I have created below Blockly to send me an alert if I left on the lights in my bathroom for a set period. To do so set I a variable after the lights have been on for that period. And when this variable is set it should alert me. After the alert I reset the variable to set it again after 10 minutes to keep alerting me (until I turn the lights off).
I set the trigger for this blockly script to 'All' and the user variable is defined as an integer.
Now this user variable does seem to change correctly when the lights are put off or left on for the given period, but the alerting part is never executed and I do not quite understand why.
To make it more complicated, after a lot of fiddling around with the script and/or changing the user-variable manually (I have not figured out exactly what actions caused it) I got it working occasionally for 1 time only, it alerts me one time but after that it does not work at all anymore.
I tried putting all the if-statements in separate blockly scripts (an changing trigger types) but it made no difference. Also changing the user variable to an string or other type did not make a difference (I also did not expect it to, but wanted to rule it out).
What am I missing here? (Note that I am still testing this so all the time values and multiple alerts might not make a lot of sense right now. Also the check on the value of the user variable in the first statement is not really necessary but as that part is working correctly I just left it like that ).
Blockly not triggered by user variable change
Moderator: leecollings
-
- Posts: 11
- Joined: Wednesday 23 August 2017 10:39
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Blockly not triggered by user variable change
- Attachments
-
- blockly.jpg (122.31 KiB) Viewed 1556 times
-
- Posts: 628
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Blockly not triggered by user variable change
The way I read this blockly and what could happen (knowing also that else-if's in blokcly are not really normal else-if but more like then-if, executed sequentially).
1) The script is triggered by changes of "bathroom".
2) the first time you switch batchroom on, it write a log and schedules the bathroomonlongtime to 1 after 5 minutes. The other two else-if's will not be executed since the conditions are not met.
3) If you switch of bathroom within 5 minutes the bathroomonlongtime will be set to 0 in the third else-if. But does this also cancel the scheduled the update after 5 minutes as initiated at step 2? My guess is it will go to 1 anyway after 5 minutes (and this is not what you want)
4) If you switch of batchroom after 5 minutes then the bathroomonlongtime will already be 1 as result of step 2 and then this script is triggered and the three conditions will be checked. The second part (the first else-if) will be executed and an email will be sent etc. the bathroomonlongtime will go to 0 and 10 minutes later back to 1 (why?). Also the last part will be executed and will set bathroomonlongtime to 0 which it already was. So after 10 minutes the batchroomonlongtime will be 1 again even though you switched of the lights. This is also not what you want.
5) if then within 10 minutes you switch light on again then condition 1 will be met and the update after 5 minutes will be scheduled again. But if you switch on after the 10 minutes, the first part will not be met, only the second part so you should get a mail again, which again is not want you want.
one big advice, stop using blockly. It is very confusing, especially with the strange "else-if". Invest some time in learning dzVents. Much easier to understand, more more logical and much more powerful.
1) The script is triggered by changes of "bathroom".
2) the first time you switch batchroom on, it write a log and schedules the bathroomonlongtime to 1 after 5 minutes. The other two else-if's will not be executed since the conditions are not met.
3) If you switch of bathroom within 5 minutes the bathroomonlongtime will be set to 0 in the third else-if. But does this also cancel the scheduled the update after 5 minutes as initiated at step 2? My guess is it will go to 1 anyway after 5 minutes (and this is not what you want)
4) If you switch of batchroom after 5 minutes then the bathroomonlongtime will already be 1 as result of step 2 and then this script is triggered and the three conditions will be checked. The second part (the first else-if) will be executed and an email will be sent etc. the bathroomonlongtime will go to 0 and 10 minutes later back to 1 (why?). Also the last part will be executed and will set bathroomonlongtime to 0 which it already was. So after 10 minutes the batchroomonlongtime will be 1 again even though you switched of the lights. This is also not what you want.
5) if then within 10 minutes you switch light on again then condition 1 will be met and the update after 5 minutes will be scheduled again. But if you switch on after the 10 minutes, the first part will not be met, only the second part so you should get a mail again, which again is not want you want.
one big advice, stop using blockly. It is very confusing, especially with the strange "else-if". Invest some time in learning dzVents. Much easier to understand, more more logical and much more powerful.
-
- Posts: 11
- Joined: Wednesday 23 August 2017 10:39
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Blockly not triggered by user variable change
Actually I created some DzVentz for my Domoticz too, but never used any of the timer functions. And it seemed pretty straight forward doing this with blockly but apparently it is not, so I will just focus on doing this DzVentz
Who is online
Users browsing this forum: No registered users and 0 guests