Mysterious if condition treatment - pushover

(Michael Mesch) #1

Hi!
I have a rule which sends a pushover message in case the garage-door is open. For whatever reason, the message is always sent, irrespective if the door is open or not. To the contrary, a log file entry is only generated in case the if-condition is correcly fulfilled. It seems like the pushover action is somehow ignoring the if-condition.

Here is the rule:

rule "Garagentor offen 22:11"

when 
		Time cron "0 11 22 1/1 * ? *"   
then
		if ((Garage_aufzu.state.toString) == "0")
		{
			logInfo("Garage_aufzu", Garage_aufzu.state.toString)
			sendPushoverMessage(pushoverBuilder("Garage offen").withDevice("Mobile"))
		}
end


rule "Garagentor offen 0:21"

when 
		Time cron "0 21 0 1/1 * ? *"
then
		if ((Garage_aufzu.state.toString) == "1") 
		{
			logInfo("Garage_aufzu", Garage_aufzu.state.toString)			
			sendPushoverMessage(pushoverBuilder("Garage offen").withDevice("Mobile"))
		}
end

Even though the garage door was closed (I’m very sure about that…) (closed = 0), I received notifications on 22:11 and 0:21 claiming that the garagedoor is open. The logfile shows one the following entry:

2019-02-11 22:11:00.030 [INFO ] [.smarthome.model.script.Garage_aufzu] - 0

No log is existing for the event at 0:21 even though I received a pushover message (which should not have been the case since the garage was closed, i.e. “0”). Can anyone explain that? I have no idea…

Thanks!
Meschmesch

0 Likes

(Vincent Regaud) #2

Can you post the item Garage_aufzu please?

0 Likes

(Michael Mesch) #3

Hi, here is the item:

Number Garage_aufzu "Garagentor auf/zu [MAP(bypass_de.map):%s]" <garagedoor> {channel="zwave:device:xxxxx:node6:sensor_door"}

and the associated map:
1=Auf
0=Zu
undefined=undefiniert
-=undefiniert

0 Likes

(Vincent Regaud) #4
rule "Garagentor offen 22:11"
when 
    Time cron "0 11 22 1/1 * ? *"
then
    if (Garage_aufzu.state == 0) {
        logInfo("Garage_aufzu", Garage_aufzu.state.toString)
        sendPushoverMessage(pushoverBuilder("Garage offen").withDevice("Mobile"))
    }
end

rule "Garagentor offen 0:21"
when 
    Time cron "0 21 0 1/1 * ? *"
then
    if (Garage_aufzu.state == 1)  {
        logInfo("Garage_aufzu", Garage_aufzu.state.toString)			
        sendPushoverMessage(pushoverBuilder("Garage offen").withDevice("Mobile"))
    }
end
0 Likes

(Rossko57) #5

Note that the messages are the same, even though the condition you test for is different. Make the messages different so that you can tell where they come from, for diagnosis!

I’m a bit confused by the whole logic; send a message “open” at 22:11 if the garage is closed, send a message “open” at 00:21 if garage is open.

This feels like a big clue, the message originates somewhere else.
Doubt you’ve been experimenting with GUI rules? (don’t think they do crons yet)
But if you’ve changed the rule “names” while editing text rules, there may a cached old ghost version. When finished editing this time, try system reboot.

0 Likes

(Mikael Gustafsson) #6

You have surely noticed that one rule checks for state = 0 and the other one for state = 1?
To me that seems like you get a pushover at 22:11 it the door is closed and 0:21 if it’s open.

0 Likes

(Michael Mesch) #7

Is the “OR” in line 3 really necessary? It don’t understand the purpose of that…

@ rossko57: I never used GUI rules, nevertheless I do the reboot.
@ mikaelgu: Yeah, it’s nonsense here. Actually I don’t want the get informed that the garage door is closed, because that’s what is supposed to be. Just for testing purposes I queried for the state = 0. But I will change it and report tomorrow…

0 Likes

(Vincent Regaud) #8

Sorry typo
I changed it

0 Likes