switch off after

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

Moderator: leecollings

Post Reply
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

switch off after

Post by pvklink »

Hi, i have an on/off switch that is set by measuring the usage of a washingmachine.
When it is finished my on/off switch is triggered to on and a wav file is played..
So far so good...
I also made a script for the on/of switch so that is will be turned off after 10 seconds...
This doed not work, and i dont know why... seems so easy...

-- switch
return {
on = {devices = {'voice_vorstalarm'}},

logging = { level = domoticz.LOG_DEBUG ,
marker = "Security"},

execute = function(dz, device, info)

if device.state == 'On' then
device.switchOff().afterSec(10)
end
end
}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switch off after

Post by waaren »

pvklink wrote: Wednesday 13 February 2019 12:05 I also made a script for the on/of switch so that is will be turned off after 10 seconds...
This doed not work, and i dont know why... seems so easy...
What this script does is switch Off the voice_vorstalarm 10 seconds after it has been switched On. Is that what you intend ?
If so please add a log statements to see what happens.

Code: Select all

-- switch 
return {
on = {devices = {'voice_vorstalarm'}}, 

logging = { level = domoticz.LOG_DEBUG , 
marker = "Security"},

execute = function(dz, device, info)

dz.log("device " .. device.name .. " switched to " .. device.state,dz.LOG_DEBUG)
if device.state == 'On' then 
device.switchOff().afterSec(10)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: switch off after

Post by pvklink »

Yes, when it becomes colder then x-degrees i get a voice message but the switch stays on..
So i want it off again after a period of time....
added the log now wait for a temperature change
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: switch off after

Post by pvklink »

mmm.. strange it works now
problem was the refresh timer of my dashticz
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: switch off after

Post by pvklink »

does work when i manually set the switch on but when my temperature script triggers this switch i get this

2019-02-13 13:30:17.172 Status: dzVents: Debug: Security: Constructed timed-command: Off
2019-02-13 13:30:17.172 Status: dzVents: Debug: Security: Constructed timed-command: Off AFTER 10 SECONDS
2019-02-13 13:30:17.172 Status: dzVents: Debug: Security: device voice_vorstalarm switched to On
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switch off after

Post by waaren »

pvklink wrote: Wednesday 13 February 2019 13:47 does work when i manually set the switch on but when my temperature script triggers this switch i get this

2019-02-13 13:30:17.172 Status: dzVents: Debug: Security: Constructed timed-command: Off
2019-02-13 13:30:17.172 Status: dzVents: Debug: Security: Constructed timed-command: Off AFTER 10 SECONDS
2019-02-13 13:30:17.172 Status: dzVents: Debug: Security: device voice_vorstalarm switched to On
Seems the standard messages to me. Maybe confusing but that is what you normally see when debug mode is on and you use the afterXXX() method .
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: switch off after

Post by pvklink »

mm.. it says device voice_vorstalarm switched to On ! instead of off
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: switch off after

Post by waaren »

pvklink wrote: Wednesday 13 February 2019 14:42 mm.. it says device voice_vorstalarm switched to On ! instead of off
Yes. That comes from this line

Code: Select all

dz.log("device " .. device.name .. " switched to " .. device.state,dz.LOG_DEBUG)
The other lines are from internal dzVents / domoticz when line

Code: Select all

device.switchOff().afterSec(10)
is interpreted. Confusing part is probably the sequence.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest