Request: update variable B after variable has specific state for x time
Posted: Sunday 16 May 2021 13:47
Hi,
I have searched the forums, but I cannot find a topic for this and after trying out various options myself I have to admit that I am lacking the knowledge for this and ask my fellow domoticz users for help.
First i'd like to explain the use for this request. I have used a LUA arp scan script to detect my phone and when it does a variable A is set to 1 (instead of 0). Based on this variable I use some blockly scripts to automate stuff.
Unfortunately the arp scan does not always find my phone, probably due to energy saving, and during the day the variable A changes multiple times between 1 and 0. Making the blockly scripts not very reliable.
So what I thought of was creating a second variable B that only sets 0 after the "last updated" time of the variable A that detects my phone set 0 exceeds 600 seconds.
So this happens;
-phone detected triggeres variable A to 1 at 8:00 when I switch on my phone
-phone connection lost triggers variable A to 0 at 8:30 when I leave for work
-when the last state of variable A = 0 > 600 seconds, in this case 8:40, it triggeres variable B to set 0
If am still at home the above mentioned trigger of variable B will nog happen because the phone will be redetected by the lua script and the variable A will be set again at 1.
I guess the bold printed script request will help me out.
Cheers,
Kim
I have searched the forums, but I cannot find a topic for this and after trying out various options myself I have to admit that I am lacking the knowledge for this and ask my fellow domoticz users for help.
First i'd like to explain the use for this request. I have used a LUA arp scan script to detect my phone and when it does a variable A is set to 1 (instead of 0). Based on this variable I use some blockly scripts to automate stuff.
Unfortunately the arp scan does not always find my phone, probably due to energy saving, and during the day the variable A changes multiple times between 1 and 0. Making the blockly scripts not very reliable.
So what I thought of was creating a second variable B that only sets 0 after the "last updated" time of the variable A that detects my phone set 0 exceeds 600 seconds.
So this happens;
-phone detected triggeres variable A to 1 at 8:00 when I switch on my phone
-phone connection lost triggers variable A to 0 at 8:30 when I leave for work
-when the last state of variable A = 0 > 600 seconds, in this case 8:40, it triggeres variable B to set 0
If am still at home the above mentioned trigger of variable B will nog happen because the phone will be redetected by the lua script and the variable A will be set again at 1.
I guess the bold printed script request will help me out.
Cheers,
Kim