I am trying to send a notification to my Sony TV ONLY when it is on. The automation was set up using the HA UI. When run it ALWAYS sends the notification even if the TV is off. I had assumed that by testing for the TV being on it would not send the notification if the test returned ‘false’.
What happens is if the TV is off the notification is sent and the TV turns on. Not exactly what I wanted at 4am!
What state does the TV’s integration report when off to HASS? Unless the state is accurately reflected in HASS, using it in conditions obviously won’t work.
Check what the TV reports in the Developer Tools > States panel:
Don’t use device conditions/triggers/actions, they produce code which is pretty much unreadable. Replace the device condition with a state condition.
When I test the TV state the test reports false if the TV is off and TRUE when the TV is on.
If I step through the test is not performed whether TV. Is on or off.
Not at my PC now but will post screen shots if useful.
Thanks for the quick reply.
OK so tested status of TV through Developer Tools>States panel. When TV is on status shows on, when off status shows off.
Also get
On test part of script.
Test condition gives accurate results - fails when off and true when on
“Don’t use device conditions/triggers/actions, they produce code which is pretty much unreadable. Replace the device condition with a state condition.”
Are you saying code the test for on/off in YAML and not to use the UI?
Shouild I learn how to use NodeRed for this type of automation?
Hold on - when run how exactly? From the automation itself (the Run button next to the action), or by actually triggering motion on your binary sensor?
If you pressed the Run button on the action, that’s exactly what it does - it runs the action only, and ignores all triggers and conditions.
If you want to test your entire automation, you need to change the state of your motion sensor (either physically, or by setting the state temporarily in developer tools > states).
No, read this. You can still use the UI - just don’t select the “Device” option.