Comparison with custom sensor value is not working Topic is solved

Post Reply
Barberousse
Posts: 109
Joined: Wednesday 02 December 2015 22:47
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Comparison with custom sensor value is not working

Post by Barberousse » Saturday 16 December 2017 21:31

Hello,

I'm trying to create notification on high and low water pressure with blocky, but events are not fired.
PbDomoticzCustom2.png
PbDomoticzCustom2.png (4.51 KiB) Viewed 738 times
PbDomoticzCustom1.png
PbDomoticzCustom1.png (34.14 KiB) Viewed 738 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?

Spitfire
Posts: 26
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Comparison with custom sensor value is not working

Post by Spitfire » Sunday 17 December 2017 1: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.

Barberousse
Posts: 109
Joined: Wednesday 02 December 2015 22:47
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Comparison with custom sensor value is not working

Post by Barberousse » Sunday 17 December 2017 22:49

Spitfire wrote:
Sunday 17 December 2017 1: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
PbDomoticzCustom3.png (39.13 KiB) Viewed 713 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).

cogliostrio
Posts: 82
Joined: Sunday 06 September 2015 11:58
Target OS: Linux
Domoticz version:
Contact:

Re: Comparison with custom sensor value is not working

Post by cogliostrio » Sunday 17 December 2017 23: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?

Barberousse
Posts: 109
Joined: Wednesday 02 December 2015 22:47
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Comparison with custom sensor value is not working

Post by Barberousse » Monday 18 December 2017 0:06

cogliostrio wrote:
Sunday 17 December 2017 23: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

Spitfire
Posts: 26
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Comparison with custom sensor value is not working

Post by Spitfire » Monday 18 December 2017 21: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.

Barberousse
Posts: 109
Joined: Wednesday 02 December 2015 22:47
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Comparison with custom sensor value is not working

Post by Barberousse » Tuesday 19 December 2017 0:27

Spitfire wrote:
Monday 18 December 2017 21: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
PbDomoticzCustom4.png (16.45 KiB) Viewed 674 times
PbDomoticzCustom5.png
PbDomoticzCustom5.png (18.16 KiB) Viewed 674 times

Barberousse
Posts: 109
Joined: Wednesday 02 December 2015 22:47
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Comparison with custom sensor value is not working

Post by Barberousse » Tuesday 19 December 2017 1:03

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

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests