Depending on how your source smart home platform implements buttons, you would likely want to use the event that triggered the rule as your condition rather than trying to query for the state of the button.
In other words, as soon as you push the button it emits a ‘pushed’ event, but when you query the status of the button just a moment later it’s either not actively in a pushed state or always retains the pushed state. In either case, the event is a better data source for building your rule as it tells you exactly which device and value triggered the rule.
Context Variables
You can use Context Variables to access information about the event that triggered the rule and use that in your conditions:
Triggering Device Name
If you want to combine multiple devices in a single rule and differentiate between which device triggered the rule, you would want to use:
- Event → Device → Name
$context.event.deviceName
Triggering Device Value
If you have a single button in a rule and perhaps wanted to distinguish between a ‘pushed’ and ‘held’ event, assuming your device supports that, you would use:
- Event → Device → Value
$context.event.value
Value and Device Name
If you had a rule where you wanted to determine which button was activated and whether it was pressed or held, you could use both context variables in an if condition with AND.
$context.event.deviceName
is ‘button 1’
and$context.event.value
is ‘pushed’`
Example: Which button was pushed?
Here’s an example showing how to distinguish if it was button 1 or button 2 pushed:
Edit: If you find it more intuitive, you could use a separate condition for each event that you are looking for. This approach would be required if you had more than 2 devices / trigger values in the Trigger as you wouldn’t be able to implicitly determine that the ‘else’ condition meant it was the other button.