dzVents 2.3.0 released in v3.8551

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

dzVents 2.3.0 released in v3.8551

Post by dannybloe »

-----------------------------------------------------------------------------------------------------------
Update 2: dzVents 2.3.0 is now included in the various downloads and tarballs and is also included when you do an ./updatebeta. Yay!
-----------------------------------------------------------------------------------------------------------
Update: for now you have to either download the sources from github or download the tarballs from the Domoticz website. If you use updatebeta you may not get all the necessary files yet. Sorry for that but it surely will be fixed anytime soon.
-----------------------------------------------------------------------------------------------------------


Hiya folks,

I'm proud to tell you that dzVents 2.3.0 has been merged into Domoticz v3.8551. Thanks to the hard work of jvandenbroek and myself we have brought event scripting in Domoticz to an even higher and easier level. Before showing the long list of changes let's start with a few highlights of this great release:

Group- and scene-events

Long awaited and finally there: as of now you can write event scripts for group and scene changes. This can be very handy if you want to write an event script when you trigger a scene from a z-wave device (like double tapping a wall-switch). Earlier you had to create dummy switches that were part of your scene and create an event script for that dummy device. No longer! simply do this in your script:

Code: Select all

return {
	on = {
		groups = { 'myGroup1' },
	},
	execute = function(domoticz, group)
		-- do you thing
	end
}
or

Code: Select all

return {
	on = {
		scenes = { 'myScene1' },
	},
	execute = function(domoticz, scene)
		-- do you thing
	end
}

Extended event triggering and command options

Earlier there were quite some situations where devices/variables etc. were updated but no follow-up events were triggered. That is no longer the case. If you update a device or a variables, group, scene etc., dzVents is now always notified so follow-up event scripts are directly triggered. Of course you may not always want this so we added the .silent() option. More on that later. Anyway, it is no longer needed to use the web API to update stuff from your event scripts only to make sure that your event scripts will be triggered afterwards! Oh... and beware that you don't create event-loops where scripts trigger themselves endlessly! This was already possible so check your logs if your systems stops responding :lol:.

Now that we enhanced the underlying event-system in Domoticz we also made sure that the command options that were already there in Domoticz are now fully exposed to dzVents (traditionally the FOR, AFTER, RANDOM stuff you put in your command-array):

Code: Select all

-- switch on after 1 minute for 10 seconds and repeat that 5 times with 1 minute in between:
myDevice.switchOn().afterMin(1).forSec(10).repeatAfterMin(1, 5)

myUserVar.set(12).afterMin(3)
All command options (for, after, within, repeatAfter) now support seconds (-Sec), minutes (-Min) and hours (-Hour). So you can do forMin(xx), forSec(xx), forHour(xx), afterSec(xx), afterMin(xx) etc.

As a bonus there is also the option .checkFirst():

Code: Select all

mySwitch.switchOn().checkFirst()
Which will only send a switch command when the switch isn't already on! This saves an if-statement. Beware though that some devices do not report their status back to Domoticz properly (even some z-wave devices have that nasty habit sometimes). For these devices you shouldn't check for the state at all, just send the command.

As mentioned earlier, all updates and changes will now trigger the event system but in some situations you may not want this to happen. Fear no more: .silent() comes to rescue. You can silently turn on a switch, update a sensor or variable like this:

Code: Select all

mySwitch.switchOn().withinMin(5).silent() -- will not trigger an event
So, again, unless you add the .silent() option, your commands will always trigger events.

See the documentation for more examples.

More timer rules

A timer rule is added: 'between xx and yy'. You can now create rules like these:

Code: Select all

return {
	on = {
		timer = {
			'between 12:45 and sunset'
		}
	},
	...
}
Or you can go wild:

Code: Select all

return {
	on = {
		timer = {
			'every 10 minutes between 20 minutes before sunset and 30 minutes after sunrise on mon,fri,tue'
		}
	},
	...
}
Note that when you use between xx and yy, the xx and yy need to be moments and not intervals. So you can use 'at 12:30' or '30 minutes before sunrise' (which again is an exact moment) but not 'at 14:*' (interval) or 'at daytime' (interval as well). Oh, and it doesn't work yet with days so don't try 'between sat and fri'.

See timer trigger options in the documentation.

Boilerplate scripts for dzVents in GUI editor

A handful of handy boilerplate script tempates are made available in Domoticz' GUI script editor. On the right side, pick dzVents as the language and you will see them in third select box (you may have to press the New button after you picked a template):
guieditor-dzvents.png
guieditor-dzvents.png (25.02 KiB) Viewed 3810 times
guieditor-boilerplates.png
guieditor-boilerplates.png (37.29 KiB) Viewed 3810 times
Oh.. and the active = true/false section in your script is now optional as the GUI editor already has a switch to enable/disable the script. So you can leave that out (unless of course you want to create a clever custom dynamic active function).

Work with times

One of the goals of dzVents has always been to make working with timestamps as simple as possible. To make it even simpler, a compare function is added so you can quickly compare two time objects and see how far apart they are:

Code: Select all

local Time = require('Time')
local tA = Time('2016-12-12 07:35:00')
local tB = Time('2016-12-12 08:35:00')

print(tB.compare(tA).minutes) -- prints 60
print(tB.compare(tA).compare) -- 0 = both are equal, 1 = time is in the future, -1 = time is in the past.

Check out Time object.

Documentation

The documentation in the wiki is updated as well with a lot more examples to get you started even faster. A whole new troubleshooting section is added as well.

New location

Previously dzVents' runtime files were located inside the scripts folder. That turned out to be not so handy as the scripts folder is intended for the user and not for runtime files. So we moved these files to a new location (/path/to/domoticz/dzVents). At startup the old runtime files are removed. Your scripts will remain in /path/to/domoticz/scripts/dzVents/scripts. So now you can just backup and restore your entire scripts folder without running the risk of overwriting the latest and greatest of dzVents runtime stuff with an older version from your backups.

Change log

Here is the full list of changes:
  • Added 'active' attribute to devices (more logical naming than the attribute 'bState'). 'myDevice.active' is true or false depending on a set of known state values (like On, Off, Open, Closed etc). Use like 'if mySwitch.active then .. end'
  • Added 'domoticz.urlEncode()' method on the 'domoticz' object so you can prepare a string before using it with 'openURL()'.
  • Updating devices, user variables, scenes and groups now always trigger the event system for follow-up events.
  • Added support for groups and scenes change-event scripts. Use 'on = { scenes = { 'myScene1', 'myScene2' }, groups = {'myGroup1'} }'
  • Added adapter for the new Temperature+Barometer device.
  • Added 'domoticz.startTime' giving you the time at which the Domoticz service was started. Returns a Time object.
  • Added 'domoticz.systemUptime' (in seconds) indicating the number of seconds the machine is running. Returns a Time object.
  • Added more options to the various commands/methods: e.g. 'myDevice.switchOff().silent()', '.forSec()', '.forHour()', '.afterHour()', '.repeatAfterSec()', '.repeatAfterMin()', '.repeatAfterHour()', '.withinHour()' and '.checkFirst()'. This now works not only for devices but also scenes, groups and user variables. See documentation about command options.
  • Added '.silent()' option to commands like 'switchOn().afterSec(4).silent()' causing no follow-up events to be triggered. This also works when updating non-switch-like devices, scenes, groups and user variables. If you do not call 'silent()'`, a follow-up event is *always* triggered (for devices, scenes, groups and user variables).
  • Added time rule 'between xx and yy'. You can now do things like: 'between 16:34 and sunset' or 'between 10 minutes before sunset and sunrise'. See the doc.
  • Added support for milliseconds in 'Time' object. This also gives an ms part in the time-stamp for historical persistent data. You can now do 'msAgo()' on time stamp when you inspect a data point from an history variable.
  • Added 'daysAgo()' to 'Time' object.
  • Added 'compare(time)' method to 'Time' object to calculate the difference between them. Returns a table. See documentation.
  • Added 'domoticz.round()' method to 'domoticz' object.
  • Added 'text' property to alert sensor.
  • 'active' section is now optional in your dzVents script. If you don't specify an 'active = true/false' then true is assumed (script is active). Handy for when you use Domoticz' GUI script editor as it has its own way of activating and deactivating scripts.
  • Added 'humidityStatusValue' for humidity devices. This value matches with the values used for setting the humidity status.
  • 'Time' object will initialize to current time if nothing is passed: 'local current = Time()'.
  • Added the lua Lodash library (http://axmat.github.io/lodash.lua, MIT license).
  • Fixed documentation about levelNames for selector switches and added the missing levelName.
  • Moved dzVents runtime code away from the '/path/to/domoticz/scripts/dzVents' folder as this scripts folder contains user stuff.
  • Added more trigger examples in the documentation.
  • You can now put your own non-dzVents modules in your scripts folder or write them with the Domoticz GUI editor. dzVents is no longer bothered by it. You can require your modules in Lua's standard way.
  • Added '/path/to/domoticz/scripts/dzVents/scripts/modules' and '/path/to/domoticz/scripts/dzVents/modules' to the Lua package path for custom modules. You can now place your modules in there and require them from anywhere in your scripts.
  • Added dzVents-specific boilerplate/templates for internal web editor.
  • Fixed the confusing setting for enabling/disabling dzVents event system in Domoticz settings.
  • Fixed a problem where if you have two scripts for a device and one script uses the name and the other uses the id as trigger, the id-based script wasn't executed.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
scottydj2
Posts: 15
Joined: Monday 06 February 2017 11:09
Target OS: Windows
Domoticz version:
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by scottydj2 »

Excellent work guys!

Thanks.

Scott
zynexiz
Posts: 8
Joined: Tuesday 07 February 2017 13:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: Sweden
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by zynexiz »

Just updated my Pi to v3.8551, and according to this document the path do dzVents has moved to domoticz root (~/domoticz/dzVents), but this is not the case for me. Can't find dzVents runtimes anywhere, not even under scripts. There is also an error in the log;
EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: cannot open /home/pi/domoticz/dzVents/runtime/dzVents.lua: No such file or directory
[EDIT] Downgrading to v3.8153 got dzVents back again.
Last edited by zynexiz on Friday 06 October 2017 11:50, edited 1 time in total.
User avatar
Phantom
Posts: 87
Joined: Saturday 31 December 2016 14:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11652
Location: The Netherlands
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by Phantom »

zynexiz wrote: Friday 06 October 2017 11:37 Just updated my Pi to v3.8551, and according to this document the path do dzVents has moved to domoticz root (~/domoticz/dzVents), but this is not the case for me. Can't find dzVents runtimes anywhere, not even under scripts. There is also an error in the log;
EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: cannot open /home/pi/domoticz/dzVents/runtime/dzVents.lua: No such file or directory
Same here.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

I think that's because the linux build hasn't been updated yet. Somehow. :?
You can download dzVents folder from github for the time being. Extract it and put dzVents in the root of your Domoticz install.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
Phantom
Posts: 87
Joined: Saturday 31 December 2016 14:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11652
Location: The Netherlands
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by Phantom »

Strange indeed, thanks i copied the dzVents folder and all seems to work good now :)
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

v3.8552 is being build.. that should work with updatebeta.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: dzVents 2.3.0 released in v3.8551

Post by BakSeeDaa »

dannybloe wrote: Friday 06 October 2017 12:58 v3.8552 is being build.. that should work with updatebeta.
Just installed v3.8552 using the GUI, (not directly incoking the updatebeta script) I had to install the dzVents runtime manually as described above.

;)

Thanks you @Dannybloe for all the hard work!
bdormael
Posts: 82
Joined: Saturday 13 December 2014 21:20
Target OS: Linux
Domoticz version:
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by bdormael »

dannybloe wrote: Friday 06 October 2017 12:58 v3.8552 is being build.. that should work with updatebeta.
Can we safely upgrade via the webapplication without doing anything else manually ?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

No, I am afraid not. You'll have to download the beta tarbal from the website instead of using updatebeta. :(
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
randytsuch
Posts: 90
Joined: Sunday 20 March 2016 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: LA, Ca USA
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by randytsuch »

Wow, you've been busy Danny.
Great stuff, thanks.

I do have one question.
About your works with time, comparing time example.
It looks like the times are one hour apart, but the code appears to be comparing seconds, and saying result will be 60.

Am I missing something?

Randy
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

Good catch. Small mistake. I’ll fix it above.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
marton
Posts: 10
Joined: Sunday 17 April 2016 10:04
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8235
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by marton »

I have installed the latest beta v3.8552 and had to manually copy the dzvents files. However in Settings/Other dzvents is disabled, and no matter how many times I enable it and saves settings it stays disabled. Do you guys have any tips?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

marton wrote: Saturday 07 October 2017 10:30 I have installed the latest beta v3.8552 and had to manually copy the dzvents files. However in Settings/Other dzvents is disabled, and no matter how many times I enable it and saves settings it stays disabled. Do you guys have any tips?
Have you tried to clear (all) your browser caches or tried different browsers?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
marton
Posts: 10
Joined: Sunday 17 April 2016 10:04
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8235
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by marton »

Thanks! Different browser helped. But now none of my scripts are running. And in settings, the version number has disappeared.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

Version is moved to the general about menu.
None of your dzVents scripts?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
marton
Posts: 10
Joined: Sunday 17 April 2016 10:04
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8235
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by marton »

dannybloe wrote: Saturday 07 October 2017 10:48 Version is moved to the general about menu.
None of your dzVents scripts?
The version in about is 2.3.0.

No, none of my scripts work. I've tried restarting domoticz, that didn't help either.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by dannybloe »

Looks like all events are disabled somehow. Strange.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
marton
Posts: 10
Joined: Sunday 17 April 2016 10:04
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8235
Contact:

Re: dzVents 2.3.0 released in v3.8551

Post by marton »

dannybloe wrote: Saturday 07 October 2017 10:55 Looks like all events are disabled somehow. Strange.
Tried disabling the event system, dzvents, restarting, nothing changed. Going back to my backup now :)
SweetPants

Re: dzVents 2.3.0 released in v3.8551

Post by SweetPants »

Working still over here after update to V3.8551 compiled from source
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest