Thanks - should it be:
(
$entities('binary_sensor.mac_active').attributes.["Screen Off"] = true
)
I am still not getting a green off so its not meeting the critieria on the state node when the screen is off. It still shows a red off.
Thanks - should it be:
(
$entities('binary_sensor.mac_active').attributes.["Screen Off"] = true
)
I am still not getting a green off so its not meeting the critieria on the state node when the screen is off. It still shows a red off.
No period after attributes.
$entities('binary_sensor.mac_active').attributes["Screen Off"] = true
Ok still the same problem with the red off though
Not sure how you test it, but triggers usually first activate, when the state change from something else to the state tested.
You do not get a trigger if it is already at the state. (Output on connect might change that though, but I do not know, because I never used that setting)
I have been testing it that way by toggling my screen on and off on my Mac to perform the trigger. I was expecting it to go green when Screen Off is true. Puzzled why that isnāt working.
Perhaps I should post in Home Assistant Companion for Apple as that is the source of the sensor to see if anyone has got this working.
If the HA developer tools show the state/attributes of the sensor, then the companion app is not the fault.
And the Node Red outputting the values too is just as good as the HA developer tools.
Thank you - so where do think the problem lies?
Not sure, but I think I at one point had an issue with detecting on an attribute with the for field being used.
It would not trigger, because the state of the sensor did not change, even though some of the attributes did.
If it that then making a template sensor in HA on the Screen Off value could be a solution.
Is there a good how-to on how to do that? I found this: https://www.youtube.com/watch?v=lQqfxunEbow, which I can start with.
I am just trying to understand how I translate/convert an attribute change into a state change.
In JSONata, field names (object keys) with spaces and reserved characters require back-ticks to reference correctly.
$entities('binary_sensor.mac_active').attributes.`Screen Off`
I canāt test this out at the moment, but it should return the value of the attribute you want. Since this value is a Boolean, there should be no need for the conditional test.
Note that these are back-ticks. Single and double quotes will not work.
Thatās it Biscuit (Geoff) - itās green now. Woohoo!