Skip to content

Commit 596a86a

Browse files
committed
dzVents add script summary logging when debugging
Commit tested with V2020.2 (12706) without errors When dzVents debug mode is active, a summary line with clock and CPU time will be added to module.log for every script executed.
1 parent 5f4621f commit 596a86a

File tree

3 files changed

+55
-19
lines changed

3 files changed

+55
-19
lines changed

dzVents/documentation/README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Keywords recognized are "at, between, every, except, in, on " ( except supported
615615
'on -3/4,4/7-', -- before 3/4 or after 4/7
616616

617617
'at 12:45-21:15 except at 18:00-18:30', -- between 12:45 and 21:15 but not between 18:00 and 18:30 ( except supported from 3.0.16 onwards )
618-
'at daytime except on sun', -- between sunrise and sunset but not on Sundays
618+
'at daytime except on sun', -- between sunrise and sunset but not on Sundays
619619

620620
-- or if you want to go really wild and combine them:
621621
'at nighttime at 21:32-05:44 every 5 minutes on sat, sun except at 04:00', -- except supported from 3.0.16 onwards
@@ -700,8 +700,8 @@ The domoticz object holds all information about your Domoticz system. It has glo
700700
- **time**: *[Time Object](#Time_object)*: Current system time. Additional to Time object attributes:
701701
- **isDayTime**: *Boolean*
702702
- **isNightTime**: *Boolean*
703-
- **isCivilDayTime**: *Boolean*.
704-
- **isCivilNightTime**: *Boolean*.
703+
- **isCivilDayTime**: *Boolean*.
704+
- **isCivilNightTime**: *Boolean*.
705705
- **isToday**: *Boolean*. Indicates if the device was updated today
706706
- **sunriseInMinutes**: *Number*. Number of minutes since midnight when the sun will rise.
707707
- **sunsetInMinutes**: *Number*. Number of minutes since midnight when the sun will set.
@@ -927,7 +927,7 @@ If for some reason you miss a specific attribute or data for a device, then like
927927
- **timedOut**: *Boolean*. Is true when the device couldn't be reached.
928928
- **unit**: *Number*. Device unit. See device list in Domoticz' settings for the unit.
929929
- **update(< params >)**: *Function*. Generic update method. Accepts any number of parameters that will be sent back to Domoticz. There is no need to pass the device.id here. It will be passed for you. Example to update a temperature: `device.update(0,12)`. This will eventually result in a commandArray entry `['UpdateDevice']='<idx>|0|12'`. Supports [command options](#Command_options_.28delay.2C_duration.2C_event_triggering.29).
930-
930+
931931
### Device attributes and methods for specific devices
932932
Note that if you do not find your specific device type here you can always inspect what is in the `rawData` attribute. Please let us know that it is missing so we can write an adapter for it (or you can write your own and submit it). Calling `myDevice.dump()` will dump all attributes and values for myDevice to the Domoticz log.
933933

@@ -984,7 +984,7 @@ Note that if you do not find your specific device type here you can always inspe
984984
- **untilDate**: *string in ISO 8601 format* or n/a .
985985
- **updateSetPoint(setPoint, mode, until)**: *Function*. Update set point. Mode can be domoticz.EVOHOME_MODE_AUTO, domoticz.EVOHOME_MODE_TEMPORARY_OVERRIDE, domoticz.EVOHOME_MODE_FOLLOW_SCHEDULE or domoticz.EVOHOME_MODE_PERMANENT_OVERRIDE. You can provide an until date (in ISO 8601 format e.g.: `os.date("!%Y-%m-%dT%TZ")`). Supports [command options](#Command_options_.28delay.2C_duration.2C_event_triggering.29).
986986

987-
#### Evohome (controller)
987+
#### Evohome (controller)
988988
- **mode**: *string* <sup>3.0.0</sup>.
989989
- **setMode(mode, dparm, action, ooc )**: *Function*. set mode for controller. Mode can be domoticz.EVOHOME_MODE_AUTO, domoticz.EVOHOME_MODE_AUTOWITHRESET, domoticz.EVOHOME_MODE_AUTOWITHECO, domoticz.EVOHOME_MODE_AWAY, domoticz.EVOHOME_MODE_DAYOFF, domoticz.EVOHOME_MODE_CUSTOM or domoticz.EVOHOME_MODE_HEATINGOFF. dParm <optional> can be a future time string (in ISO 8601 format e.g.: `os.date("!%Y-%m-%dT%TZ")`), a future time object, a future time as number of seconds since epoch or a number representing a positive offset in minutes (max 1 year). action <optional> (1 = run on action script, 0 = disable), ooc <optional> (1 = only trigger the event & log on change, 0 = always trigger & log)
990990

@@ -1234,10 +1234,10 @@ There are many switch-like devices. Not all methods are applicable for all switc
12341234
- **direction**: *Number*. Degrees.
12351235
- **directionString**: *String*. Formatted wind direction like N, SE.
12361236
- **gust**: *Number*. ( in meters / second, might change in future releases to Meters/Counters settings for Wind Meter )
1237-
- **gustMs**: *Number*. Gust ( in meters / second )
1237+
- **gustMs**: *Number*. Gust ( in meters / second )
12381238
- **temperature**: *Number*
12391239
- **speed**: *Number*. Windspeed ( in the unit set in Meters/Counters settings for Wind Meter )
1240-
- **speedMs**: *Number*. Windspeed ( in meters / second )
1240+
- **speedMs**: *Number*. Windspeed ( in meters / second )
12411241
- **updateWind(bearing, direction, speed, gust, temperature, chill)**: *Function*. Bearing in degrees, direction in N, S, NNW etc, speed in m/s, gust in m/s, temperature and chill in Celsius. Use `domoticz.toCelsius()` to convert a Fahrenheit temperature to Celsius. Supports [command options](#Command_options_.28delay.2C_duration.2C_event_triggering.29).
12421242

12431243
#### Youless meter
@@ -1540,7 +1540,7 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
15401540
mmm -- abbreviated monthname(e.g. Sep) language depends on locale
15411541
mm -- month [01-12]
15421542
yyyy -- 4 digit year
1543-
yy -- 2 digit year
1543+
yy -- 2 digit year
15441544
hh -- hour 24-hour clock
15451545
ii -- hour 12-hour clock
15461546
MM -- minute
@@ -1576,7 +1576,7 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
15761576
- **millisecondsAgo**: *Number*. Number of milliseconds since the last update.
15771577
- **minutes**: *Number*
15781578
- **minutesAgo**: *Number*. Number of minutes since the last update.
1579-
- **minutesSinceMidnight**: *Number*
1579+
- **minutesSinceMidnight**: *Number*
15801580
- **month**: *Number*
15811581
- **monthAbbrName**: String. jan, feb, mar, etc
15821582
- **monthName**: *String*. January, February, etc
@@ -1599,7 +1599,7 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
15991599
domoticz.time.timestampToDate(60,'ddd mm mmm yyyy ii:MM mer','date time') --> 'Thu 01 Jan 1970 01:01 AM''
16001600
domoticz.time.timestampToDate(1598077445,'dd/mm/yy ii:MM mer nZero') --> '22/08/20 8:24 AM'
16011601
```
1602-
1602+
16031603
- **toUTC(string | table,[offset])**: *domoticz time object*. <sup>3.0.9</sup> returns domoticz time object based on first parameter (time as table or string) string format must be 'yyyy-mm-dd hh:mm:ss'. offset defaults to 0.
16041604
- **utcSystemTime**: *Table*. UTC system time (only when in UTC mode):
16051605
- **day**: *Number*
@@ -2096,7 +2096,7 @@ For every script file that defines persisted variables (using the `data={ … }`
20962096

20972097
domoticz/
20982098
scripts/
2099-
dzVents/
2099+
dzVents/
21002100
data/
21012101
__data_yourscript1.lua
21022102
__data_yourscript2.lua
@@ -2352,7 +2352,7 @@ Settings for dzVents are found in the Domoticz GUI: **Setup > Settings > Other >
23522352
- *Errors*,
23532353
- *Errors + minimal execution info*: Errors and some minimal information about which script is being executed and why,
23542354
- *Errors + minimal execution info + generic info*. Even more information about script execution and a bit more log formatting.
2355-
- *Debug*. Shows everything and dzVents will create a file `domoticzData.lua` in the dzVents folder. This is a dump of all the data received by dzVents from Domoticz.. These data are used to create the entire dzVents data structure.
2355+
- *Debug*. Shows everything and dzVents will create the files `domoticzData.lua` and `module.log` in the scripts/dzVents folder. `domoticzData.lua` is a dump of all the data received by dzVents from Domoticz and `module.log` is a summary of the execution time and CPU usage of the user scripts active during the debug period.
23562356
- *No logging*. As silent as possible.
23572357

23582358
# Troubleshooting
@@ -2367,9 +2367,22 @@ Make sure the active section in your script is set to `true`: `active = true`.
23672367
### Turn on debug logging
23682368
Activate debug logging in the settings (see above). This will produce a lot of extra messages in the Domoticz log (don't forget to turn it off when you are done troubleshooting!). It is best to monitor the log through the command line, as the log in the browser sometimes tends to not always show all log messages. See the Domoticz manual for how to do that.
23692369

2370-
When debug logging is enabled, every time dzVents kicks into action (Domoticz throws an event) it will log it, and it will create a file `/path/to/domoticz/scripts/dzVents/domoticzData.lua` with a dump of the data sent to dzVents. These data lie at the core of the dzVents object model. You can open this file in an editor to see if your device/variable/scene/group/hardware is in there. Note that the data in the file are not exactly the same as what you will get when you interact with dzVents, but it is a good start. If your object is not in the data file, then you will not have access to it in dzVents and dzVents will not be able to match triggers with that object. Something's wrong if you expect your object to be in there but it is not (is the object active/used?).
2370+
When debug logging is enabled, every time dzVents kicks into action (Domoticz throws an event) it will log it, and it will create the files `domoticzData.lua` and `module.log` in `/path/to/domoticz/scripts/dzVents`. `domoticzData.lua` is a dump of all the data received by dzVents from Domoticz. This data lie at the core of the dzVents object model. You can open this file in an editor to see if your device/variable/scene/group/hardware is in there. Note that the data in the file are not exactly the same as what you will get when you interact with dzVents, but it is a good start. If your object is not in the data file, then you will not have access to it in dzVents and dzVents will not be able to match triggers with that object. Something's wrong if you expect your object to be in there but it is not (is the object active/used?).
2371+
`module.log` is a summary of the execution time and CPU usage of the user scripts active during the debug period.with a dump of the data sent to dzVents.
2372+
2373+
Example content of `module.log`
2374+
```
2375+
Startdate time - End date time (clk - CPU ) module / scriptname << type: "trigger"
2376+
---------------------------------------------------------------------------------------------------------------
2377+
11/27/20 18:40:00 - 11/27/20 18:40:00 (00 - 0.0029) waqi.lua << timer: "every 20 minutes"
2378+
11/27/20 18:40:00 - 11/27/20 18:40:00 (00 - 0.0016) Washer.lua << timer: "every 5 minutes"
2379+
11/27/20 18:40:01 - 11/27/20 18:40:01 (00 - 0.0215) getWaterFromHomewizard.lua << HTTPResponse: "WaterfromHomewizard"
2380+
11/27/20 18:40:03 - 11/27/20 18:40:03 (00 - 0.2472) updateWeatherSensors.lua << HTTPResponse: "WUS_buienradarResponse"
2381+
11/27/20 18:40:03 - 11/27/20 18:40:03 (00 - 0.0290) waqi.lua << HTTPResponse: "waqi_nearby"
2382+
11/27/20 18:41:00 - 11/27/20 18:41:00 (00 - 0.0583) Bathroom humidity.lua << timer: "every minute between 05:15 and 23:30"
2383+
```
23712384

2372-
Every time Domoticz starts dzVents and debug logging is enabled you should see these lines:
2385+
Every time Domoticz starts dzVents and debug logging is enabled you should see these lines in the domoticz log:
23732386
```
23742387
dzVents version: x.y.z
23752388
Event trigger type: aaaa

dzVents/documentation/README.wiki

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ There are several options for time triggers. It is important to know that Domoti
592592
'on -3/4,4/7-', -- before 3/4 or after 4/7
593593
594594
'at 12:45-21:15 except at 18:00-18:30', -- between 12:45 and 21:15 but not between 18:00 and 18:30 ( except supported from 3.0.16 onwards )
595-
'at daytime except on sun', -- between sunrise and sunset but not on Sundays
595+
'at daytime except on sun', -- between sunrise and sunset but not on Sundays
596596
597597
-- or if you want to go really wild and combine them:
598598
'at nighttime at 21:32-05:44 every 5 minutes on sat, sun except at 04:00', -- except supported from 3.0.16 onwards
@@ -1525,7 +1525,7 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
15251525
mmm -- abbreviated monthname(e.g. Sep) language depends on locale
15261526
mm -- month [01-12]
15271527
yyyy -- 4 digit year
1528-
yy -- 2 digit year
1528+
yy -- 2 digit year
15291529
hh -- hour 24-hour clock
15301530
ii -- hour 12-hour clock
15311531
MM -- minute
@@ -2296,7 +2296,7 @@ Settings for dzVents are found in the Domoticz GUI: '''Setup &gt; Settings &gt;
22962296
** ''Errors'',
22972297
** ''Errors + minimal execution info'': Errors and some minimal information about which script is being executed and why,
22982298
** ''Errors + minimal execution info + generic info''. Even more information about script execution and a bit more log formatting.
2299-
** ''Debug''. Shows everything and dzVents will create a file <code>domoticzData.lua</code> in the dzVents folder. This is a dump of all the data received by dzVents from Domoticz.. These data are used to create the entire dzVents data structure.
2299+
** ''Debug''. Shows everything and dzVents will create the files <code>domoticzData.lua</code> and <code>module.log</code> in the scripts/dzVents folder. <code>domoticzData.lua</code> is a dump of all the data received by dzVents from Domoticz and <code>module.log</code> is a summary of the execution time and CPU usage of the user scripts active during the debug period.
23002300
** ''No logging''. As silent as possible.
23012301
23022302
= Troubleshooting =
@@ -2315,9 +2315,19 @@ Make sure the active section in your script is set to <code>true</code>: <code>a
23152315
23162316
Activate debug logging in the settings (see above). This will produce a lot of extra messages in the Domoticz log (don’t forget to turn it off when you are done troubleshooting!). It is best to monitor the log through the command line, as the log in the browser sometimes tends to not always show all log messages. See the Domoticz manual for how to do that.
23172317
2318-
When debug logging is enabled, every time dzVents kicks into action (Domoticz throws an event) it will log it, and it will create a file <code>/path/to/domoticz/scripts/dzVents/domoticzData.lua</code> with a dump of the data sent to dzVents. These data lie at the core of the dzVents object model. You can open this file in an editor to see if your device/variable/scene/group/hardware is in there. Note that the data in the file are not exactly the same as what you will get when you interact with dzVents, but it is a good start. If your object is not in the data file, then you will not have access to it in dzVents and dzVents will not be able to match triggers with that object. Something’s wrong if you expect your object to be in there but it is not (is the object active/used?).
2318+
When debug logging is enabled, every time dzVents kicks into action (Domoticz throws an event) it will log it, and it will create the files <code>domoticzData.lua</code> and <code>module.log</code> in <code>/path/to/domoticz/scripts/dzVents</code>. <code>domoticzData.lua</code> is a dump of all the data received by dzVents from Domoticz. This data lie at the core of the dzVents object model. You can open this file in an editor to see if your device/variable/scene/group/hardware is in there. Note that the data in the file are not exactly the same as what you will get when you interact with dzVents, but it is a good start. If your object is not in the data file, then you will not have access to it in dzVents and dzVents will not be able to match triggers with that object. Something’s wrong if you expect your object to be in there but it is not (is the object active/used?). <code>module.log</code> is a summary of the execution time and CPU usage of the user scripts active during the debug period.with a dump of the data sent to dzVents.
23192319
2320-
Every time Domoticz starts dzVents and debug logging is enabled you should see these lines:
2320+
Example content of <code>module.log</code>
2321+
2322+
<pre> Startdate time - End date time (clk - CPU ) module / scriptname &lt;&lt; type: &quot;trigger&quot;
2323+
---------------------------------------------------------------------------------------------------------------
2324+
11/27/20 18:40:00 - 11/27/20 18:40:00 (00 - 0.0029) waqi.lua &lt;&lt; timer: &quot;every 20 minutes&quot;
2325+
11/27/20 18:40:00 - 11/27/20 18:40:00 (00 - 0.0016) Washer.lua &lt;&lt; timer: &quot;every 5 minutes&quot;
2326+
11/27/20 18:40:01 - 11/27/20 18:40:01 (00 - 0.0215) getWaterFromHomewizard.lua &lt;&lt; HTTPResponse: &quot;WaterfromHomewizard&quot;
2327+
11/27/20 18:40:03 - 11/27/20 18:40:03 (00 - 0.2472) updateWeatherSensors.lua &lt;&lt; HTTPResponse: &quot;WUS_buienradarResponse&quot;
2328+
11/27/20 18:40:03 - 11/27/20 18:40:03 (00 - 0.0290) waqi.lua &lt;&lt; HTTPResponse: &quot;waqi_nearby&quot;
2329+
11/27/20 18:41:00 - 11/27/20 18:41:00 (00 - 0.0583) Bathroom humidity.lua &lt;&lt; timer: &quot;every minute between 05:15 and 23:30&quot;</pre>
2330+
Every time Domoticz starts dzVents and debug logging is enabled you should see these lines in the domoticz log:
23212331
23222332
<pre>dzVents version: x.y.z
23232333
Event trigger type: aaaa</pre>

dzVents/runtime/EventHelpers.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,19 @@ local function EventHelpers(domoticz, mainMethod)
449449
utils.log('------ Finished ' .. moduleLabel , utils.LOG_MODULE_EXEC_INFO)
450450
end
451451

452+
if (tonumber(globalvariables['dzVents_log_level']) == utils.LOG_DEBUG or TESTMODE ) then
453+
local moduleSummary = globalvariables.script_path .. 'module.log'
454+
utils.log('Debug: Writing module summary to ' .. moduleSummary ,utils.LOG_FORCE)
455+
456+
local f = io.open(moduleSummary, 'a' )
457+
f:write(
458+
os.date('%x %X - ',timeStampAtStart) .. os.date('%x %X ') .. '(' ..
459+
string.format('%02d', realTimeSpend) .. ' - ' .. string.format('%.4f',clockTimeSpend) ..
460+
') ' .. string.format('%35s',moduleLabel) .. ' <<' .. moduleLabelInfo ..
461+
( eventHandler.trigger and ( ' timer: "' .. eventHandler.trigger .. '"' ) or '') ,'\n')
462+
f:close()
463+
end
464+
452465
restoreLogging()
453466
end
454467
end

0 commit comments

Comments
 (0)