Matched Condition Not Actioned

Hi

Any ideas why a condition would be incorrectly evaluated as false. The rule below runs but appears to be incorrectly actioned as false every time it runs. I've deleted and re-wrote it. It's in RM 5.1 and I'm on 2.3.0.113


Neither sub portion is true. There is no "on physical" in the first, nor "set to..." in the second.

I don't follow - the first part of the IF is true. The string "Dining Room Lights was turned on physical" contains "on physical" (I screenshot the rule before the light was switched on and so that shows off physical)

Sorry, I’ll look at it more. Away just now.

I don't know what is going on with this. When I create a similar rule, it works as expected:

1 Like

Ok - I'm flummoxed then. A couple of further queries if that's ok...

1 - Could the issue be that in my rule there is no delay between the variable string being written in the first action and the new string string being evaluated in the second action (so the action is possibly evaluating the previous string)?

2 - With regard to the Dimmer level changed trigger. I need to evaluate the string based on whether the dimmer is adjusted at all, no matter what percentage it changes to. For example if the string is written as "Dining Room Lights was set to 38% physical", is there a way I can define the expression to contain "set to" and "physical" while disregarding the percentage? Can I use - contains 'set to physical' or will that fail as there is "38%" in the middle.

I hope that makes some sort of sense! Thanks.

I don't think so because the log for the *contains* test shows the string you'd expect to test properly. But, can't be certain of the relative time, so if you inserted a very short delay, and then it worked, that would certainly be proof. I'd certainly want to know about that as the timing should not matter.

You do need a level, but > 0 would work.

There is another way you could do this automation. You can trigger from physical vs digital events. So you could have one rule that triggers from physical events, and one that triggers from digital events, and those set the variable you want to set, without using an intermediary test/set like you are now.

I don't understand why this is failing. I would also suggest that you play around with other *contains* tests, not to get your rule working so much as to assist in narrowing down where this is failing.

Thanks for the info. I tried a 2 second delay and watched the live logs but the result was the same. It'll probably be something that I've done incorrectly though I don't know what.

I was trying to keep the number of rules to a minimum. The rule is (or should be) a fairly straightforward motion lighting rule. The current rule is as follows:

I was trying to use the "Physical" variable two ways - as a required expression that prevented the rule from running unless it was false, and then I wanted to add something into the rule that if the dimmer was adjusted while the rule was already running, it would prevent the lights from turning off (switching the lights off physically when leaving the room would put the variable back to false again so that the rule would run next time motion was detected). Because the Physical Switch and Physical Dimmer are only available as triggers (not in defined expressions) I can't use them in a conditional IF THEN as they don't appear in the list. If they did I wouldn't need to use a variable at all.

In your 'Defined Required Expression' shouldn't there be parentheses?
Should it be
(Time is between x and y
OR
Curtain closed)
AND
Var=false

Just wondering if this is what you are trying to achieve.
I'm not saying that is your issue but it seems more logical to me.

Yes I thought that was probably wrong - I'll change that. Unfortunately I never got far enough for it to be needed. I've just been monitoring the logs and the two variables to see what's happening when I operate the switch at the switch or from the dashboard. As I can't get the rule to evaluate the string in the first variable correctly, the action is skipped to switch the second variable to True. I'll mess around a bit more and see if I can find anything to work.

What else are you doing with the 'state' variable, besides using it to convey the "physical" text?

Nothing at all - I'm just trying to set another variable "Dining Room Physical" to True or False according to the text in that "state" variable. RM won't allow me just to use "IF Physical Switch Dining Room Light is Changed" so it seems to be an overcomplicated way of doing it, but I really don't want to use multiple rules or create virtual switches for each room where I'm using motion lighting.

I found a case where I can get *contains* to fail:

It appears to be something related to space character. Try yours with just the word "physical" without the space.

This gives me something to go on...

1 Like

I can try that but I need contains 'on physical' so there will be a space regardless between the words. The reason I need 'on physical' is so that when it turns 'off physical' the Dining Room Physical Variable switches back to False

1 Like

This is correct.
I use 2 statements for my rules to get it to work.
IF var contains 'digital'
AND
IF var contains 'on'
THEN
Do your stuff.

Sorry @johnwill1 but I did point this out to you in your other thread. :wink:

Glad you have identified an issue though @bravenel

1 Like

Yeah, but I don't understand it.

I bet you understand it more than me. :grinning: :grinning:

LOL. I was hoping you knew what the heck is going on!

To be fair the rule is pretty complicated! I hope I never need to write one like that!

@bravenel when I first tried to do this I copied in the following for the var must contain.
Dining Room-Socket was turned on [digital]
When I then looked at the rule the [ and ] where removed from the must contain box.
So it just showed
Dining Room-Socket was turned on digital
I assumed this was because they were special characters and where stripped out by RM.
Could RM be stripping out the space for checking purposes?
Just wondering.