My TV at home features both Google TV through a Xiaomi Mi Box, and Kodi running on an old Chromebox. This alone is what most would call, a ‘smart tv’
However Is it really smart if you still have to turn it on? and change channel?
In some occasions, HDMI CEC can help here, as it is capable of turning the TV on and changing to the input it needs ! However for my use case, this doesnt work. and it is rarely able to turn OFF the TV.
Luckily, in one of my recent posts I covered how I added RS232 control to the TV. so actually changing inputs and power on and off are now discrete commands we have at our disposal!
Using some simple logic in Node-Red it was a simple case of checking which device changes to playing, and then switching the TV on, and changing over the input to match!
There is probably a more streamlined way to do this but this is what I have come up with:
It works like so;
First we have this state changed node that outputs true, if the device is not playing.
If it IS playing, it outputs a false, which triggers the ‘Turn on TV’ call service node.
followed by a wait until node, just to add a 1 second delay to allow the TV to startup.
and finally another call service node to actually change the input!
Meanwhile, if the TV state is anything OTHER than playing, it will first go to this wait until node, and wait 60 minutes in case it begins playing again (this gives time to choose the next video or show using a remote ! I will probably shorten this though)
finally followed by the turn off switch for the TV.
I also need to get around to renaming the entities of the switches used here, as they’re not very well named at present.
Ill include the flow below!
[{"id":"4e63a44b.f401bc","type":"server-state-changed","z":"e94d3e8b.2d81e","name":"When Kodi stops Playing","server":"33a2704d.0e654","version":1,"entityidfilter":"media_player.kodi_libreelec_local","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"playing","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"x":290,"y":760,"wires":[["9a3def91.d13ae"],["432da1ba.4b195"]]},{"id":"432da1ba.4b195","type":"api-call-service","z":"e94d3e8b.2d81e","name":"Turn on TV","server":"33a2704d.0e654","version":"1","service_domain":"homeassistant","service":"turn_on","entityId":"switch.sharp_tv_rs232","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":850,"y":700,"wires":[["9be17d6c.92cdf"]]},{"id":"11a5db01.9c8e75","type":"api-call-service","z":"e94d3e8b.2d81e","name":"Turn off TV","server":"33a2704d.0e654","version":1,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.turn_off","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":850,"y":780,"wires":[[]]},{"id":"9a3def91.d13ae","type":"ha-wait-until","z":"e94d3e8b.2d81e","name":"","server":"33a2704d.0e654","outputs":2,"entityId":"media_player.kodi_libreelec_local","property":"state","comparator":"is","value":"playing","valueType":"str","timeout":"60","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":620,"y":760,"wires":[["432da1ba.4b195"],["11a5db01.9c8e75"]]},{"id":"9f2ad7cf.baa538","type":"api-call-service","z":"e94d3e8b.2d81e","name":"Change Input","server":"33a2704d.0e654","version":1,"service_domain":"switch","service":"turn_on","entityId":"switch.displayport","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":680,"wires":[[]]},{"id":"9be17d6c.92cdf","type":"ha-wait-until","z":"e94d3e8b.2d81e","name":"","server":"33a2704d.0e654","outputs":2,"entityId":"switch.displayport_2","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"1","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1000,"y":680,"wires":[["9f2ad7cf.baa538"],["9f2ad7cf.baa538"]]},{"id":"33a2704d.0e654","type":"server","z":"","name":"Home Assistant [Lewys]","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]