Washing Machine Door Signal

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
paul402
Posts: 105
Joined: Monday 23 May 2016 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Washing Machine Door Signal

Post by paul402 »

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...

Code: Select all

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
}
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Washing Machine Door Signal

Post by hoeby »

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)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Washing Machine Door Signal

Post by waaren »

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..

Would this help ?

Code: Select all

return {
    on = {
        devices = {
            'WashMachine-D3'
        }
    },
    
    execute = function(domoticz, device)
        domoticz.log('Device ' .. device.name .. ' was changed to ' .. device.state, domoticz.LOG_INFO)
        domoticz.log('Device ' .. device.name .. ' lastUpdate was '  .. device.lastUpdate.secondsAgo .. ' seconds ago.' , domoticz.LOG_INFO)
        
        if device.state == 'Alarm' then       
            domoticz.log('washmachine door is unlocked', domoticz.LOG_INFO)
            local msg = "Wash Machine Door Unlocked" 
            domoticz.openURL('https://api.telegram.org/256900994&text=' .. msg).afterMin(5)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
paul402
Posts: 105
Joined: Monday 23 May 2016 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Washing Machine Door Signal

Post by paul402 »

I finally got round to looking at this again. It works great and I've learnt something.
A big "Thank You" for your help!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest