You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dzVents/documentation/README.md
+55-50Lines changed: 55 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,7 +219,6 @@ The customEvent object (second parameter in your execute function) has these att
219
219
-**xmlEncoding**. *String*. When the response data is `text/xml` See [ xml encoding] ( https://en.wikipedia.org/wiki/XML ).
220
220
-**xmlVersion**. *String*. When the response data is `text/xml` See [ xml versions ] ( https://en.wikipedia.org/wiki/XML ).
221
221
222
-
223
222
#### devices = { ... }
224
223
A list of device-names or indexes. If a device in your system was updated (e.g. a switch was triggered or a new temperature was received) and it is listed in this section then the execute function is executed. **Note**: update does not necessarily means the device state or value has changed. Each device can be:
225
224
@@ -264,12 +263,11 @@ A list of one or more system triggers.
264
263
- **start** - fired when Domoticz has started.
265
264
- **stop** - fired when Domoticz is shutting down. As you probably can imagine you have only a limited amount of time - also depending on the load on your system - to have Domoticz do stuff when your script has been completed. Some commands will probably not be executed. Just give it a try.
266
265
- **Backups** - the trigger item (2nd parameter of the execute function) is a table that holds information about the newly created backup (location, duration in seconds and type). You could use this information to copy the file to some other location or for another purpose.
267
-
- **dailyBackupFinished**- automatic backup when set in domoticz
266
+
- **dailyBackupFinished**- automatic backup when set in domoticz
268
267
- **hourlyBackupFinished** - " "
269
268
- **monthlyBackupFinished** - " "
270
269
- **manualBackupFinished** - fired when you start a backup using the Domoticz GUI or via **< domoticz IP:domoticz port >**/backupdatabase.php
271
270
272
-
273
271
#### timer = { ... }
274
272
A list of one ore more time 'rules' like `every minute` or `at 17:*`. See [*timer* trigger rules](#timer_trigger_rules). If any or the rules matches with the current time/date then your execute function is called. E.g.: `on = { timer = { 'between 30 minutes before sunset and 30 minutes after sunrise' } }`.
275
273
@@ -528,9 +526,9 @@ return {
528
526
execute=function(domoticz, item)
529
527
if (item.isTimer) then
530
528
domoticz.executeShellCommand({
531
-
command='speedtest-cli --json', -- just an example
532
-
callback='internetspeedRetrieved', -- see shellCommandResponses above.
533
-
timeout=20, -- max execution time in seconds
529
+
command='speedtest-cli --json', -- just an example
530
+
callback='internetspeedRetrieved', -- see shellCommandResponses above.
531
+
timeout=20, -- max execution time in seconds
534
532
})
535
533
elseif (item.isShellCommandResponse) then
536
534
if (item.statusCode==0) then
@@ -726,11 +724,11 @@ The domoticz object holds all information about your Domoticz system. It has glo
726
724
-**snapshot(cameraID(s) or camera Name(s)<sup>3.0.13</sup>,subject)**: *Function*. Sends email with a camera snapshots if email is configured and set for attachments in Domoticz. Send 1 or multiple camerIDs -names in ; separated string or array.
727
725
728
726
```Lua
729
-
dz.snapshot() -- defaults to id = 1, subject domoticz
730
-
dz.snapshot(1,'dz') -- subject dz
731
-
dz.snapshot('1;2;3') -- ; separated string
732
-
dz.snapshot({1,4,7}) -- table
733
-
dz.snapshot('test;test2') -- ; separated string
727
+
dz.snapshot() -- defaults to id = 1, subject domoticz
728
+
dz.snapshot(1,'dz') -- subject dz
729
+
dz.snapshot('1;2;3') -- ; separated string
730
+
dz.snapshot({1,4,7}) -- table
731
+
dz.snapshot('test;test2') -- ; separated string
734
732
dz.snapshot({'test', 'test2'}) -- table
735
733
```
736
734
@@ -804,7 +802,7 @@ The domoticz object holds all information about your Domoticz system. It has glo
- **osCommand(cmd)**: *Function*: <sup>3.0.13</sup> Execute an OS command and return result and returncode. Note: For long running scripts `domoticz.executeShellCommand()` should be used, See [Asynchronous shell commands](#Asynchronous_shell_command_execution) for more information.
807
-
- **osExecute(cmd)**: *Function*: Execute an OS command (no return). Note: For long running scripts `executeShellCommand()` should be used. See [Asynchronous shell commands](#Asynchronous_shell_command_execution) for more information.
805
+
- **osExecute(cmd)**: *Function*: Execute an OS command (no return). Note: For long running scripts `executeShellCommand()` should be used. See [Asynchronous shell commands](#Asynchronous_shell_command_execution) for more information.
808
806
- **rightPad(string, length [, character])**: *Function*: Succeed string with given character(s) (default = space) to given length.
809
807
- **round(number, [decimalPlaces])**: *Function*. Helper function to round numbers. Default decimalPlaces is 0.
810
808
- **sceneExists(parm)**: *Function*: returns name when entered with valid scene ^3.0.12^ or sceneID and return ID when entered with valid sceneName or false when not a scene, sceneID or sceneName of an existing scene
@@ -1004,10 +1002,10 @@ Note that if you do not find your specific device type here you can always inspe
1004
1002
-**updateCounter(value)**: *Function*. **Overwrite current value for managed and standard counters; increment for incremental counters !!**. Supports [command options](#Command_options_.28delay.2C_duration.2C_event_triggering.29).
1005
1003
-**incrementCounter(value)**: *Function*. (counter incremental) Supports [command options](#Command_options_.28delay.2C_duration.2C_event_triggering.29). To update with a complete new value you will have to do some calculation and take the counter divider into account.
1006
1004
```Lua
1007
-
localnewValue=value
1008
-
localiCounter=domoticz.devices('device name')
1009
-
localcounterDivider=x-- x is depending on the counter divider set for the device
Some options are not available to all commands. All the options are available to device switch-like commands like `myDevice.switchOff()`, `myGroup.switchOn()` or `myBlinds.open()`. For updating (usually Dummy ) devices like a text device `myTextDevice.updateText('zork')` you can only use `silent()`. For thermostat setpoint devices and snapshot command silent() is not available. For commands for which dzVents must use openURL, only `at()` and `afterAAA()` methods are available. These commands are mainly the setAaaaa() commands for RGBW type devices.
1391
1389
1392
-
1393
1390
See table below
1394
1391
1395
1392
```{=mediawiki}
@@ -1584,8 +1581,8 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
1584
1581
-**dateToDate( dateString, sourceFormat, targetFormat[ , offSet] )**:<sup>3.0.17</sup> *Function*: Returns a reformatted datestring. dateString is a formatted date and source- and targetFormat are representations of the dateString elements and their locations in the string (see examples in dateToTimestamp) . Offset is a number (default = 0 )
-**dateToTimestamp([ dateString [,control]] )**: *Function*: Returns *Number* representing time since epoch in seconds. dateString is a formatted date and control is a representation of the dateString elements and their location in the string. Default control is 'yyyy-mm-dd hh:MM'.
@@ -1611,11 +1608,11 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
@@ -1651,7 +1648,7 @@ local someTime = domoticz.time.makeTime() -- someTime = new domoticz time object
1651
1648
-**sunriseInMinutes**: *Number*. Minutes from midnight until sunrise.
1652
1649
-**solarnoonInMinutes**: *Number*. <sup>3.0.11</sup> Minutes from midnight until solarnoon.
1653
1650
-**time**: *String*. Returns the time part of the raw data as HH:MM
1654
-
-**timestampToDate([[ timestamp ] , [ pattern ] ,[ offSet ] )**: *function*. Returns a datestring. timestamp is number of seconds since epoch (default = now) , pattern is a string as explained in this wiki at the description of the domoticz.time.date2Timestamp function (default = 'yyyy-mm-dd hh:MM:ss'). Offset is a number (default = 0 )
1651
+
-**timestampToDate([[ timestamp ] , [ pattern ] ,[ offSet ] )**: *function*. Returns a datestring. timestamp is number of seconds since epoch (default = now) , pattern is a string as explained in this wiki at the description of the domoticz.time.dateToTimestamp function (default = 'yyyy-mm-dd hh:MM:ss'). Offset is a number (default = 0 )
dzVents allows you to make asynchronous shell commands and handle the results. Asynchronous means that you don't block the system while waiting for the response. Earlier you had to use functions like `utils.osCommand()` or `os.Execute()` and some magic to make sure that you didn't block the system for too long after which Domoticz comes with a message that the script took more than 10 seconds.
2418
2414
2419
2415
dzVents to the rescue. With dzVents there are two ways to execute a shell command asynchronously and it is determined by how you use the `domoticz.executeShellCommand()` command. The simplest form simply calls `executeShellCommand` on the domoticz object with only the command as the parameter (a string value):
@@ -2457,22 +2453,31 @@ return {
2457
2453
```
2458
2454
Of course you can combine the script that issues the request and handles the response in one script:
2459
2455
```Lua
2460
-
return {
2461
-
on= {
2462
-
timer= {'every 5 minutes'},
2463
-
shellCommandResponses= { 'trigger' }
2456
+
return
2457
+
{
2458
+
on=
2459
+
{
2460
+
timer=
2461
+
{
2462
+
'every 5 minutes',
2463
+
},
2464
+
shellCommandResponses=
2465
+
{
2466
+
scriptVar,
2467
+
},
2464
2468
},
2469
+
2465
2470
execute=function(domoticz, item)
2466
-
if (item.isTimer) then
2467
-
domoticz.executeShellCommand({
2468
-
command='...',
2469
-
callback='trigger'
2470
-
timeout=10,
2471
+
ifitem.isTimerthen
2472
+
domoticz.executeShellCommand(
2473
+
{
2474
+
command='some shell command',
2475
+
callback=scriptVar,
2476
+
timeout=timeoutinseconds,
2471
2477
})
2472
-
end
2473
-
ifitem.isShellCommandResponsethen
2478
+
elseifitem.isShellCommandResponseandthen
2474
2479
ifitem.statusCode==0then
2475
-
...
2480
+
...-- process result (in item.json, -item.xml, -item.lines or item.data)
2476
2481
end
2477
2482
end
2478
2483
end
@@ -2539,14 +2544,14 @@ When debug logging is enabled, every time dzVents kicks into action (Domoticz th
2539
2544
2540
2545
Example content of `module.log`
2541
2546
```
2542
-
Startdate time- End date time(clk - CPU ) module / scriptname << type: "trigger"
2547
+
Startdate time- End date time(clk - CPU ) dule / scriptname << type: "trigger"
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"
2550
2555
```
2551
2556
2552
2557
Every time Domoticz starts dzVents and debug logging is enabled you should see these lines in the domoticz log:
@@ -2607,7 +2612,7 @@ Check out the documentation [here](https://htmlpreview.github.io/?https://github
2607
2612
- Fixed bug in dumpTable that caused infinite loop for table with self-reference
2608
2613
2609
2614
## [3.0.17]
2610
-
- Add timestampTodate, dateToTimestamp and date2date functions in Time
2615
+
- Add timestampTodate, dateToTimestamp and dateToDate functions in Time
2611
2616
2612
2617
## [3.0.16]
2613
2618
- Add except as keyword in timeRules
@@ -2688,7 +2693,7 @@ Check out the documentation [here](https://htmlpreview.github.io/?https://github
2688
2693
- Add custom-events triggers as option to the on = { ... } section. You can now send an event trigger to start subscribed dzVents scripts. customEvents can be triggered by:
2689
2694
- dzVents domoticz.emitEvent(name, data ) -- command (data = optional)
2690
2695
- JSON: json.htm?type=command¶m=customevent&event=MyEvent&data=myData ( data = optional )
0 commit comments