doing something when status changes from off to on
Moderator: leecollings
-
- Posts: 234
- Joined: Thursday 09 July 2015 12:03
- Target OS: Linux
- Domoticz version: 2.4538
- Location: Norway
- Contact:
doing something when status changes from off to on
In blockly it is easy to do somthing when a switch is on, or off, but what if I want somthing to happen if the switch is changed from eg off to on.
why? because if i eg want to receiv a E-Mail when a switch is turned on i will be spammed with emails if i use "if on"
why? because if i eg want to receiv a E-Mail when a switch is turned on i will be spammed with emails if i use "if on"
-
- Posts: 110
- Joined: Friday 20 September 2013 18:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Finland
- Contact:
Re: doing something when status changes from off to on
Have you tested how it really works?
-
- Posts: 673
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: doing something when status changes from off to on
You can check the lastupdated time, you can create an additional virtual switch to check the status change.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: doing something when status changes from off to on
In my scripting I 'memorize' when the last message is sent. I then only sent a new one if a certain time has passed. Like when someone presses the doorbell 3 times I only get 1 notification.
I would also suggest looking for another notification system than email. I believe Telegram or Pushover is way more suitable for this.
I would also suggest looking for another notification system than email. I believe Telegram or Pushover is way more suitable for this.
-
- Posts: 234
- Joined: Thursday 09 July 2015 12:03
- Target OS: Linux
- Domoticz version: 2.4538
- Location: Norway
- Contact:
Re: doing something when status changes from off to on
yepp, tested with smoke-detektor and "email if PANIC".alfred_j_kwak wrote:Have you tested how it really works?
how can i do this in blockly?jannl wrote:You can check the lastupdated time, you can create an additional virtual switch to check the status change.
how do you memorize this using blockly?Egregius wrote:In my scripting I 'memorize' when the last message is sent. I then only sent a new one if a certain time has passed. Like when someone presses the doorbell 3 times I only get 1 notification.
I would also suggest looking for another notification system than email. I believe Telegram or Pushover is way more suitable for this.
this is a good solution in your example with doorbell, but not if i want a notification when a light is tuned on (and it stays on for many hours, for example)
But yes, I will try Telegram or Pushover

- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: doing something when status changes from off to on
I wrote 'In my scripting' 
I don't use blockly, only php.
In php could be as simple as:
if($switch=='On'&&$switchtime>time()-60) telegram('switch X On');

I don't use blockly, only php.
In php could be as simple as:
if($switch=='On'&&$switchtime>time()-60) telegram('switch X On');
-
- Posts: 673
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: doing something when status changes from off to on
lastupdate is in the forum or in the wiki somehwere.
Create a virtual switch
set it to on when e-mail sent and check if it is on and do not sent in that case
set the virtual switch to off when the concerning switch is set to off
Create a virtual switch
set it to on when e-mail sent and check if it is on and do not sent in that case
set the virtual switch to off when the concerning switch is set to off
-
- Posts: 110
- Joined: Friday 20 September 2013 18:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Finland
- Contact:
Re: doing something when status changes from off to on
Ok. So I don't understand the question. I have belived that all the switch action is event based and event occures only when switch is status changes so notification is send according change not state.
My bad.
My bad.
-
- Posts: 673
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: doing something when status changes from off to on
I use lua, not blockly.
When an event is fired, all device lua scripts are run. It is up to the script to react or not.
When an event is fired, all device lua scripts are run. It is up to the script to react or not.
-
- Posts: 110
- Joined: Friday 20 September 2013 18:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Finland
- Contact:
Re: doing something when status changes from off to on
Yes. But if in the beginning of your Lua script you check 'if devicechanged...' and so on it does trigger only with edge not from state? I understand that OP get spam emails from solid state and that's what confuses.
-
- Posts: 673
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: doing something when status changes from off to on
Devicechanged is only for the device that triggered the event scripts
Who is online
Users browsing this forum: No registered users and 1 guest