Page 1 of 1
Comparison with custom sensor value is not working
Posted: Saturday 16 December 2017 20:31
by Barberousse
Hello,
I'm trying to create notification on high and low water pressure with blocky, but events are not fired.

- PbDomoticzCustom2.png (4.51 KiB) Viewed 1465 times

- PbDomoticzCustom1.png (34.14 KiB) Viewed 1465 times
If I change condition (with time for instance), the event is fired, I'm able to read the value from log (for instance 1.939).
Another problem, the message I get in notification mail is "utilitydevice[249]" instead of 1.939.
Any idea?
Re: Comparison with custom sensor value is not working
Posted: Sunday 17 December 2017 0:59
by Spitfire
I’m not sure what you mean but that script will probably not work as you think since ”else if” statements are borked in Blocky. It’s like stacking if:s in a row and I doubt anything will be fixed regarding that any day soon since it been there since the introduction. So stay away from else ifs...or use ANY other supported language.
Re: Comparison with custom sensor value is not working
Posted: Sunday 17 December 2017 21:49
by Barberousse
Spitfire wrote: ↑Sunday 17 December 2017 0:59
I’m not sure what you mean but that script will probably not work as you think since ”else if” statements are borked in Blocky. It’s like stacking if:s in a row and I doubt anything will be fixed regarding that any day soon since it been there since the introduction. So stay away from else ifs...or use ANY other supported language.
I read the post on the "else if" problem, I don't think I'm concerned, I don't receive any notification in my example above, and my real script is this one:

- PbDomoticzCustom3.png (39.13 KiB) Viewed 1440 times
I want to have a notification when water pressure is too low or when water pressure is too high ("Pression de l'eau du chauffage" is "heater water pressure", from a custom sensor created with ebusd python plugin).
Re: Comparison with custom sensor value is not working
Posted: Sunday 17 December 2017 22:02
by cogliostrio
I use "else if's" successfully in several blocklys.
Your test script has an error, If its larger that 2.5, it is also larger than 1.5. Have you tried changing the script type?
Re: Comparison with custom sensor value is not working
Posted: Sunday 17 December 2017 23:06
by Barberousse
cogliostrio wrote: ↑Sunday 17 December 2017 22:02
I use "else if's" successfully in several blocklys.
Your test script has an error, If its larger that 2.5, it is also larger than 1.5. Have you tried changing the script type?
The script of the first post is wrong on purpose: I was trying to force comparison to be true (pressure is around 2) to check if I receive a notification, but nothing received... For the real script, see the 3rd post
Re: Comparison with custom sensor value is not working
Posted: Monday 18 December 2017 20:43
by Spitfire
Else if does not work as they should period.
However you can of course use them as stacks of if:s...if that is what you want.
In the first example above both the if and else if will be executed if the value is above 2,5 and I do not think you want that.
Re: Comparison with custom sensor value is not working
Posted: Monday 18 December 2017 23:27
by Barberousse
Spitfire wrote: ↑Monday 18 December 2017 20:43
Else if does not work as they should period.
However you can of course use them as stacks of if:s...if that is what you want.
In the first example above both the if and else if will be executed if the value is above 2,5 and I do not think you want that.
It doesn't work either with a single if statement, I have nothing in log:

- PbDomoticzCustom4.png (16.45 KiB) Viewed 1401 times

- PbDomoticzCustom5.png (18.16 KiB) Viewed 1401 times
Re: Comparison with custom sensor value is not working
Posted: Tuesday 19 December 2017 0:03
by Barberousse
Ok, now it works, it was a bug in my ebusd python plugin, the pressure was declared as text instead of bar custom sensor, i was never considered as a number