After spending a lot of hours in the past two weeks trying to enhance the Lua scripting experience for Domoticz I am happy to announce dzVents on GitHub. I have been truly enjoying making this enhancement and I am glad to share it to you peeps. Maybe it makes your scripting live a lot easier as well. (Note that it is still beta, so please be patient a little here, and help out perhaps).
This is the excerpt from GitHub:
About
dzVents (|diː ziː vɛnts| short for Domotiz Easy Events) brings Lua scripting in Domoticz to whole new level. Writing scripts for Domoticz has never been so easy. Not only can you define triggers more easily, and have full control over timer-based scripts with extensive scheduling support, dzVents presents you with an easy to use API to all necessary information in Domoticz. No longer do you have to combine all kinds of information given to you by Domoticzs in many different data tables. You don't have to construct complex commandArrays anymore. dzVents encapsulates all the Domoticz peculiarities regarding controlling and querying your devices. And on top of that, script performance has increased a lot if you have many scripts because Domoticz will fetch all device information only once for all your device scripts and timer scripts.
Let's start with an example. Let's say you have a switch that when activated, it should activate another switch but only if the room temperature is above a certain level. And when done, it should send a notification. This is how it looks like in dzVents:
Code: Select all
return {
active = true,
on = {
'Room switch'
},
execute = function(domoticz, roomSwitch)
if (roomSwitch.state == 'On' and domoticz.devices['Living room'].temperature > 18) then
domoticz.devices['Another switch'].switchOn()
domoticz.notify('This rocks!',
'Turns out that it is getting warm here',
domoticz.PRIORITY_LOW)
end
end
}
Code: Select all
return {
active = true,
on = {
['timer'] = {'Every 10 minutes on mon,tue,wed,thu,fri'}
},
execute = function(domoticz)
-- check time of the day
if (domoticz.time.isDayTime and domoticz.variables['myVar'].nValue == 10) then
domoticz.variables['anotherVar'].set(15)
--activate my scene
domoticz.setScene('Evening lights', 'On')
if (domoticz.devices['My PIR'].lastUpdate.minutesAgo > 5) then
domoticz.devices['Bathroom lights'].switchOff()
end
end
end
}
....
This is just a sneek preview. And there is a lot more to tell so please read along on GitHub and let me know what you think. I have this running for a couple of days now without any problems so far and my event scripts have become almost trivial now and a lot smaller.
Oh, btw, people who tried my earlier versions may have to change their execute function a bit now that the domoticz object and device objects are passed along. Sorry for that.
Cheers,
Danny