Event that acts depending on last status
Moderator: leecollings
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Event that acts depending on last status
Hi!
Im currently running an event that checks the wattage of a wall plug and uses the value to determine if the house is armed or disarmed. I know its an pretty ugly solution but its the easiest way since I cannot get status directly from my security provider =)
Anyway, the event works just fine, the problem is that it runs EVERY hour. Which means I get the same notifications over, and over, and over both when I'm away and at home. Im not sure why but I guess that Domoticz is somehow configured to check all events every hour??
My thought was that I could check the last status of the alarm and that way tell it NOT to send a notification if the status is unchanged. Problem is that Blockly doesnt seem to support that kind of logic. So, does anyone have any suggestions? Im sure I could do this pretty easily with a python script or LUA, but with two small children I haven't had the time to learn any advanced scripting yet.
Any help and suggestions is greatly appriciated!
Best regards,
royson
Im currently running an event that checks the wattage of a wall plug and uses the value to determine if the house is armed or disarmed. I know its an pretty ugly solution but its the easiest way since I cannot get status directly from my security provider =)
Anyway, the event works just fine, the problem is that it runs EVERY hour. Which means I get the same notifications over, and over, and over both when I'm away and at home. Im not sure why but I guess that Domoticz is somehow configured to check all events every hour??
My thought was that I could check the last status of the alarm and that way tell it NOT to send a notification if the status is unchanged. Problem is that Blockly doesnt seem to support that kind of logic. So, does anyone have any suggestions? Im sure I could do this pretty easily with a python script or LUA, but with two small children I haven't had the time to learn any advanced scripting yet.
Any help and suggestions is greatly appriciated!
Best regards,
royson
Re: Event that acts depending on last status
Take a look at dz_Ventz (https://www.domoticz.com/wiki/DzVents:_ ... _scripting). It has a steep learning curve, but once you master it you will see the advantage over plain LUA and Blockly and the integration with Domoticz. I have converted all my LUA scripts to dz_Ventz and must say it works great.
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
Thanks for the tip, I actually had some thoughts on dzVents and after having another look it seems like a nice way to start.SweetPants wrote: ↑Tuesday 23 October 2018 20:45 Take a look at dz_Ventz (https://www.domoticz.com/wiki/DzVents:_ ... _scripting). It has a steep learning curve, but once you master it you will see the advantage over plain LUA and Blockly and the integration with Domoticz. I have converted all my LUA scripts to dz_Ventz and must say it works great.
Im just having some problems getting my logic right as there doesnt seems to be any "last state" command to use.
I would like my event to check if the last state of the switch is the same or not. If it is, it shouldnt do anything. The event should only continue if the state is changed, that way I wouldnt get the notifications every hour.
Maybe I could use another dummy switch that keeps track of my Alarm switches state?
Re: Event that acts depending on last status
Take a look at the persistent data part. That can give you state info of a previous script run (https://www.domoticz.com/wiki/DzVents:_ ... stent_data)
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
Thanks. Im gonna give that a look.SweetPants wrote:Take a look at the persistent data part. That can give you state info of a previous script run (https://www.domoticz.com/wiki/DzVents:_ ... stent_data)
Skickat från min CLT-L29 via Tapatalk
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
Ok, this is what i've got:
Last part is mostly frustration...
Code: Select all
return {
on = {
devices = {
'vSwitch_till_Larmet'
}
},
execute = function(domoticz, vSwitch_till_Larmet)
local Larmet = domoticz.devices('vSwitch_till_Larmet')
local HomeAway = domoticz.devices('vLARM_HomeAway')
if (Larmet.state == 'On') then
HomeAway.switchOff()
domoticz.notify('Avlarmat', 'Välkommen hem!', domoticz.PRIORITY_NORMAL)
elseif (Larmet.state == 'Off') then
HomeAway.switchOn()
domoticz.notify('Larmet aktiverat', 'Huset är nu larmat', domoticz.PRIORITY_NORMAL)
else
domoticz.notify('Stop', 'Sending me the same shit every hour!!', domoticz.PRIORITY_NORMAL)
end
end
}
Re: Event that acts depending on last status
Do you have re-notification set? Setup->Settings->Notification->Notification Intervals (sensor) i guess 1 hour?
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
I have set that to 12 hours..SweetPants wrote: ↑Friday 26 October 2018 18:50 Do you have re-notification set? Setup->Settings->Notification->Notification Intervals (sensor) i guess 1 hour?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Event that acts depending on last status
A possible solution using dzVents persistent data (as suggested by Sweetpants)
Code: Select all
return {
on = { devices = { "vSwitch_till_Larmet" }},
data = { lastState = { initial = "init" }},
execute = function(domoticz, item) -- item is vSwitch_till_Larmet (the script trigger)
local HomeAway = domoticz.devices('vLARM_HomeAway')
if item.state ~= domoticz.data.lastState then -- lastState different than current state ?
domoticz.data.lastState = item.state -- Store current state in domoticzVents persistent data
if item.state == 'On' then
HomeAway.switchOff()
domoticz.notify('Avlarmat', 'Välkommen hem!', domoticz.PRIORITY_NORMAL)
else
HomeAway.switchOn()
domoticz.notify('Larmet aktiverat', 'Huset är nu larmat', domoticz.PRIORITY_NORMAL)
end
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
Re: Event that acts depending on last status
Hmm weird, where is the 1 hour (re)notification coming from then!!!royson wrote: ↑Saturday 27 October 2018 7:57I have set that to 12 hours..SweetPants wrote: ↑Friday 26 October 2018 18:50 Do you have re-notification set? Setup->Settings->Notification->Notification Intervals (sensor) i guess 1 hour?
Waaren already send you a script that uses 'persistent data', maybe you can build from there
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
Not sure. Maybe Domoticz haven't registered my change to 12h or something.SweetPants wrote:Hmm weird, where is the 1 hour (re)notification coming from then!!!royson wrote: ↑Saturday 27 October 2018 7:57I have set that to 12 hours..SweetPants wrote: ↑Friday 26 October 2018 18:50 Do you have re-notification set? Setup->Settings->Notification->Notification Intervals (sensor) i guess 1 hour?
Waaren already send you a script that uses 'persistent data', maybe you can build from there
Yep. Gonna give waaren suggestion a go.
Skickat från min CLT-L29 via Tapatalk
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
Thank you. I'm gonna give that a try and read the guide again. With your help I might actually understand how it workswaaren wrote:A possible solution using dzVents persistent data (as suggested by Sweetpants)
Code: Select all
return { on = { devices = { "vSwitch_till_Larmet" }}, data = { lastState = { initial = "init" }}, execute = function(domoticz, item) -- item is vSwitch_till_Larmet (the script trigger) local HomeAway = domoticz.devices('vLARM_HomeAway') if item.state ~= domoticz.data.lastState then -- lastState different than current state ? domoticz.data.lastState = item.state -- Store current state in domoticzVents persistent data if item.state == 'On' then HomeAway.switchOff() domoticz.notify('Avlarmat', 'Välkommen hem!', domoticz.PRIORITY_NORMAL) else HomeAway.switchOn() domoticz.notify('Larmet aktiverat', 'Huset är nu larmat', domoticz.PRIORITY_NORMAL) end end end }
Skickat från min CLT-L29 via Tapatalk
-
- Posts: 13
- Joined: Friday 10 November 2017 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Event that acts depending on last status
Thanks a lot for your help @Sweetpants and @waaren. Its seems to be working great!waaren wrote: ↑Saturday 27 October 2018 8:35A possible solution using dzVents persistent data (as suggested by Sweetpants)
Code: Select all
...
Who is online
Users browsing this forum: No registered users and 1 guest