I am trying to create a doorbell dzVents script. (I have a working blockly version)
The doorbell device is an RFXtrx433XL device (cheap Action stuff)
When pressed (depending on the pressure) it sends in a few milliseconds a few On commands.
So a domoticz variable is used to turn on a virtual on/off switch which sends a voice command to my google homes (in node-red)
The script is not working though because can't find how to access (read and write) the domoticz variable "deurbellen"
This my current script but apparently the "variable" method I use is not correct.
-- Send Telegram Notification if Deurbel (RFXtrx433XL) is turned on
-- and also turns on a virtual on/off switch which activates a google home voice command in node-red
Code: Select all
return {
on =
{
devices = {'Deurbel'}
},
{
variables = { 'deurbellen' }
},
execute = function(dz, variable)
local Switch = dz.devices('Bel_Schakelaar')
local Security = dz.devices('Deurbel Security')
if dz.devices('Deurbel').state == "On" and variable.value == 'Niet aangebeld' then
variable.set('Er wordt aangebeld')
Switch.cancelQueuedCommands()
Switch.switchOn()
dz.notify(Switch.name,'Er wordt aangebeld!', dz.PRIORITY_NORMAL,'','',dz.NSS_TELEGRAM)
dz.log('Device ' .. Switch.name .. ' state: ' .. Switch.state, dz.LOG_INFO)
Switch.switchOff().afterSec(8)
Security.switchNormal().afterSec(8)
variable.set('Niet aangebeld').afterSec(10)
end
end
}