{"id":792,"date":"2019-08-27T10:17:20","date_gmt":"2019-08-26T23:47:20","guid":{"rendered":"http:\/\/parablog-wordpress.dockerbox.rei.moe\/?p=792"},"modified":"2019-08-27T10:17:20","modified_gmt":"2019-08-26T23:47:20","slug":"a-smarter-smart-tv","status":"publish","type":"post","link":"https:\/\/blog.lewys.eu\/?p=792","title":{"rendered":"A Smarter Smart TV"},"content":{"rendered":"\n<p>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 &#8216;smart tv&#8217;<\/p>\n\n\n\n<p>However Is it really smart if you still have to turn it on? and change channel? <br>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.<br><br>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!<\/p>\n\n\n\n<p>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!<\/p>\n\n\n\n<p>There is probably a more streamlined way to do this but this is what I have come up with:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"259\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-3-1024x259.png\" alt=\"\" class=\"wp-image-793\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-3-1024x259.png 1024w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-3-300x76.png 300w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-3-768x195.png 768w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-3.png 1543w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>It works like so;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>First we have this state changed node that outputs true, if the device is not playing.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"590\" height=\"410\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-4.png\" alt=\"\" class=\"wp-image-794\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-4.png 590w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-4-300x208.png 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/figure>\n\n\n\n<p>If it IS playing, it outputs a false, which triggers the &#8216;Turn on TV&#8217; call service node.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"399\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-5.png\" alt=\"\" class=\"wp-image-795\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-5.png 606w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-5-300x198.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/figure>\n\n\n\n<p>followed by a wait until node, just to add a 1 second delay to allow the TV to startup.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"582\" height=\"515\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-6.png\" alt=\"\" class=\"wp-image-796\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-6.png 582w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-6-300x265.png 300w\" sizes=\"auto, (max-width: 582px) 100vw, 582px\" \/><\/figure>\n\n\n\n<p>and finally another call service node to actually change the input!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"708\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-7.png\" alt=\"\" class=\"wp-image-797\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-7.png 602w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-7-255x300.png 255w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p>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)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"555\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-8.png\" alt=\"\" class=\"wp-image-798\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-8.png 602w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-8-300x277.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p>finally followed by the turn off switch for the TV.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"611\" height=\"772\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2019\/08\/image-9.png\" alt=\"\" class=\"wp-image-799\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-9.png 611w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2019\/08\/image-9-237x300.png 237w\" sizes=\"auto, (max-width: 611px) 100vw, 611px\" \/><\/figure>\n\n\n\n<p>I also need to get around to renaming the entities of the switches used here, as they&#8217;re not very well named at present.<\/p>\n\n\n\n<p>Ill include the flow below!<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">[{\"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}]<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;smart tv&#8217; 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 &hellip; <a href=\"https:\/\/blog.lewys.eu\/?p=792\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">A Smarter Smart TV<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,19,45],"tags":[],"class_list":["post-792","post","type-post","status-publish","format-standard","hentry","category-home-assistant","category-home-automation-2","category-node-red"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts\/792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=792"}],"version-history":[{"count":2,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts\/792\/revisions"}],"predecessor-version":[{"id":801,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts\/792\/revisions\/801"}],"wp:attachment":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}