I use an OnlineChecker script to see if my partners or my phone is at home. The script triggers a virtual switch (on is ‘at home’, off is ‘away’). I would like to have a light switch on if one of us comes at home during the night:
e.g. IF Time > 0:30h and time < 4:00h AND switch person1 OR person2 turns on THEN turn on light.
Problem is that i cannot find a way to Blocky use the ‘changes state’ as a trigger. Now the problem is the script keeps turning the light on because one of our phones are at home. When I use only ‘device’ as a trigger, turning off at our wish the ligt re-triggers the script and therefore keeping the ligt in a ‘on’ loop.
I also thought about setting a user variable if the device is switched off, to prevent a ‘on-loop’ but I cannot work that out either.
Does someone have a solution? i can imagine is is a quite common application..
action when person arrives Topic is solved
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: action when person arrives
I would not know how to solve it using Blockly. A dzVents solution could look like below scriptloeknl wrote: ↑Saturday 04 July 2020 16:25 Problem is that i cannot find a way to Blocky use the ‘changes state’ as a trigger. Now the problem is the script keeps turning the light on because one of our phones are at home. When I use only ‘device’ as a trigger, turning off at our wish the ligt re-triggers the script and therefore keeping the ligt in a ‘on’ loop.
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
return
{
on =
{
devices =
{
[ 'phone1' ] = { 'between 00:45 and sunrise' }, -- change names of phone1, phone2
[ 'phone2' ] = { 'between 00:45 and sunrise' },
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is tested and OK
},
},
execute = function(dz, item)
local light = dz.devices('phoneLight') -- change to name of light
if item.active and light.state == 'Off' then
light.cancelQueuedCommands()
light.switchOn()
light.switchOff().afterMin(30) -- automatic switchOff after 30 minutes
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 6
- Joined: Saturday 04 July 2020 16:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Netherlands
- Contact:
Re: action when person arrives
Thanks! Works perfect
Who is online
Users browsing this forum: No registered users and 1 guest