Rule Machine newb here... I tried to search for what I am trying to do but I must be using the wrong keywords to search. This has to be covered in a thread somewhere on here...
I want to create a notification rule that triggers on my door lock changing state. But I want my notification to say "Kitchen Door Locked" when the state changes from Unlocked to Locked. Then I want a notification to say "Kitchen Door Unlocked" when the state changes from Locked to Locked.
In Rule Machine 4.0 I tried to create two rules with the lock state change as trigger and applied a condition to only do the action of the lock state is locked for one rule and unlocked for the other rule. When I test it, I get both "locked" and "unlocked" notifications no matter what direction the state is changing. I am missing something here. I am sure it is simple.
I just accomplished what I wanted to do using the "notifications" built-in app. But it would be good experience for me to see how this is done in rule manager and/or in logic statements.
If you're totally new to Rule Machine, the UI can be a bit awkward. To figure out how to get the IFs, I see you've already done so, but maybe watching the videos would help:
The docs are also good. I know they sound boring, but they're full of good examples. Here is my preferred location for those (though you can also find this in the docs site): [Released] Rule 4.0
Finally, to give you even more ideas, locks generally only report a "locked" or "unlocked" state (some can do "unknown" and "unlocked with timeout" is apparently also an option that I'm not sure I've ever seen). Rule Machine also includes a few built-in variables you can use. Combining these facts, the following rule should work about the same:
Triggers:
Kitchen Door Lock *changed*
Actions:
Notify Pixel 3 XL: '%device% is %value'
Here, this relies on the fact that %device% is a string variable with the display name of the last triggering device (always going to be your lock here, since that's all there is) and %value% is a variable containing the value of the attribute ("lock," in this case, with likely values "locked" or "unlocked"--see "Current States" on the device page for what yours does) of the device that matched your trigger.
That being said, I'd just use the Notifications app for this myself.
Got it working in Rule manager. Thanks for your help. My logic brain needed a kick start. There was a time when I could write many lines of logical code in programs like MatLab, Maple, Excel. But it has been decades since college...
I needed this jolt to my thought processes.This will be my segway into automating my ceiling fans based on temperature thresholds, HVAC on/off state, and pre-existing conditions like if the fans were already turned on manually.