I have one of those 433 Mhz Kerui door switches connected up to a relay which indicates when volts are no longer going through the door switch heater. Everything is working ok except my code. Instead of getting a delayed message that the door is "unlocked" I get the message immediately.
If I remove the "and washmachinedoor.lastUpdate.minutesAgo >= 5" delay then it all works fine without a delay.
Can anyone tell me where I am going wrong...
return {
on = {
devices = {
'WashMachine-D3'
}
},
execute = function(domoticz, device)
domoticz.log('Device ' .. device.name .. ' was changed ' .. device.state, domoticz.LOG_INFO)
local washmachinedoor = domoticz.devices('WashMachine-D3')
if (washmachinedoor.state == 'Alarm' and washmachinedoor.lastUpdate.minutesAgo >= 5) then
domoticz.log('washmachine door is unlocked')
msg="Wash Machine Door Unlocked"
domoticz.openURL('https://api.telegram.org/256900994&text=' .. msg)
end
end
}
When the script is running.
What is the lastupdate time when you look to your device?
I have a few devices where the lastupdate isn't updatet when the switch modifies it's state.
When that happens, this could be the reason why >=5 is true and it send the notification.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
paul402 wrote: Saturday 19 October 2019 18:23
Everything is working ok except my code. Instead of getting a delayed message that the door is "unlocked" I get the message immediately.
Adding extra log statements does give you more information on what is happening..