{"id":629,"date":"2021-03-14T16:38:00","date_gmt":"2021-03-14T21:38:00","guid":{"rendered":"https:\/\/lab.rapternet.us\/?p=629"},"modified":"2021-10-24T21:10:11","modified_gmt":"2021-10-25T02:10:11","slug":"wled-automation-for-roku-in-home-assistant","status":"publish","type":"post","link":"https:\/\/lab.rapternet.us\/?p=629","title":{"rendered":"WLED Automation for Roku in Home Assistant"},"content":{"rendered":"\n<p>I was able to get WLED going on a light strip but I do have a lack of ideas on how to make use of it. I finally decided to go with the tried and true movie lighting. So my goal is to setup automations so that when my Roku begins playing something, the WLED strip dims and sets to a specific color (we&#8217;ll go with red), and when I pause or stop playing, it will turn to max brightness white light. This will give lower lighting while watching and brighter lights if something is paused (and I have to go get something). I&#8217;m still not entirely sure if I will end up making use of this in the end, but it will give me some ideas on what I can do and how to do it.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\" id=\"goals\">Goals:<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Adjust lighting when Roku plays some media<ul><li>If light is on, dim when playing<\/li><li>If light is on, brighten and go to white when paused or stopped<\/li><\/ul><\/li><li>Change to solid colors and a specific color<\/li><li>When the Roku goes to Idle, turn the light strip off<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"plan\">Plan<\/h2>\n\n\n\n<p>The Roku integration has a number of different statuses, however we&#8217;ll be focusing on 3 of them:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>idle<\/li><li>playing<\/li><li>paused<\/li><\/ul>\n\n\n\n<p>For our automations, we&#8217;ll be looking for changes in status in the following ways:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>any status to playing<\/li><li>any status to idle<\/li><li>playing to any status<\/li><\/ul>\n\n\n\n<p>The plan is to create an automation for each one of these status changes. And each of those automations will perform the actions we have listed in the goals. To do this, we&#8217;ll be making use of the Roku and WLED integrations as well as the WLED webui for creating presets.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setup\">Setup<\/h2>\n\n\n\n<p>Setting everything up starts on the WLED webui side of things. This is where presets can be added to the device and various settings can be changed on the fly. We will be adding two presets for our set of automations (bright white and dim red). I did this on a desktop, so with the webui all the way open, it was on the far right side. I first set the LED strip to the settings I wanted the preset to use, then I clicked to add a new preset. Doing this twice got me the two presets.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"301\" height=\"457\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/1e1435b8dbbc4f62a9a6b5c44a6a54d5.png\" alt=\"\" class=\"wp-image-631\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/1e1435b8dbbc4f62a9a6b5c44a6a54d5.png 301w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/1e1435b8dbbc4f62a9a6b5c44a6a54d5-198x300.png 198w\" sizes=\"auto, (max-width: 301px) 100vw, 301px\" \/><\/figure>\n\n\n\n<p>Do make sure to note the presets numbers since this will be used to call up the presets when used in the automations later on.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"324\" height=\"184\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/6914d79d0b3946d2976d7163175abff5.png\" alt=\"\" class=\"wp-image-632\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/6914d79d0b3946d2976d7163175abff5.png 324w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/6914d79d0b3946d2976d7163175abff5-300x170.png 300w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><\/figure>\n\n\n\n<p>Those presets can be called by the HASS automation to set things a bit more specifically than the HASS service will allow. The presets allow setting the solid color to use which I didn&#8217;t see as an option using the home assistant WLED service.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"dim-when-playing\">Dim when Playing<\/h1>\n\n\n\n<p>The first automation in our set of 3 is to dim the lights when the Roku starts playing some content.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"trigger\">Trigger:<\/h2>\n\n\n\n<p>The trigger for dimming the lights uses a state change from any state to &#8216;playing&#8217;. Since we don&#8217;t care about the original state, we leave the &#8216;from&#8217; field blank, essentially acting as a wildcard, and we set the &#8216;to&#8217; field to &#8216;playing&#8217;. This trigger will work when going from paused to playing, from an app to playing, etc.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"635\" height=\"426\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/90f21406c8144494995cfb8dc2b51e64.png\" alt=\"\" class=\"wp-image-633\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/90f21406c8144494995cfb8dc2b51e64.png 635w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/90f21406c8144494995cfb8dc2b51e64-300x201.png 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"condition\">Condition:<\/h2>\n\n\n\n<p>The condition here is that the LED strip is already on. If the LED strip is off, we do not want to turn it on and start manipulating it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"327\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/17984c12c7264eb99422c6b46a7b7628.png\" alt=\"\" class=\"wp-image-634\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/17984c12c7264eb99422c6b46a7b7628.png 638w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/17984c12c7264eb99422c6b46a7b7628-300x154.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"actions\">Actions:<\/h2>\n\n\n\n<p>It may seem a bit strange that we&#8217;re turning on the light as the action here when we already know its on, but it was the most straight forward way I could find to set the brightness on the light strip.<\/p>\n\n\n\n<p>After turning the lights on, we want to set the lights to a solid color and call the preset to our dim red preset. I realize this could all be performed using the preset, but this is in part a relic of my experimenting with the automations. This can probably be simplified into the preset to handle the brightness, effect, and color.<br><img decoding=\"async\" src=\"\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"627\" height=\"631\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/9dd15ac4ffed45bebb069476e6753083.png\" alt=\"\" class=\"wp-image-636\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/9dd15ac4ffed45bebb069476e6753083.png 627w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/9dd15ac4ffed45bebb069476e6753083-298x300.png 298w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/9dd15ac4ffed45bebb069476e6753083-150x150.png 150w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/9dd15ac4ffed45bebb069476e6753083-100x100.png 100w\" sizes=\"auto, (max-width: 627px) 100vw, 627px\" \/><\/figure>\n\n\n\n<p>The final (and only really necessary) action is to call a service with one argument to the light strip. The argument is the preset number that was created in the webui of WLED.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"630\" height=\"347\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/73ad9c453c804e0ea357b4a195a3ddaa.png\" alt=\"\" class=\"wp-image-637\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/73ad9c453c804e0ea357b4a195a3ddaa.png 630w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/73ad9c453c804e0ea357b4a195a3ddaa-300x165.png 300w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"turn-bright-when-paused\">Turn Bright when Paused<\/h1>\n\n\n\n<p>The second automation in this grouping is to turn the lights up when pausing the video.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"trigger-2\">Trigger:<\/h2>\n\n\n\n<p>The trigger for turning up the lights when the media is paused is similar to the others. This time we want the state to change from playing to anything else. Due to this, we&#8217;re just using the &#8216;from&#8217; field.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"657\" height=\"423\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/29b76cd74e9d40c19c43f9abbbac136a.png\" alt=\"\" class=\"wp-image-638\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/29b76cd74e9d40c19c43f9abbbac136a.png 657w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/29b76cd74e9d40c19c43f9abbbac136a-300x193.png 300w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"condition-2\">Condition:<\/h2>\n\n\n\n<p>We only want to adjust the lights when they&#8217;re on, if we turn them off then we don&#8217;t want to be manipulating them.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"327\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/17984c12c7264eb99422c6b46a7b7628-1.png\" alt=\"\" class=\"wp-image-635\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/17984c12c7264eb99422c6b46a7b7628-1.png 638w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/17984c12c7264eb99422c6b46a7b7628-1-300x154.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"action\">Action:<\/h2>\n\n\n\n<p>The action for this automation is simple enough, we just need to set the light strip to the preset. This is a service call with one argument to the light strip.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"349\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/b129001e3dfb423da3ca946f6519d8ff.png\" alt=\"\" class=\"wp-image-639\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/b129001e3dfb423da3ca946f6519d8ff.png 628w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/b129001e3dfb423da3ca946f6519d8ff-300x167.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"turn-off-when-idle\">Turn off When Idle<\/h1>\n\n\n\n<p>The final automation for this setup is to turn the lights off when the Roku goes idle. The idle state is when they Roku goes to the screensaver. In this automation, we&#8217;re not going to use the condition that the light strip is on, since if it is on or off, turning it off will have the exact same effect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"trigger-3\">Trigger:<\/h2>\n\n\n\n<p>The trigger for turning off the lights when the Roku goes idle is similar to the others. This time we want the state to change from anything to idle. Due to this, we&#8217;re just using the &#8216;to&#8217; field.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"427\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/22bcdc10fa2d4cec82b90b9e4d3a4296.png\" alt=\"\" class=\"wp-image-640\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/22bcdc10fa2d4cec82b90b9e4d3a4296.png 653w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/22bcdc10fa2d4cec82b90b9e4d3a4296-300x196.png 300w\" sizes=\"auto, (max-width: 653px) 100vw, 653px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"action-2\">Action:<\/h2>\n\n\n\n<p>The action is simple to setup, we just want to turn off the light strip.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"289\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/7427ebc138474759bfd94f13da312701-1024x289.png\" alt=\"\" class=\"wp-image-641\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/7427ebc138474759bfd94f13da312701-1024x289.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/7427ebc138474759bfd94f13da312701-300x85.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/7427ebc138474759bfd94f13da312701-768x217.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/7427ebc138474759bfd94f13da312701.png 1094w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"testing-and-changes-to-plans\">Testing and Changes to Plans<\/h1>\n\n\n\n<p>I went to play and pause the Roku far more times than I expected. Using the testing is how I found my sun condition of before sunrise and after sunset was causing problems. It took a few tries to figure out the right status settings for the automation. Below is the failed Sun condition that I tried to use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"332\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/ad47cb4c4ef24a6a818c2b3af70a2d46.png\" alt=\"\" class=\"wp-image-642\" title=\"\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/ad47cb4c4ef24a6a818c2b3af70a2d46.png 621w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/ad47cb4c4ef24a6a818c2b3af70a2d46-300x160.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/figure>\n\n\n\n<p>Since this condition did not work, I decided to create a different condition, that the WLED strip is on already before manipulating it. Since the goal Sun condition was to manipulate the lights only at night, I decided that using the lights on\/off status would be a good compromise and fit the same goal. I can just say &#8216;well if the lights are on already, then start manipulating them&#8217;.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h1>\n\n\n\n<p>This was a fun project to get some automation experience with WLED. I didn&#8217;t have the light strip setup with my TV as I hadn&#8217;t yet decided how I was going to use it, I just wanted to know what I could do. This does however work pretty well. This also gave me some other knowledge on the automations, triggers, and actions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was able to get WLED going on a light strip but I do have a lack of ideas on how to make use of it. I finally decided to go with the tried and true movie lighting. So my goal is to setup automations so that when my Roku begins playing something, the WLED &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lab.rapternet.us\/?p=629\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;WLED Automation for Roku in Home Assistant&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[39,49,58],"class_list":["post-629","post","type-post","status-publish","format-standard","hentry","category-how-to","tag-home-assistant","tag-smart-home","tag-wled"],"_links":{"self":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=629"}],"version-history":[{"count":3,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/629\/revisions"}],"predecessor-version":[{"id":1173,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/629\/revisions\/1173"}],"wp:attachment":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}