<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Jordan Rounds]]></title><description><![CDATA[Tinker & Putter]]></description><link>https://jordanrounds.com/</link><image><url>https://jordanrounds.com/favicon.png</url><title>Jordan Rounds</title><link>https://jordanrounds.com/</link></image><generator>Ghost 3.21</generator><lastBuildDate>Sat, 07 Feb 2026 12:31:58 GMT</lastBuildDate><atom:link href="https://jordanrounds.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant]]></title><description><![CDATA[<p>The house I recently moved into contains 40+ 6" recessed lights all containing incandescent or halogen bulbs ranging from 120 to 150 watts each. Basically they had flood lights installed in the house. These lights were all extremely bright and completely inefficient. I am in the process of replacing all</p>]]></description><link>https://jordanrounds.com/controlling-hue-bulbs-with-insteon-dimmers-using-node-red-and-home-assistant/</link><guid isPermaLink="false">5efb3a6c6239532b6113e3f0</guid><category><![CDATA[Hue]]></category><category><![CDATA[Home Assistant]]></category><category><![CDATA[insteon]]></category><category><![CDATA[Smart Home]]></category><category><![CDATA[Node Red]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Mon, 17 Aug 2020 22:42:44 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/08/IMG_6856.png" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/08/IMG_6856.png" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant"><p>The house I recently moved into contains 40+ 6" recessed lights all containing incandescent or halogen bulbs ranging from 120 to 150 watts each. Basically they had flood lights installed in the house. These lights were all extremely bright and completely inefficient. I am in the process of replacing all of them with these <a href="https://www2.meethue.com/en-us/p/hue-white-and-color-ambiance-downlight-5-6-inch/5996611U5">Hue Downlights</a>, which are only 9 watts each, and plenty bright at 650 lumens. On top of that I can now control the color or temperature of every light in the house.</p><p>In my previous house I controlled Hue lighting from <a href="https://www.indigodomo.com/">Indigo</a> and used physical <a href="https://www.smarthome.com/products/switchlinc-dimmer-insteon-2477d-remote-control-dimmer-dual-band-white">Insteon dimmers</a>. I want to achieve the same thing in the new house, but using Home Assistant. I feel like I caused myself a bit of headache by wanting to use the Insteon dimmers, because they have lights on them that show the brightness level., and I am not able to handle this light not properly reflecting the brightness of the Hue bulbs being controlled. I also wanted to be able to make them be able to dim or brighten the hue bulbs by holding down the dimmer paddle like intended with standard bulbs.</p><h2 id="whats-been-done-so-far">Whats been done so far?</h2><p>I've successfully got the Insteon dimmers setup and working with Home Assistant using <a href="https://github.com/TD22057/insteon-mqtt">Insteon-MQTT</a> running in a Docker container. I'm able to control the dimmers through the Home Assistant UI and see their state reflected by interacting with them manually. You can read about how I set this part up here:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://jordanrounds.com/insteon-mqtt-home-assistant/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Setup Insteon-MQTT and integrate with Home Assistant</div><div class="kg-bookmark-description">Recently I moved into a new house. My previous house was mostly Insteon devices
and I used Indigo [https://www.indigodomo.com/] running on a Mac Mini as my home
automation software. Before moving I had slowly started dabbling with Home
Assistant and got a bunch of my Insteon devices communicating wi…</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://jordanrounds.com/favicon.ico" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant"><span class="kg-bookmark-author">Jordan Rounds</span><span class="kg-bookmark-publisher">Jordan Rounds</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://jordanrounds.com/content/images/2020/06/banner-2.png" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant"></div></a></figure><h2 id="time-to-actually-control-something-">Time to actually control something!</h2><p>My first attempt at making all of this work was by using normal HA automations written in YAML. In the beginning it seemed like this was going to work without any issue. Turning the lights on and off was extremely straight forward. 15 minutes later if thats all I wanted I would have been done.</p><h3 id="why-it-got-complicated">Why it got complicated</h3><p>The Insteon Dimmers when brightening or dimming only send payloads of in <code>UP</code>,  <code>DOWN</code>, and  <code>STOP</code>. They do not know their actual brightness level, and only report that level after they send <code>STOP</code>.  If I actually wanted to change the brightness I needed to kick off a script that would increase or decrease the brightness at an interval until the <code>STOP</code> payload was received. This seemed easy enough, and I did get that working as well. There is even an <a href="https://www.home-assistant.io/cookbook/dim_and_brighten_lights/">example</a> of it in the Home Assistant docs. This is now the point where I'm my own worst enemy and everything fell apart. After the <code>STOP</code> payload came through I'd stop the script, and then the dimmer would report its brightness and since I was changing the light brightness independently of the dimmer brightness things would be out of sync and the light would either brighten or dim to match the dimmer itself. I got it pretty close by adjusting the timing and amount the brightness changed each loop, but it was never quite right. Here's an example of just the yaml file for brightness changing from the dimmer.</p><pre><code class="language-yaml">- id: dimmer_brightness
  alias: "Dimmer Brightness Change"
  trigger:
    platform: state
    entity_id:
      - light.dimmer
  condition:
    condition: template
    value_template: &gt;-
      {% set manual_state = state_attr(trigger.entity_id, "manual_state") %}
      {% set is_not_manual = (manual_state == "STOP" or manual_state == "None") %}
      {% set dimmer_on = (trigger.from_state.state == 'on' and trigger.to_state.state == 'on') %}
      {% set from_off_to_on = trigger.from_state.state == 'off' and trigger.to_state.state == 'on' %}
      {% set brightness_change = trigger.from_state.attributes.brightness != trigger.to_state.attributes.brightness %}
      {% set needs_update = state_attr(state_attr("sensor.insteon_map", state_attr(trigger.entity_id, 'address')), 'brightness') != trigger.to_state.attributes.brightness %}
      {{ dimmer_on and brightness_change and is_not_manual and needs_update  }}
  action:
    - service: light.turn_on
      data_template:
        entity_id: &gt;-
          {% set address = state_attr(trigger.entity_id, 'address') %}
          {{ state_attr("sensor.insteon_map", address) }}
        brightness: &gt;-
           {{ trigger.to_state.attributes.brightness }}</code></pre><p>Does that explain why I felt it got too complicated? I needed to check all sorts of different conditions and try to present that in a sane way through yaml. I started to go slightly crazy. In the end I had 9 yaml files with the different parts of the automations to keep everything in sync.</p><h3 id="what-were-my-options">What were my options?</h3><p>I'm sure there are plenty of options, but the two I looked into were <a href="https://nodered.org/">Node Red</a> and <a href="https://appdaemon.readthedocs.io/en/latest/">AppDaemon</a>. My initial instinct was to try and use AppDaemon since I'm relatively comfy writing Python, and it's a familiar path to have to take from my experiences using Indigo. I ended up deciding to give Node Red a try first though, since the barrier to entry as well as the visual representation was appealing and seemed like it might be easier to manage later once I've forgotten how everything works at a later date.</p><h3 id="so-i-installed-and-setup-node-red">So, I Installed and Setup Node Red</h3><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://jordanrounds.com/installing-node-red-in-docker-for-home-assistant/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Installing Node Red in Docker for Home Assistant</div><div class="kg-bookmark-description">I
[https://www.smarthome.com/products/switchlinc-dimmer-insteon-2477d-remote-control-dimmer-dual-band-white]
[https://www.indigodomo.com/]
[https://www2.meethue.com/en-us/p/hue-white-and-color-ambiance-downlight-5-6-inch/5996611U5…</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://jordanrounds.com/favicon.ico" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant"><span class="kg-bookmark-author">Jordan Rounds</span><span class="kg-bookmark-publisher">Jordan Rounds</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://jordanrounds.com/content/images/2020/07/banner-1.png" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant"></div></a></figure><h2 id="adding-the-dimmers-to-ha">Adding the Dimmers to HA</h2><p>The dimmers are added pretty much as you'd expect based on how I walked through setting up <a href="https://jordanrounds.com/insteon-mqtt-home-assistant/">insteon-mqtt with home assistant</a>. There are a few differences though, which are the addition of <code>json_attributes_topic</code> which is going to be how we are able to track the manual interactions, as well as the addition of a <code>unique_id</code> for no reason other than I didn't like the UI complaining to me about it not having one.</p><pre><code class="language-yaml">- name: dimmer_hallway
  platform: mqtt
  schema: json
  state_topic: "insteon/41.b3.5e/state"
  command_topic: "insteon/41.b3.5e/level"
  json_attributes_topic: "insteon/41.b3.5e/manual_state"
  brightness: true
  unique_id: 41.b3.5e</code></pre><p>There will be an additional attribute that will show up called <code>manual_state</code> which will say <code>STOP</code> once you've released the dimmer paddle.</p><h2 id="creating-a-generic-ha-config-and-node-red-flow">Creating a Generic HA Config and Node Red Flow</h2><p>My goal was to make it so that for 99% of the use cases I would be able to simply add a new hue bulb and "pair" it to a dimmer switch and have it work with little effort. To do that I ended up with the concept of   <code>sync_entity_id, sync_address, address, sync_entites, sync_dimmers, and sync_bulbs</code>.  </p><p>There very well may be a much more straight forward way of doing it but I found myself in the situation where I needed a place to store some additional meta data that was manually configured for my lights and dimmers. To do this I heavily utilized the flexibility of  <code>customize.yaml</code>. </p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">#----------------------------------------------------------
#         Hallway Dimmers
#----------------------------------------------------------
light.dimmer_hallway:
  address: 41.b3.5e
  is_sync_dimmer: true
  sync_entity_id: light.hallway
  friendly_name: Hallway Dimmer

light.dimmer_hallway_master:
  address: 41.b8.f6
  is_sync_dimmer: true
  sync_entity_id: light.hallway
  friendly_name: Hallway Dimmer Master

#----------------------------------------------------------
#          Hallway Bulbs
#----------------------------------------------------------
light.hallway:
  sync_address: 41.b3.5e
  is_sync_bulb: true
  sync_entities:
    - light.dimmer_hallway
    - light.dimmer_hallway_master</code></pre><figcaption>Hallway Example of customize.yaml</figcaption></figure><h3 id="what-are-these-used-for">What are these used for?</h3><p>These probably wont make a ton of sense at the moment but will be more clear once we get into the Node Red flow.</p><!--kg-card-begin: markdown--><p><strong>Dimmers</strong></p>
<ul>
<li>address - the actual insteon device address</li>
<li>is_sync_dimmer - so we know if the dimmer is supposed to talk to a bulb</li>
<li>sync_entity_id: id of the bulb to reference</li>
</ul>
<p><strong>Bulbs</strong></p>
<ul>
<li>sync_address - the address of the insteon device to control</li>
<li>is_sync_bulb - so we know if the bulb is supposed to talk to a dimmer</li>
<li>sync_entities - list of dimmers to update when the light changes</li>
</ul>
<!--kg-card-end: markdown--><h2 id="creating-the-flows">Creating the Flows</h2><p>Now that the Home Assistant configuration is handled its time to create the flow. The main thing to remember here is that the state of the bulb is always the most important truth. By taking this approach we wont end up in any weird update loops and also still have the ability to use any third party apps to control the bulbs and the dimmers will still respond appropriately. You can download the <a href="https://gist.github.com/jordanrounds/ab7edc7dab8abbf03d7ca5d11fb1fb0c"><strong>Entire Node Red Flow</strong></a><strong> </strong>otherwise I've broken it up into chunks that are linked to as we go.</p><h3 id="bulb-flow">Bulb Flow</h3><p>Here's what the flow for the lights changing looks like, and you can download it here: <a href="https://gist.github.com/jordanrounds/35539f1d29f16c5739f593b47e5c2da4">light-flow.json</a></p><figure class="kg-card kg-image-card kg-width-full"><img src="https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-11.48.44-AM.png" class="kg-image" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant" width="2394" height="290" srcset="https://jordanrounds.com/content/images/size/w600/2020/08/Screen-Shot-2020-08-17-at-11.48.44-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/08/Screen-Shot-2020-08-17-at-11.48.44-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/08/Screen-Shot-2020-08-17-at-11.48.44-AM.png 1600w, https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-11.48.44-AM.png 2394w"></figure><p>The first thing that happens is we check if the bulb is a sync_bulb, and if it is we move on to a function node which gets the list of sync_entities so that we can update their state.</p><figure class="kg-card kg-code-card"><pre><code class="language-javascript">let attrs = msg.data.new_state.attributes;
let payload = msg.payload;

if(attrs.hasOwnProperty("sync_entities")) {
    msg.payload = attrs.sync_entities;
    msg.original_payload = payload;
    return msg;
}</code></pre><figcaption>Sync Entities Node</figcaption></figure><p>Next those entities are piped through the split node, so that we can go get each dimmer individually using its it. The split node sends an individual msg for each entity_id in the sync_entities list. It sets msg.payload to each of those entity_ids, which go through a ha-get-entities node that uses the entity_id as its property its searching on.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-11.32.38-AM.png" class="kg-image" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant" width="1012" height="1202" srcset="https://jordanrounds.com/content/images/size/w600/2020/08/Screen-Shot-2020-08-17-at-11.32.38-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/08/Screen-Shot-2020-08-17-at-11.32.38-AM.png 1000w, https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-11.32.38-AM.png 1012w" sizes="(min-width: 720px) 720px"><figcaption>Dimmer Node</figcaption></figure><p>Finally there is a check using a switch node that looks at the original payload to see if the bulb was turning on or off. From there if its off we turn the dimmer off, and if its on there is one last check to make sure the bulb wasn't changing state due to a manual interaction with the dimmer.</p><figure class="kg-card kg-code-card"><pre><code class="language-javascript">let attrs = msg.payload.attributes;
let hasManual = attrs.hasOwnProperty("manual_state");

if(!hasManual || hasManual &amp;&amp; attrs.manual_state == "STOP") {
    return msg;
}
</code></pre><figcaption>Stop Node</figcaption></figure><h3 id="dimmer-flow">Dimmer Flow</h3><p>The dimmer flow is similar to the bulb flow but even more straight forward. You can download it here: <a href="https://gist.github.com/jordanrounds/446311d0be02df6507f4a4766e3bb599">dimmer-flow.json</a></p><p>It starts out exactly the same where the first node is looking for events coming from any entity starting with <code>light.dimmer</code>. The next node is a simple switch checking if it is a sync dimmer. The Stop node is the same as the one from the bulb flow, which is checking to make sure the dimmer isn't being manually interacted with.</p><figure class="kg-card kg-image-card kg-width-full"><img src="https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-11.41.33-AM.png" class="kg-image" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant" width="1830" height="396" srcset="https://jordanrounds.com/content/images/size/w600/2020/08/Screen-Shot-2020-08-17-at-11.41.33-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/08/Screen-Shot-2020-08-17-at-11.41.33-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/08/Screen-Shot-2020-08-17-at-11.41.33-AM.png 1600w, https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-11.41.33-AM.png 1830w"></figure><p>Finally we check if its an on or an off command with the on/off switch node. If its off then we simply turn the bulb off, but if its on we make one check to make sure the bulb is actually off before turning it on. This was done to handle the edge case of using a bulb standalone as well as in a hue light group. Turning the bulb on individually in hand turns on the group as well. When the group turned on it triggered an update of the dimmer from the bulb, and if you don't  check against the light group being on already it would turn on the whole group. (thats confusing, and I'm not sure a better way to explain...)</p><h3 id="manual-dimming">Manual Dimming</h3><p>This is where things started to get a bit more tricky. Now I wanted to actually start handing the manual interaction with the dimmers, meaning if I hold down the dimmer paddle I now want the bulbs to start dimming and then stop when I let off the paddle. That sounds pretty straight forward, but it ends up becoming a bit of a headless interaction because we will be getting zero feedback about state until the paddle is released, so the speed and way it behaves is all based on my best guess and referencing what I used to have when I did a similar thing using <a href="https://www.indigodomo.com/">Indigo</a>. I used the timing from this <a href="https://github.com/nsheldon/Hue-Lights-Indigo-plugin">Indigo Hue Plugin</a>. You can download the flow here: <a href="https://gist.github.com/jordanrounds/fe1bedc8ad22d88e8838e2ceed8028e2">manual-dim-flow.json</a></p><p>For the manual interactions we will be responding directly to the MQTT messages that are coming over the manual_state channel, and the first node will simply be looking for the <code>STOP</code> payload and if it's received it will kill the 400ms timer.</p><figure class="kg-card kg-image-card kg-width-full kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-2.39.49-PM.png" class="kg-image" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant" width="2346" height="616" srcset="https://jordanrounds.com/content/images/size/w600/2020/08/Screen-Shot-2020-08-17-at-2.39.49-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/08/Screen-Shot-2020-08-17-at-2.39.49-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/08/Screen-Shot-2020-08-17-at-2.39.49-PM.png 1600w, https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-2.39.49-PM.png 2346w"><figcaption>Manual Dimmer Flow</figcaption></figure><p>If the payload is not <code>STOP</code> then it's a matter of looking up the bulb that listens to this dimmer, by using the dimmer address and looking up the bulb that has that address set as its sync_address. Once the light is found I decided to create a JSON object of "instructions" that will be iterated over by the timer. The below javascript is what is found in the Dim/Brighten function node.</p><figure class="kg-card kg-code-card"><pre><code class="language-javascript">let light = msg.payload;
let step = 30, max = 20, transition = .4;
let curBrightness = 0, nextBrightness = 0;

msg.instructions = { "increase": true, "transition": transition, "step": step, "count": 0, "max": max, "brightness": 0};

//brightness attribute may not exist if brightening from off state
if(light.attributes.hasOwnProperty('brightness')) {
    curBrightness = light.attributes.brightness;
}

if(msg.manual_state == "DOWN") {
    nextBrightness = curBrightness - step;
    nextBrightness = nextBrightness &lt; 0 ? 0 : nextBrightness;
    msg.instructions.increase = false;
} else {
    nextBrightness = curBrightness + step;
    nextBrightness = nextBrightness &gt; 255 ? 255 : nextBrightness;
}

msg.instructions.brightness = nextBrightness
msg.light = light;

return msg;</code></pre><figcaption>Dim/Brighten Node</figcaption></figure><p>It creates an instructions object containing properties saying if its increasing or decreasing brightness depending on if manual_state is set to <code>UP</code> or <code>DOWN</code>, how fast the transition is, the step of how much to change the brightness, and the brightness to be set. Next immediately start updating the brightness of the bulb so there isn't a feeling of delay.</p><p>From here the stoptimer node will get kicked off and it will fire every 400ms. The Update Instructions function node will then use and update that instructions object to increase or decrease brightness appropriately and also killing the timer if the button is held down longer than it takes to completely turn on or off the bulb.</p><figure class="kg-card kg-code-card"><pre><code class="language-javascript">let inst = msg.instructions;

inst.count++;

if(inst.count &gt;= inst.max || inst.brightness &gt; 255 || inst.brightness &lt; 0) {
    msg.payload = "stop"
    return [null, msg]
}


if(inst.increase) {
    inst.brightness += inst.step;
} else {
    inst.brightness -= inst.step;
}

return [msg, null];</code></pre><figcaption>Update Instructions Node</figcaption></figure><h3 id="manual-fast-on">Manual Fast On</h3><p>There is one final interaction that I wanted to handle which is the simple fact that if the light was on and the dimmer was on, and I tapped the dimmer again to increase its brightness all the way to 100% nothing would happen.</p><p> This would come through as a payload mode of <code>normal</code> and a state of <code>ON</code>. You could also add things to this such as support for "fast" which would be a double tap of the switch for an instant on or off message. I decided to handle fast in the same way I handled normal. You can download the flow here: <a href="https://gist.github.com/jordanrounds/586268908aa687929a8b0f789b64cf74">manual-on-off-flow.json</a></p><figure class="kg-card kg-image-card kg-width-full"><img src="https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-1.34.12-PM.png" class="kg-image" alt="Controlling Hue bulbs with Insteon Dimmers using Node Red and Home Assistant" width="1746" height="418" srcset="https://jordanrounds.com/content/images/size/w600/2020/08/Screen-Shot-2020-08-17-at-1.34.12-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/08/Screen-Shot-2020-08-17-at-1.34.12-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/08/Screen-Shot-2020-08-17-at-1.34.12-PM.png 1600w, https://jordanrounds.com/content/images/2020/08/Screen-Shot-2020-08-17-at-1.34.12-PM.png 1746w"></figure><p>First uses a get entities node to find the dimmer entity being pressed using its address. Once we've got the dimmer, it's time to figure out if the dimmer was manually pressed and was already on. This is done in the Manual Tap node.</p><figure class="kg-card kg-code-card"><pre><code class="language-javascript">let payload = msg.payload;

msg.dimmer = msg.dimmers[0];
delete msg.dimmers;

let device_on = payload.reason == "device" &amp;&amp; payload.state == "ON";
let device_off = payload.reason == "device" &amp;&amp; payload.state == "OFF";
let fast = payload.mode == "fast";

let fast_on = msg.dimmer.state == "off" &amp;&amp; device_on &amp;&amp; fast;
let fast_off = msg.dimmer.state == "on" &amp;&amp; device_off &amp;&amp; fast;

let fast_on_from_on = msg.dimmer.state == "on" &amp;&amp; device_on &amp;&amp; fast;
let fast_off_from_off = msg.dimmer.state == "off" &amp;&amp; device_off &amp;&amp; fast

let on_from_on = msg.dimmer.state == "on" &amp;&amp; device_on

if(fast_on || on_from_on) {
    msg.brightness = payload.brightness;
    return msg;
}</code></pre><figcaption>Manual Tap Node</figcaption></figure><p>There's more script there than necessary to solve what I actually needed, but I figured I'd try and capture a few of the various states incase I ever wanted to respond to them differently in the future.</p><h2 id="closing-thoughts">Closing Thoughts</h2><p>Overall I'm pretty happy with my setup. It's certainly not perfect but 99% of the time it works exactly as you'd expect. One major consideration to be made is you really need to commit to the idea that if the mqtt broker, insteon-mqtt, or home assistant isnt reachable the switches will do nothing. I've spent some time figuring out the best way to mitigate this, and my current solution is nothing runs on wifi, and everything is connected to a UPS. Obviously if the power goes out so do the lights, but the UPS is in place to prevent something from not rebooting properly during a short power outage as well as piece of mind that something wont get corrupt by shutting down improperly. </p><p>Another is how I'm handling manual dimmer changes. In the current setup the MQTT node is listening to <code>insteon/+/manual_state</code> which is any dimmer in my house. If someone were to manually dim one at the same time as someone else, whoever stops first will stop both lights. After writing this I'm not 100% sure, but there may even be an issue using two switches at the exact same time. I've never tested but assume bad things happen. At the end of the day its only myself and my wife living in this house and the likelihood of this happening is slim.</p>]]></content:encoded></item><item><title><![CDATA[Installing Node Red in Docker for Home Assistant]]></title><description><![CDATA[The process of setting up Node Red using Docker and then connecting it to Home Assistant to do some simple automations.]]></description><link>https://jordanrounds.com/installing-node-red-in-docker-for-home-assistant/</link><guid isPermaLink="false">5efbdfa76239532b6113e5ad</guid><category><![CDATA[Node Red]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Home Assistant]]></category><category><![CDATA[Home Automation]]></category><category><![CDATA[Docker Compose]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Wed, 01 Jul 2020 17:08:30 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/07/banner-1.png" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/07/banner-1.png" alt="Installing Node Red in Docker for Home Assistant"><p><a href="https://www2.meethue.com/en-us/p/hue-white-and-color-ambiance-downlight-5-6-inch/5996611U5"><a href="https://www.indigodomo.com/"><a href="https://www.smarthome.com/products/switchlinc-dimmer-insteon-2477d-remote-control-dimmer-dual-band-white">I</a></a></a>'ve been trying to figure out a good reliable way to have semi complex automations setup for Home Assistant that I can easily edit and debug. Node Red ended up being the solution I settled on.</p><p>My goal was to be able to control Hue lights with Insteon dimmers where the dimmers aren't actually connected to the load and communicating via MQTT. This is the second post in a series about that journey. You can find the first post here:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://jordanrounds.com/insteon-mqtt-home-assistant/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Setup Insteon-MQTT and integrate with Home Assistant</div><div class="kg-bookmark-description">Recently I moved into a new house. My previous house was mostly Insteon devices
and I used Indigo [https://www.indigodomo.com/] running on a Mac Mini as my home
automation software. Before moving I had slowly started dabbling with Home
Assistant and got a bunch of my Insteon devices communicating wi…</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://jordanrounds.com/favicon.ico" alt="Installing Node Red in Docker for Home Assistant"><span class="kg-bookmark-author">Jordan Rounds</span><span class="kg-bookmark-publisher">Jordan Rounds</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://jordanrounds.com/content/images/2020/06/banner-2.png" alt="Installing Node Red in Docker for Home Assistant"></div></a></figure><p>We will walkthrough installing Node Red in Docker and then setting it up to connect to Home Assistant. Finally we will verify that messages are coming through properly.</p><h2 id="installing-node-red">Installing Node Red</h2><p>Being new to Node Red, I had zero idea what I was doing, but knew that I wanted to run it in Docker. I started by looking around at the various Dockerfiles out there and tried to pick the various flows that it seemed like I might need installed. The most important one here being <a href="https://flows.nodered.org/node/node-red-contrib-home-assistant-websocket">node-red-contrib-home-assistant-websocket</a>. I think the only other one I needed was <a href="https://flows.nodered.org/node/node-red-contrib-stoptimer">node-red-contrib-stoptimer</a>. Here's the Dockerfile I ended up going with:</p><figure class="kg-card kg-code-card"><pre><code class="language-Dockerfile">FROM nodered/node-red

RUN npm install node-red-contrib-actionflows \
        # https://flows.nodered.org/node/node-red-contrib-actionflows
				node-red-contrib-home-assistant-websocket \
        # https://flows.nodered.org/node/node-red-contrib-home-assistant-websocket
				node-red-contrib-stoptimer \
        # https://flows.nodered.org/node/node-red-contrib-stoptimer
				node-red-contrib-time-range-switch \
        # A simple Node-RED node that routes messages depending on the time. If the current time falls within the range specified in the node configuration, the message is routed to output 1. Otherwise the message is routed to output 2.
				node-red-contrib-timecheck \
        # Is it that time yet? This node compares a given time to the current time.
				node-red-node-timeswitch
        # node to provide a simple timeswitch node to schedule daily on/off events</code></pre><figcaption>Dockerfile</figcaption></figure><p>From there it was just a simple docker-compose file to get up and running.</p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">version: '3.7'
services:
  node-red:
    build: .
    container_name: "node-red"
    environment:
      TZ: ${TZ}
    image: "nodered/node-red"
    restart: unless-stopped
    ports:
      - "1880:1880"
    volumes:
      - "data:/data"
volumes:
  data:
    name: node-red_data
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/node-red/data
</code></pre><figcaption>docker-compose.yaml</figcaption></figure><p>Run <code>docker-compose up -d</code> and then navigate to the host's ip on port 1880.</p><h2 id="connecting-node-red-to-home-assistant">Connecting Node Red to Home Assistant</h2><p>The first thing we need to do to connect Node Red to Home Assistant is generate an access token. I decided to at the same time create a new user in Home Assistant specifically for Node Red. I don't have any real justification for this step other than I liked the separation. So you could totally skip this bit.</p><p>Click Configuration on the left navigation, and scroll down and click Users.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/Users.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Users.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Users.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Users.png 1600w, https://jordanrounds.com/content/images/2020/07/Users.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>Click the add button in the lower right, and create a new admin user for node red.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/Add-User-1.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Add-User-1.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Add-User-1.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Add-User-1.png 1600w, https://jordanrounds.com/content/images/2020/07/Add-User-1.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>After your new user is created click on your current user in the lower left, and click logout. Next login as your node red user. Once logged in again click on the user in the lower left, and scroll down the profile page to the bottom section named Long-Lived Access Tokens and click Create Token.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/Tokens.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Tokens.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Tokens.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Tokens.png 1600w, https://jordanrounds.com/content/images/2020/07/Tokens.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>You'll then give your token a name and click Ok.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/Name-Token.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Name-Token.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Name-Token.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Name-Token.png 1600w, https://jordanrounds.com/content/images/2020/07/Name-Token.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>Next you'll see a modal displaying your access token. Be sure to copy and save it somewhere so we can enter it back in Node Red.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/Copy-Token.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Copy-Token.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Copy-Token.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Copy-Token.png 1600w, https://jordanrounds.com/content/images/2020/07/Copy-Token.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>Now its time to go back over to Node Red, and the first thing we will do is drop a server-state-changed node, which is labeled "events: state" from the left hand nodes panel under the Home Assistant section.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/event-state-node.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/event-state-node.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/event-state-node.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/event-state-node.png 1600w, https://jordanrounds.com/content/images/2020/07/event-state-node.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>Next double click on the node you added, and you'll see the configuration for that node. Next to the Server field click the pencil icon to add a new server. Then give your server a name, enter its url, and put that access token we created in there. Finally click the add button.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/configure-event-state-node.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/configure-event-state-node.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/configure-event-state-node.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/configure-event-state-node.png 1600w, https://jordanrounds.com/content/images/2020/07/configure-event-state-node.png 2272w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/configure-HA-server.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/configure-HA-server.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/configure-HA-server.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/configure-HA-server.png 1600w, https://jordanrounds.com/content/images/2020/07/configure-HA-server.png 2272w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Now you'll see the configuration for the node. We are just going to test that everything is working next so you can give it a name, pick an entity (one you can change state easily on), and then uncheck only on state change.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/state-node-config-1.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/state-node-config-1.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/state-node-config-1.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/state-node-config-1.png 1600w, https://jordanrounds.com/content/images/2020/07/state-node-config-1.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>From here click done and you'll see the Flow canvas again with our new node. Next to see if everything's working scroll up to the top of the nodes list on the left and find the debug node. Drop one of those on the canvas. Once its there click and drag from the gray box on the event node to the debug node.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/debug-node-1.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/debug-node-1.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/debug-node-1.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/debug-node-1.png 1600w, https://jordanrounds.com/content/images/2020/07/debug-node-1.png 2272w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/connect-the-nodes-1.png" width="860" height="512" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/connect-the-nodes-1.png 600w, https://jordanrounds.com/content/images/2020/07/connect-the-nodes-1.png 860w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Finally we can click the Deploy button in the upper right. Click the debug button under it and change the state of the entity through Home Assistant or however you want to change it. Then sit back and watch the messages come through.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/07/debugging.png" class="kg-image" alt="Installing Node Red in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/debugging.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/debugging.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/debugging.png 1600w, https://jordanrounds.com/content/images/2020/07/debugging.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>Now we've got Node Red Setup and working with Home Assistant, and used a debug node to confirm that.</p><h2 id="create-a-simple-automation-to-control-a-light">Create a Simple Automation to Control a Light</h2><p>This is probably the most basic thing we could do. We will use the dimmer and its payload to then trigger a light to either turn on or off. First lets drop an "events: state" node into the flow, and configure it to be an entity that is the dimmer.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-6.23.04-AM.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Screen-Shot-2020-07-01-at-6.23.04-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Screen-Shot-2020-07-01-at-6.23.04-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Screen-Shot-2020-07-01-at-6.23.04-AM.png 1600w, https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-6.23.04-AM.png 2272w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-6.22.51-AM.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Screen-Shot-2020-07-01-at-6.22.51-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Screen-Shot-2020-07-01-at-6.22.51-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Screen-Shot-2020-07-01-at-6.22.51-AM.png 1600w, https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-6.22.51-AM.png 2272w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Next add a "call service" node to the flow. Double click it to configure it. W will give it a name of "Light", set the domain to <code>light</code>, set the service to be <code>turn_{{payload}}</code> , and set the entity id to the light entity you want to control in Home Assistant. The key piece to call out here is the service entry, which is essentially taking the payload from the msg object, which will either be on or off, therefore calling the appropriate service of <code>turn_on</code> or <code>turn_off}</code>.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-8.52.55-AM.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Screen-Shot-2020-07-01-at-8.52.55-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Screen-Shot-2020-07-01-at-8.52.55-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Screen-Shot-2020-07-01-at-8.52.55-AM.png 1600w, https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-8.52.55-AM.png 2272w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-8.52.27-AM.png" width="2272" height="1918" alt="Installing Node Red in Docker for Home Assistant" srcset="https://jordanrounds.com/content/images/size/w600/2020/07/Screen-Shot-2020-07-01-at-8.52.27-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/07/Screen-Shot-2020-07-01-at-8.52.27-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/07/Screen-Shot-2020-07-01-at-8.52.27-AM.png 1600w, https://jordanrounds.com/content/images/2020/07/Screen-Shot-2020-07-01-at-8.52.27-AM.png 2272w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Finally, make sure to connect the two nodes and then go toggle your dimmer and watch the light turn on and off.</p><h2 id="what-s-now">What's Now?</h2><p>From here we can use Node Red for any types of automations that can be imagined. Searching around the internet there are many great examples others have created, and many times provide the flow to be copied and pasted right into Node Red. </p><p>We've created this simple automation be the starting point of the automations that will be needed to control Hue lights with Insteon Dimmers coming up next.</p><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Insteon-MQTT + Home Assistant]]></title><description><![CDATA[Install Insteon-MQTT and setup Insteon devices to integrate with Home Assistant over MQTT.]]></description><link>https://jordanrounds.com/insteon-mqtt-home-assistant/</link><guid isPermaLink="false">5ef3f5aa6239532b6113deb4</guid><category><![CDATA[Home Assistant]]></category><category><![CDATA[insteon]]></category><category><![CDATA[Mqtt]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Docker Compose]]></category><category><![CDATA[Home Automation]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Thu, 25 Jun 2020 23:33:14 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/06/banner-2.png" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/06/banner-2.png" alt="Insteon-MQTT + Home Assistant"><p>Recently I moved into a new house. My previous house was mostly Insteon devices and I used <a href="https://www.indigodomo.com/">Indigo</a> running on a Mac Mini as my home automation software. Before moving I had slowly started dabbling with Home Assistant and got a bunch of my Insteon devices communicating with HA via MQTT. This was great as a starting point but now I had two separate automation platforms to deal with and I was slowly moving everything that I could out of Indigo and into HA.</p><p>The move was extremely motivating to completely stop using Indigo because I had to start over anyway. Now the question was what should I use to integrate Insteon with HA. There were a few various options I found, including the built in support in HA, but I settled on <a href="https://github.com/TD22057/insteon-mqtt">Insteon-MQTT</a>. I felt like it gave me the flexibility and control that I was looking for.</p><p>The main Insteon devices that I use are <a href="https://www.smarthome.com/products/switchlinc-dimmer-insteon-2477d-remote-control-dimmer-dual-band-white">dimmers</a> and keypads. I ended up settling on them long ago because I couldn't find anything that even closely compared to the quality of hardware and I especially like the LED display of the brightness on the dimmers. To kick things off I needed to get a testing device setup.</p><h2 id="testing-setup">Testing Setup</h2><p>I built this box with a <a href="https://www.homedepot.com/p/2-Device-Drawn-Switch-Electrical-Box-683SP/202056186">metal electrical box</a> and <a href="https://www.homedepot.com/p/HDX-6-ft-13-Amp-3-Prong-Grey-Appliance-Replacement-Cord-HD-588-547/100672804">power cord</a> from Home Depot and installed a keypad and a dimmer. This gave me the flexibility to not completely have to change switches and not have lights work while getting everything setup. All I did different from a normal in-wall install was connected black to black, white to white, ground to ground, and then capped the load with a wire nut. Just be careful to not electrocute yourself and make sure its unplugged before you put a switch in or take one out.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/test-switches.png" class="kg-image" alt="Insteon-MQTT + Home Assistant" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/test-switches.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/test-switches.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/test-switches.png 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/test-switches.png 2400w" sizes="(min-width: 720px) 720px"><figcaption>Test Switches</figcaption></figure><h2 id="insteon-mqtt-install">Insteon-MQTT Install</h2><p>To start with Insteon-MQTT is extremely well <a href="https://github.com/TD22057/insteon-mqtt/blob/master/docs/quick_start.md">documented</a>. They even provide <a href="https://github.com/TD22057/insteon-mqtt/blob/master/docs/hassio_quick_start.md">instructions</a> for setting it up as an add-on in Home Assistant, but I opted for installing it as a Docker <a href="https://hub.docker.com/r/larizzo/insteon-mqtt/">container</a> I could manage myself.</p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">version: '3.7'
services:
  inseon-mqtt:
    container_name: 'insteon-mqtt'
    environment:
      TZ: ${TZ}
    image: larizzo/insteon-mqtt
    restart: unless-stopped
    devices:
      - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A403KDY0-if00-port0:/dev/ttyUSB0
    volumes:
      - config:/config:rw
      - data:/data:rw
volumes:
  config:
    name: insteon-mqtt_config
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/insteon-mqtt/config
  data:
    name: insteon-mqtt_data
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/insteon-mqtt/data
</code></pre><figcaption>docker-compose.yaml</figcaption></figure><p>Here's the docker-compose.yaml file I use. All you'll need to do is make sure the paths to your volumes are correct, and the devices definition which is pointing to the Insteon PLM thats connected to the computer running Docker. Once you have everything configured you'll just need to run docker-compose.</p><pre><code class="language-command line">docker-compose up -d</code></pre><p>At this point the container will be up and running but you wont have any devices or the PLM configured. Inside of the config directory that you had mapped as a volume you will find a file called <em>insteon_mqtt.yaml</em></p><h2 id="config-setup">Config Setup</h2><p>If you open the <em>insteon_mqtt.yaml</em> file you'll see that its wonderfully populated and commented out showing examples for configuring each type of device as well as examples for integrating into Home Assistant. </p><h3 id="plm">PLM</h3><p>The first thing we need to do is setup the <a href="https://www.smarthome.com/products/powerlinc-modem-insteon-2413u-usb-interface-dual-band?pr_prod_strat=description&amp;pr_rec_pid=5084181397637&amp;pr_ref_pid=5084181037189&amp;pr_seq=uniform">Insteon PLM</a>. Below is an example of my config for the PLM.</p><pre><code class="language-yaml">insteon:
  # Serial device:
  # USB PLM modem
  port: '/dev/ttyUSB0'
  baudrate: 19200

  # PLM modem Insteon hex address
  address: 3C.4D.74

  # Device database file storage location.
  storage: 'data'

  # Automatically refresh device states and databases (if needed) at
  # startup.  This may be slow depending on the number of devices.
  startup_refresh: False</code></pre><p>The only things you'll probably need to modify to get the PLM working is the port, which points to <em>/dev/ttyUSB0 </em>and is also what we defined in the devices section of the docker-compose file. Next you'll need to enter in whatever the actual address is of your PLM which you should find on the back of it.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/plm.png" class="kg-image" alt="Insteon-MQTT + Home Assistant" width="3024" height="4032" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/plm.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/plm.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/plm.png 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/plm.png 2400w" sizes="(min-width: 720px) 720px"><figcaption>Insteon PLM address location</figcaption></figure><h3 id="devices">Devices</h3><p>Now that we have the PLM setup its time to add our devices. For now I'm just adding a single dimmer but you could just add the addresses of all your Insteon devices in here right now. Insteon dimmers normally have an address sticker on the front of them.</p><pre><code class="language-yaml">devices:

    # Dimming devices (outlets, wall switches, lamp modules, etc).
    dimmer:
      - 41.ad.4f: 'dimmer'</code></pre><p>You'll be putting the address first followed by a colon and then a string for the name of the device. </p><p>If for some reason you don't know the address of the device you are able to get it by looking at the logs of insteon-mqtt as long as the device is powered and sending a command. If you are in this situation, restart the docker container after configuring the PLM and go checkout the logs to get your addresses. When I went through this process I used a label maker to add new address stickers to all of my dimmers.</p><h3 id="mqtt">MQTT</h3><p>Next we need to configure MQTT. You'll need at a minimum the address to your broker and the port. Optionally if you have authentication turned on the username and password.</p><pre><code class="language-yaml">mqtt:
  broker: 192.168.1.123
  port: 1883
  
  # Optional broker login data.
  username: yourusername
  password: yourpassword</code></pre><p>Once the broker is setup you can take a look at the topics for Dimmers and any of the other supported types of Insteon devices you might need. Below is an example of what my dimmer topics look like. </p><pre><code class="language-yaml">dimmer:
    state_topic: 'insteon/{{address}}/state'
    state_payload: &gt;
       { "state" : "{{on_str.upper()}}", "brightness" : {{level_255}}, "reason" : "{{reason}}", "mode" : "{{mode}}", "address" : "{{address}}" }

    manual_state_topic: 'insteon/{{address}}/manual_state'
    manual_state_payload: '{ "manual_state" : "{{manual_str.upper()}}", "address" : "{{address}}" }'

    on_off_topic: 'insteon/{{address}}/set'
    on_off_payload: '{ "cmd" : "{{value.lower()}}" }'

    level_payload: &gt;
       { "cmd" : "{{json.state.lower()}}",
         "level" : {% if json.brightness is defined %}
                      {{json.brightness}}
                   {% else %}
                      255
                   {% endif %} }
                   
    scene_topic: 'insteon/{{address}}/scene'
    scene_payload: '{ "cmd" : "{{value.lower()}}" }'</code></pre><p>It's very close to the defaults except I've included <em>reason, mode, </em>and <em>address </em>in the state payload as well as uncommented the <em>manual_state</em> topic and payload, which will send dimming start and stop payloads.</p><h2 id="restart-join-pair-and-refresh-">Restart, Join, Pair, and Refresh!</h2><p>At this point all the configuration we need for insteon-mqtt is complete. Before we do anything else go ahead and restart the container.</p><pre><code class="language-command line">docker-compose restart</code></pre><p>Once the container is back up we need to go through the process of <em>joining</em>, <em>pairing</em>, and <em>refreshing</em> all the devices. This <a href="https://github.com/TD22057/insteon-mqtt/blob/master/docs/mqtt.md">process</a> can be done from the command line or using MQTT. I chose to do it via the command line using docker exec, and I wrote a simple bash script to help keep it simple.</p><p>While it isn't necessary I did also choose to factory reset all my dimmers before adding any of them. This can be done by pulling out the small button below the dimmer button, wait ten seconds, and then press in and hold it until the switch stops beeping and then a couple seconds later you'll hear a double beep confirming that the reset was successful. You can find the instructions in the <a href="http://cache.insteon.com/documentation/2477D-en.pdf">manual</a> as well.</p><h3 id="using-mqtt">Using MQTT </h3><p>The topic would be:</p><pre><code>insteon/command/aa.bb.cc</code></pre><p>The payload would be one of these three:</p><pre><code>{ "cmd" : "join"}
{ "cmd" : "pair"}
{ "cmd" : "refresh"}</code></pre><h3 id="using-docker-exec">Using Docker Exec</h3><p>You can join and pair each device using the appropriate commands, and when done call the refresh-all command. Alternatively you could call refresh on each one individually.</p><pre><code class="language-command line">docker exec -d your_instance_name insteon-mqtt /config/insteon_mqtt.yaml join aa.bb.cc

docker exec -d your_instance_name insteon-mqtt /config/insteon_mqtt.yaml pair aa.bb.cc

docker exec -d your_instance_name insteon-mqtt /config/insteon_mqtt.yaml refresh-all</code></pre><h3 id="bash-script">Bash Script</h3><p>Lets call this script <em>insteon-mqtt.sh. </em> Make sure that the file's permissions are executable, and then type <em>./insteon-mqtt.sh</em> on the command line.</p><figure class="kg-card kg-code-card"><pre><code class="language-bash">#!/bin/bash
INSTANCE_NAME='insteon-mqtt'
CONFIG_FILE='/config/insteon_mqtt.yaml'
LINE='-------------------------------------'

echo 'Insteon MQTT Management'
echo
echo 'What would you like to do?'
echo $LINE
echo '1) Join Device'
echo '2) Pair Device'
echo '3) Refresh All Devices'
echo '4) Refresh Device'
echo $LINE

read -p 'Choose option: '
echo

if [ ${REPLY} -eq 1 ]; then
  echo "Joining Device"
  echo $LINE
  read -p 'Device Address (aa.bb.cc): ' address
  echo
  echo "Joining Device: $address"
  docker exec -d $INSTANCE_NAME insteon-mqtt $CONFIG_FILE join $address
  #docker exec -d $INSTANCE_NAME kill -HUP 1
elif [ ${REPLY} -eq 2 ]; then
  echo "Pairing Device"
  echo $LINE
  read -p 'Device Address (aa.bb.cc): ' address
  docker exec -d $INSTANCE_NAME insteon-mqtt $CONFIG_FILE pair $address
  #docker exec -d $INSTANCE_NAME kill -HUP 1
elif [ ${REPLY} -eq 3 ]; then
  echo "Refresh All Devices"
  echo $LINE
  docker exec -d $INSTANCE_NAME insteon-mqtt $CONFIG_FILE refresh-all
elif [ ${REPLY} -eq 4 ]; then
  echo "Refresh Device"
  echo $LINE
  read -p 'Device Address (aa.bb.cc): ' address
  echo
  echo "Refreshing Device: $address"
  docker exec -d $INSTANCE_NAME insteon-mqtt $CONFIG_FILE refresh $address
else
  echo "Please enter a valid option."
fi
exit 1
</code></pre><figcaption>insteon-mqtt.sh</figcaption></figure><h2 id="testing-mqtt">Testing MQTT</h2><p>Now that everything should be added, paired and ready to go its probably worth testing it out before trying to put everything in Home Assistant. Home assistant has some built in MQTT debugging under the Developer Tools.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Home-Assistant-MQTT.png" class="kg-image" alt="Insteon-MQTT + Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Home-Assistant-MQTT.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Home-Assistant-MQTT.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Home-Assistant-MQTT.png 1600w, https://jordanrounds.com/content/images/2020/06/Home-Assistant-MQTT.png 2272w" sizes="(min-width: 720px) 720px"><figcaption>Home Assistant MQTT Developer Tools</figcaption></figure><p>I prefer to use <a href="http://workswithweb.com/mqttbox.html">MQTTBox</a> which is a free download. It allows for subscribing or publishing to multiple topics easily, and keeps your setup saved for later.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/MQTTBox.png" class="kg-image" alt="Insteon-MQTT + Home Assistant" width="2206" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/MQTTBox.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/MQTTBox.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/MQTTBox.png 1600w, https://jordanrounds.com/content/images/2020/06/MQTTBox.png 2206w" sizes="(min-width: 720px) 720px"><figcaption>MQTTBox</figcaption></figure><p>Once you are subscribed to your topic using the correct address of your device you should start to see messages coming through when you turn it on or off. If you aren't seeing messages coming through, be sure to double check the address of your device is correctly entered in the <em>insteon_mqtt.yaml</em> file, and in the topic you are subscribed to. </p><p>Additionally its always worth checking in on the logs from insteon-mqtt. They are extremely verbose and helpful.</p><pre><code class="language-command line">docker-compose logs</code></pre><h2 id="adding-to-home-assistant">Adding to Home Assistant</h2><p>Finally we need to add these devices into Home Assistant using MQTT Templates. Luckily there are very clear examples inside the insteon_mqtt.yaml file. Under the MQTT sections of each device type you will find examples and instructions for adding them to Home Assistant. We will be using the Dimmer as our example.</p><pre><code class="language-yaml">light:
  - platform: mqtt
    schema: json
    name: "insteon 1"
    state_topic: "insteon/aa.bb.cc/state"
    command_topic: "insteon/aa.bb.cc/level"
    brightness: true</code></pre><h2 id="so-what-now">So what now?</h2><p>At this point we've successfully gotten an Insteon dimmer to communicate over MQTT and be integrated into Home Assistant. You can now automate and interact with that switch like any other dimmer that would have been added over Z-Wave or some other protocol. </p><p>I didn't end up stoping at this point though. In my old setup with Indigo, my Insteon dimmers controlled my Hue bulbs, and the Hue bulbs would update the state of the LED on the dimmers to reflect their brightness. </p><p>Soon I'll walk through what that process looked like and explain the different approaches I took until finally settling on Node Red being how I managed the automation.</p>]]></content:encoded></item><item><title><![CDATA[DNSimple + Lets Encrypt + NGINX in Docker for Home Assistant]]></title><description><![CDATA[Using NGINX and Lets Encrypt with the DNSimple Plugin to create a reverse proxy in Docker for Home Assistant.]]></description><link>https://jordanrounds.com/home-assistant-nginx-lets-encrypt-in-docker/</link><guid isPermaLink="false">5ef6181f6239532b6113e23a</guid><category><![CDATA[DNS]]></category><category><![CDATA[Nginx]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Home Assistant]]></category><category><![CDATA[Hassio]]></category><category><![CDATA[Docker Compose]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Sun, 19 Apr 2020 16:27:00 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/06/banner.png" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/06/banner.png" alt="DNSimple + Lets Encrypt + NGINX in Docker for Home Assistant"><p>If you start looking around the internet there are tons of different articles about getting this setup. They all vary in complexity and at times get a bit confusing. I’ve gone down this path before without Docker setting up an Ubuntu instance on Digital Ocean and installing everything from scratch. It was a complete nightmare, but after many many hours or days I was able to get it working. Once I started to understand Docker and had everything running locally at home it seemed like it would be a much easier to maintain there.</p><p>I ditched my Digital Ocean droplet and started researching how to do this in Docker on my home server. There was one requirement, which was I need a container that supported the <a href="https://certbot-dns-dnsimple.readthedocs.io/en/stable/" rel="noopener nofollow">DNSimple DNS plugin</a> since I host my sites through <a href="https://dnsimple.com/r/1c01efec46ca9d" rel="noopener nofollow">DNSimple</a>. It turns out there is an absolutely beautiful container linuxserver/letsencrypt that does everything I needed. It supports all the various plugins for certbot.</p><h2 id="prerequisites">Prerequisites</h2><p>The first thing I did was add an A record with the actual domain (example-domain.com), and a wildcard subdomain (*.example-domain.com) to DNS and pointed it at my home ip. I then forwarded ports 80 and 443 to my home server.</p><h2 id="docker-compose-yaml">docker-compose.yaml</h2><p>Below is the Docker Compose file I setup. Its pretty much copy and paste from their example. The main things to point out are: <code>SUBDOMAINS=wildcard</code>, <code>VALIDATION=dns</code>, and <code>DNSPLUGIN=dnsimple</code>.</p><pre><code class="language-yaml">version: "3.7"
services:
  letsencrypt:
    image: linuxserver/letsencrypt
    container_name: nginx-letsencrypt
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles
      - URL=yourdomain.com
      - SUBDOMAINS=wildcard
      - VALIDATION=dns
      - DNSPLUGIN=dnsimple 
      - EMAIL=name@email.com
    volumes:
      -  config:/config
    ports:
      - 443:443
      - 80:80 #optional
    restart: unless-stopped
volumes:
  config:
    name: nginx_letsencrypt
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/nginx/config</code></pre><p>Once that’s saved, you just need to run <code>docker-compose up -d</code></p><h2 id="dnsimple-configuration">DNSimple Configuration</h2><p>After the container is running you’ll need to go modify the configuration for the DNSimple plugin and put your token in there. To get this token you’ll need to go to your DNSimple Account page and click the Automation tab on the left. Then under API Tokens you’ll click the new button, give it a name, and copy the token.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/dnsimple-api-tokens.png" class="kg-image" alt="DNSimple + Lets Encrypt + NGINX in Docker for Home Assistant" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/dnsimple-api-tokens.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/dnsimple-api-tokens.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/dnsimple-api-tokens.png 1600w, https://jordanrounds.com/content/images/2020/06/dnsimple-api-tokens.png 2272w" sizes="(min-width: 720px) 720px"></figure><p>Now that you have the token your going to navigate to <code>config/dns-conf/dnsimple.ini</code> which is wherever you pointed your volume to and paste that token in replacing the default one thats in there. Once you’ve saved that file you can then restart the container with <code>docker-compose restart</code> At this point you should now be able to navigate to your url and will be presented with the default page.</p><h2 id="nginx-subdomain-config">NGINX Subdomain Config</h2><p>Next thing I did was configure a subdomain to point to my Home Assistant install. I used the default example that they provide in the documentation for the container and also this <a href="https://blog.linuxserver.io/2019/04/25/letsencrypt-nginx-starter-guide/" rel="noopener nofollow">post</a> with a few minor changes/additions.</p><pre><code>server{
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name ha.*;

  include /config/nginx/ssl.conf;

  client_max_body_size 0;

  location / {
    include /config/nginx/proxy.conf;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    resolver 127.0.0.11 valid=30s;
    set $upstream your.ip.here:8123;
    proxy_pass http://$upstream;
  }
}</code></pre><p>I’ll call out the key changes that I made. For <code>server_name</code> you can enter your <code>subdomain.*</code>. Next you’ll need to add <code>proxy_set_header Upgrade $http_upgrade;</code> and <code>proxy_set_header Connection “upgrade”;</code>. Then finally you’ll need to change <code>your.ip.here</code> to be the internal IP of the machine hosting Home Assistant. Once this is all setup the final thing left to do is run <code>docker-compose restart</code> and you should be up and running.</p><h2 id="but-my-ip-is-dynamic-and-changes">But my IP is dynamic and changes</h2><p>Your home IP is most likely dynamic and could change at anytime. Obviously this will cause issues, and everything we’ve setup will break since that A record will no longer point to the correct place. DNSimple provides an easy solution to this problem. They provide a <a href="https://developer.dnsimple.com/ddns/" rel="noopener nofollow">shell script</a> for updating DNS with your current IP using the same token approach that the dns plugin for DNSimple that Certbot uses.</p><pre><code class="language-sh">#!/bin/bash

TOKEN="your-oauth-token"  # The API v2 OAuth token
ACCOUNT_ID="12345"        # Replace with your account ID
ZONE_ID="yourdomain.com"  # The zone ID is the name of the zone (or domain)
RECORD_ID="1234567"       # Replace with the Record ID
IP=`curl --ipv4 -s http://icanhazip.com/`

curl -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -X "PATCH" \
     -i "https://api.dnsimple.com/v2/$ACCOUNT_ID/zones/$ZONE_ID/records/$RECORD_ID" \
     -d "{\"content\":\"$IP\"}"</code></pre><p>For <code>TOKEN</code> it’s the same process as before. I’m pretty sure you can use the same one generated previously, but I chose to generate a new one. The <code>ACCOUNT_ID</code> I grabbed from the URL when logged into DNSimple. <code>ZONE_ID</code> is obviously the domain being updated. The <code>RECORD_ID</code> I found by clicking on edit for a DNS record, and then pulling the ID from the URL.</p><h2 id="automate-the-script">Automate the Script</h2><p>Once I got that script sorted out, I needed a way to get it to run regularly to make sure the IP was up to date. I opted for creating a Docker container with this being its sole responsibility. Obviously this could just be a cron job you ran on the machine, but what fun would that be?</p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">version: '3.7'
services:
  alpine:
    build: .
    container_name: "dnsimple-dyndns"
    environment:
      - TZ=America/Los_Angeles
    image: "dnsimple-dyndns"
    restart: unless-stopped</code></pre><figcaption>docker-compose.yaml</figcaption></figure><figure class="kg-card kg-code-card"><pre><code class="language-Dockerfile">FROM alpine:3.11
RUN apk add curl
COPY example.dyndns.update-dns /etc/periodic/15min/dnsimple-updatedns
CMD crond -l 2 -f</code></pre><figcaption>Dockerfile</figcaption></figure><figure class="kg-card kg-code-card"><pre><code class="language-sh">#!/bin/sh

TOKEN="your-token"  # The API v2 OAuth token
ACCOUNT_ID="your-account-id"        # Replace with your account ID
ZONE_ID="example.com"  # The zone ID is the name of the zone (or domain)
RECORD_ID="your-record-id"       # Replace with the Record ID
IP=`curl --ipv4 -s http://icanhazip.com/`

curl -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -X "PATCH" \
     -i "https://api.dnsimple.com/v2/$ACCOUNT_ID/zones/$ZONE_ID/records/$RECORD_ID" \
     -d "{\"content\":\"$IP\"}"</code></pre><figcaption>update-dns</figcaption></figure><p>I created the Dockerfile from <code>alpine:3.11</code>. I installed curl so that the script could execute the command. Under <code>/etc/periodic/15min</code> you can drop any scripts you want run and cron will kick them off. I copied the script in there, and then finally need the container to run the command <code>crond -l 2 -f</code>. Thats really all there is to it, so all that was left was to run <code>docker-compose build</code> and then <code>docker-compose up -d</code> and its up and running.</p>]]></content:encoded></item><item><title><![CDATA[Smart Home Docker Setup]]></title><description><![CDATA[<p>Previously I wrote about setting up Home Assistant running in Docker along with Portainer to provide a GUI for management. Since then I’ve spent a fair amount of time coming up with a setup that is something I’m comfortable with and feel is able to be easily maintained.</p>]]></description><link>https://jordanrounds.com/smart-home-docker-setup/</link><guid isPermaLink="false">5ef61c6e6239532b6113e286</guid><category><![CDATA[Docker]]></category><category><![CDATA[Docker Compose]]></category><category><![CDATA[Mqtt]]></category><category><![CDATA[Mosquitto]]></category><category><![CDATA[Smart Home]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Sun, 19 Apr 2020 15:02:00 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/06/docker-logo.png" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/06/docker-logo.png" alt="Smart Home Docker Setup"><p>Previously I wrote about setting up Home Assistant running in Docker along with Portainer to provide a GUI for management. Since then I’ve spent a fair amount of time coming up with a setup that is something I’m comfortable with and feel is able to be easily maintained. I’m assuming that I’ve gone through a lot of steps that are similar to what others have.</p><p>I got up and running with simple <code>docker run</code> <a href="https://docs.docker.com/engine/reference/run/" rel="noopener nofollow">commands</a> that were cobbled together from random posts and examples across the internet. I would run the container with its various command line options and tweaking until it worked. Once I got something solid I would copy that into some of my notes so I had it for later. This whole process felt disorganized and likely to end up in a sad failure when I tried to come back to any of it months later when I would have inevitably forgotten how and why I had done anything.</p><p>I then realized that there was <code>docker-compose</code> which initially was quite confusing. Reading the documentation made it seem like it was meant for managing multiple container docker applications, but I only needed one container and initially thought this was an issue. Turns out just because it can support multiple doesn’t mean you cant just run one container. <a href="https://docs.docker.com/compose/compose-file/" rel="noopener nofollow">Docker Compose</a> files provided a so much nicer and organized approach to setting up the configuration and running a container.</p><h2 id="where-i-stored-all-of-my-docker-stuff">Where I stored all of my Docker stuff</h2><p>In <code>/home/docker</code> is what I settled on. Within that directory I created a new directory for each of my containers, and their associated mounts, configs, etc. This ended up looking similar to:</p><figure class="kg-card kg-code-card"><pre><code>/home
   |__ /docker
         |__ /mosquitto
               |__ /config
               |__ /log
               |__ /data
         |__ /portainer
         |__ /samba  </code></pre><figcaption>Docker directory structure</figcaption></figure><p>This seemed easy to wrap my head around, find my data, and navigate.</p><h2 id="docker-run-vs-docker-compose-up">docker run vs. docker-compose up</h2><p>Heres and example of the docker run command to bring up my mosquitto container.</p><pre><code class="language-command line">sudo docker run -it --name mosquitto -p 1883:1883 -p 9001:9001 -v /home/docker/mosquitto:/mosquitto/config -v /home/docker/mosquitto/data:/mosquitto/data -v /home/docker/mosquitto/log:/mosquitto/log eclipse-mosquitto</code></pre><p>Now compare that to what it looks like in a docker compose file.</p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">version: '3.7'
services:
  mosquitto:
    container_name: "mosquitto"
    image: "eclipse-mosquitto"
    restart: unless-stopped
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - "./config:/mosquitto/config"
      - "./log:/mosquitto/log"
      - "./data:/mosquitto/data"</code></pre><figcaption>docker-compose.yaml</figcaption></figure><p>Both of these are doing the same thing, but obviously the Docker Compose file is far easier to read.</p><h2 id="understanding-volumes">Understanding Volumes</h2><p>So now that I’ve settled on using Docker Compose and it appealing to my need for organization the next step was figuring out what all those -v or volume options actually meant. Since it was just copy paste to start I had no idea what was going on. Realistically it was creating those directories local to where I ran docker compose and persisting the data on the host’s file system. This seemed great at first but requires that that directory structure had to be the same if you were to move the containers to a different host, which is less than ideal.</p><p>It turns out if you don’t declare them Docker takes care of it for you and just creates its own. This led to me to start understanding what <a href="https://docs.docker.com/storage/volumes/" rel="noopener nofollow">volumes</a> were in Docker, which you can find in:</p><pre><code>/var/lib/docker/volumes</code></pre><p>Docker will just give them random names and create them. You also have the option of specifying a volume and giving it your own name, which can also be done in the Docker Compose file.</p><pre><code>volumes:
   data_vol:      
      name: my-named-volume</code></pre><p>Doing this will give you named volumes managed by Docker. This seemed like a solid solution, except that everything is then located in <code>/var/lib/docker/volumes</code> It was pretty annoying bouncing over to that directory to change config files, and then back to <code>/home/docker/</code>. This felt like the “right” thing to do, and the proper Docker pattern to follow, but I didn’t like it.</p><h2 id="introducing-local-persist">Introducing local-persist</h2><p>I was talking with a friend and he told me he had found this Docker volume plugin called <a href="https://github.com/MatchbookLab/local-persist" rel="noopener nofollow">local-persist</a>. This changed things up quite a bit. I was now able to persist data in a local directory but still have named volumes. The real kicker was that I felt like I still doing things the “right” way. I now had the ability to persist data locally and maintain named volumes. If I removed the volume my data lived on. If I wanted to point those volumes at an external source like my NAS, I now had that option. That original <a href="https://hub.docker.com/_/eclipse-mosquitto" rel="noopener nofollow">Mosquitto</a> Docker Compose file now turned into this:</p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">version: '3.7'
services:
  mosquitto:
    container_name: "mosquitto"
    environment:
      - TZ=America/Los_Angeles
    image: "eclipse-mosquitto"
    restart: unless-stopped
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - "config:/mosquitto/config"
      - "log:/mosquitto/log"
      - "data:/mosquitto/data"
volumes:
  config:
    name: mosquitto_config
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/mosquitto/config
  log:
    name: mosquitto_log
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/mosquitto/log
  data:
    name: mosquitto_data
    driver: local-persist
    driver_opts:
      mountpoint: ${LOCAL_PERSIST}/mosquitto/data</code></pre><figcaption>docker-compose.yaml</figcaption></figure><p>That <code>$LOCAL_PERSIST</code> environmental variable is set in <code>/etc/environment</code> to <code>LOCAL_PERSIST=”/home/docker/.local-persist”</code>. This made it easy for me to use it across multiple Docker Compose files.</p><h2 id="in-conclusion">In Conclusion</h2><p>I now feel like I have a pattern of setting up Docker containers using Docker Compose using the local-persist plugin that makes me feel like I’m in control and have something I can easily maintain and move around if I chose to. Everything I have talked about here was learned over the course of a couple weeks and is just my opinion. It’d be great to hear from others what their approach is.</p>]]></content:encoded></item><item><title><![CDATA[Intel NUC + Home Assistant Supervised]]></title><description><![CDATA[<p>I’ve been running Home Assistant on a Raspberry Pi 4 for around 7 months or so, and have been very happy with it. That being said there were things that were a bit frustrating, such as slow reboot times, and the constant fear of killing the micro SD card.</p>]]></description><link>https://jordanrounds.com/intel-nuc-home-assistant-supervised/</link><guid isPermaLink="false">5ef535a66239532b6113e124</guid><category><![CDATA[Home Assistant]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Smart Home]]></category><category><![CDATA[Hassio]]></category><category><![CDATA[NUC]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Wed, 08 Apr 2020 16:24:00 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/06/IMG_6327-1.jpeg" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/06/IMG_6327-1.jpeg" alt="Intel NUC + Home Assistant Supervised"><p>I’ve been running Home Assistant on a Raspberry Pi 4 for around 7 months or so, and have been very happy with it. That being said there were things that were a bit frustrating, such as slow reboot times, and the constant fear of killing the micro SD card. A friend of mine moved his setup over to a NUC (mini pc or whatever it’s called) and had nothing but great things to say, so I decided to make the move.</p><p>I’m going to walk through the steps I took to build and setup the NUC, enable SSH, install Docker and Portainer, and finally get Home Assistant running. I opted for Home Assistant <a href="https://github.com/home-assistant/supervised-installer">Supervised</a> <a href="https://www.home-assistant.io/blog/2020/01/29/changing-the-home-assistant-brand/">(formerly Hassio)</a>, not Home Assistant Core, so that I would continue to have the ease of updates, and add ons that I’ve become accustomed to.</p><h2 id="putting-together-the-nuc">Putting together the NUC</h2><p>I went around in circles trying to figure out what hardware to buy. Do I want an i3, i5, or i7? Should I get an 10th, 8th, or older generation? Should I just go with the <a href="https://www.amazon.com/dp/B07DKNPPHZ/ref=cm_sw_r_cp_api_i_J.AyEbFP7WV8H">same machine</a> my friend used? At the end of the day I decided to get some current powerful hardware that would allow for me to easily run Home Assistant and any other number of services I might want, as well as just have a more future proof machine to mess with. Heres the hardware I ended up choosing:</p><!--kg-card-begin: markdown--><ul>
<li><a href="https://www.amazon.com/gp/product/B08357VWB2">Intel Nuc 10 (NUC10i7FNH1)</a></li>
<li><a href="https://www.amazon.com/gp/product/B01N2VUOBJ">Kingston HyperX Impact 16GB Memory</a></li>
<li><a href="https://www.amazon.com/gp/product/B07M7Q21N7">Samsung 970 EVO Plus SSD 500GB — M.2 NVMe</a></li>
</ul>
<!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6309.jpeg" class="kg-image" alt="Intel NUC + Home Assistant Supervised" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6309.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6309.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6309.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6309.jpeg 2400w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6311-1.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6311-1.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6311-1.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6311-1.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6311-1.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6312-1.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6312-1.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6312-1.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6312-1.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6312-1.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6313-1.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6313-1.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6313-1.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6313-1.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6313-1.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>First we need to flip the NUC over and remove the 4 screws that hold the cover on, and gently pull the cover off.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6314-1.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6314-1.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6314-1.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6314-1.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6314-1.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6316-1.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6316-1.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6316-1.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6316-1.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6316-1.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Next we can install the ssd drive. To do this we will remove the screw back by the usb ports on the rear. Once the screw is out you can slide the ssd drive in and tighten the screw back down.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6317.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6317.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6317.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6317.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6317.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6320.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6320.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6320.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6320.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6320.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6322.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6322.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6322.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6322.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6322.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Finally we need to install the Memory. Just slide each module in with the top angled up and then gently push down until it snaps in.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6325.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6325.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6325.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6325.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6325.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6327.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6327.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6327.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6327.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6327.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>At this point all thats left to do is screw the cover back on, and plug in the power, monitor, and keyboard.</p><h2 id="updating-the-bios">Updating the BIOS</h2><p>Since we are starting fresh I figured it wouldn’t hurt to update the bios to the latest version. Obviously this can fail and the whole thing could be bricked, but I was feeling lucky enough. (this step could be skipped)</p><p>To start with go to the <a href="https://downloadcenter.intel.com/search?keyword=bios+aptio" rel="noopener nofollow">intel download center</a>. Change the operating system to OS Independent and look for the bios for your model of NUC. In this case mine was <a href="https://downloadcenter.intel.com/download/29458/BIOS-Update-FNCML357-" rel="noopener nofollow">BIOS Update [FNCML357]</a>.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.03.12-PM.png" class="kg-image" alt="Intel NUC + Home Assistant Supervised" width="2194" height="2196" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-04-at-2.03.12-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-04-at-2.03.12-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-04-at-2.03.12-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.03.12-PM.png 2194w" sizes="(min-width: 720px) 720px"></figure><p>You’ll want to download the FN0039.cap file. The method we’ll be using to do the update is the power button method. The instructions can be found <a href="https://downloadmirror.intel.com/29458/eng/NUC-AptioV-BIOS-Update-Readme.pdf" rel="noopener nofollow">here</a>, but it’s a pretty straight forward procedure.</p><p>Start off by grabbing a USB drive and it’ll need to be formatted. I used Disk Utility on MacOS and formatted it to MS-DOS (FAT). Once thats done put the .cap file you downloaded on the USB drive.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-1.51.48-PM.png" class="kg-image" alt="Intel NUC + Home Assistant Supervised" width="1850" height="1142" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-04-at-1.51.48-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-04-at-1.51.48-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-04-at-1.51.48-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-1.51.48-PM.png 1850w" sizes="(min-width: 720px) 720px"></figure><p>With the NUC powered off completely insert the USB Drive. Next, you will hold down the power button for 3 seconds after which it will turn red and you can release it.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6331.jpeg" class="kg-image" alt="Intel NUC + Home Assistant Supervised" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6331.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6331.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6331.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6331.jpeg 2400w" sizes="(min-width: 720px) 720px"></figure><p>The NUC will then boot and you’ll be presented with a screen of different options. You’ll want to pick “Update Bios” and therefore can press F7 on the keyboard. Next you’ll be presented with a screen to choose the flash drive, then the .cap file. You’ll see instructions for navigating the screens at the bottom.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6333.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6333.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6333.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6333.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6333.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6334.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6334.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6334.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6334.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6334.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6335.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6335.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6335.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6335.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6335.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Eventually you’ll make it through the screens where it’ll ask you to confirm the BIOS update, the NUC will reboot, and you will then see the Flash Update screen showing you the progress of the update.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6336.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6336.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6336.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6336.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6336.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6337.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6337.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6337.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6337.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6337.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6338.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6338.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6338.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6338.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6338.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><h2 id="installing-ubuntu-18-04-4">Installing Ubuntu 18.04.4</h2><p>Next we will be downloading ubuntu, imaging a usb drive, and installing the operating system. I opted for the desktop minimal version just to give myself something to mess around with. We will be downloading two things: <a href="https://ubuntu.com/download/desktop" rel="noopener nofollow">Ubuntu</a> and <a href="https://www.balena.io/etcher/" rel="noopener nofollow">Balena Etcher</a>. Once they are both downloaded get Etcher installed and opened up. First you’ll select the image for Ubuntu, next you’ll select the USB drive, and then click flash.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.09.57-PM.png" width="1824" height="1184" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-04-at-2.09.57-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-04-at-2.09.57-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-04-at-2.09.57-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.09.57-PM.png 1824w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.10.11-PM.png" width="1824" height="1184" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-04-at-2.10.11-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-04-at-2.10.11-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-04-at-2.10.11-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.10.11-PM.png 1824w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.10.16-PM.png" width="1824" height="1184" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-04-at-2.10.16-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-04-at-2.10.16-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-04-at-2.10.16-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-04-at-2.10.16-PM.png 1824w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>After Ether is finished you can remove the USB drive from the computer and insert it into the NUC with the power off. Now we will do the same thing we did when updating the BIOS and hold down the power button for 3 seconds and then release it. Next you’ll see the same screen from updating the BIOS but this time you will be pressing F10 which will take you to the boot menu. Choose your USB drive, then at the next screen select “Install Ubuntu.”</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6343.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6343.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6343.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6343.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6343.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/1_wyfeYhCTEIzaJDkOy9FA7A.jpg" width="1000" height="750" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/1_wyfeYhCTEIzaJDkOy9FA7A.jpg 600w, https://jordanrounds.com/content/images/2020/06/1_wyfeYhCTEIzaJDkOy9FA7A.jpg 1000w" sizes="(min-width: 720px) 720px"></div></div></div></figure><p>Now all you’ll have to do is walk through Ubuntu’s installer screens and then we are good to go!</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6348.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6348.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6348.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6348.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6348.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6357-1.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6357-1.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6357-1.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6357-1.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6357-1.jpeg 2400w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/IMG_6358.jpeg" width="4032" height="3024" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_6358.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_6358.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_6358.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_6358.jpeg 2400w" sizes="(min-width: 720px) 720px"></div></div></div></figure><h2 id="enable-ssh">Enable SSH</h2><p>I suppose getting SSH working isn’t completely essential but it sure is handy to be able to sit at a laptop and just ssh into the NUC. Also, it’s also pretty straight forward, so why not?</p><pre><code class="language-command line">sudo apt update
sudo apt install openssh-server
(press y)
sudo systemctl enable ssh
sudo ufw allow ssh
sudo ufw enable</code></pre><p>This should have enabled ssh, and allowed traffic over port 22 through the firewall.</p><h2 id="install-docker">Install Docker</h2><p>I chose to install Docker <a href="https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository" rel="noopener nofollow">using the repository</a> as it’s the recommended method.</p><pre><code class="language-command line">sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common</code></pre><p>Install Docker’s official GPG key and verify the fingerprint <code>(0EBFCD88)</code></p><pre><code class="language-command line">curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88</code></pre><p>Setup the stable repository.</p><pre><code class="language-command line">sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"</code></pre><p>Install Docker Engine</p><pre><code class="language-command line">sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io</code></pre><h2 id="install-portainer">Install Portainer</h2><p>Installing Portainer is not necessary but is extremely useful as it gives you an actual GUI to interact with Docker. If you are new to Docker like me this will be extremely helpful. First you will create a volume for the portainer data and then create the container.</p><pre><code class="language-command line">docker volume create portainer_data
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer</code></pre><p>Once this is complete you can navigate in your browser to the NUC’s IP address port 9000. (ie: 192.168.7.4:9000) From there you will be prompted to create the admin account, then choose the Docker environment you want to manage, which is “Local.” After connecting to local you will be logged in and presented with a screen similar to this:</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-08-at-4.02.19-PM.png" class="kg-image" alt="Intel NUC + Home Assistant Supervised" width="2272" height="1918" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-08-at-4.02.19-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-08-at-4.02.19-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-08-at-4.02.19-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-08-at-4.02.19-PM.png 2272w" sizes="(min-width: 720px) 720px"><figcaption>Portainer Home</figcaption></figure><p>From here you will be able to navigate around to view your containers, volumes, etc.</p><h2 id="installing-home-assistant-finally-">Installing Home Assistant — Finally!</h2><p>So looking around the internet there didn’t seem to be a ton of tutorials installing what was called Hassio in Docker. I found one <a href="https://www.smarthomebeginner.com/install-hass-io-on-docker-linux/" rel="noopener nofollow"><em><em>here</em></em></a> and <a href="https://dew-itwebservices.com.au/installing-and-running-hassio-in-docker-on-an-intel-nuc/" rel="noopener nofollow"><em><em>here</em></em></a>. They are both pretty similar but out of date, since the URL to the repo has changed. The new repo for Home Assistant Supervised lives <a href="https://github.com/home-assistant/supervised-installer" rel="noopener nofollow">here</a>. It took me a while to figure out what changed, what the correct URL was, etc. Because of the name changes I even glazed over the <a href="https://www.home-assistant.io/hassio/installation/#alternative-install-home-assistant-supervised-on-a-generic-linux-host" rel="noopener nofollow">official documentation</a> not realizing it was exactly what I needed. Run the commands listed below and Home Assistant will be installed and running in its various Docker containers.</p><pre><code class="language-command line">sudo su

add-apt-repository universe

apt-get install bash jq curl avahi-daemon dbus software-properties-common apparmor-utils apt-transport-https ca-certificates network-manager socat

systemctl disable ModemManager 

systemctl stop ModemManager

curl -sL https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh | bash -s -- -m intel-nuc -d /home/docker/hassio</code></pre><p>There are two things to call out:</p><ul><li>-m is the machine type (in our case intel-nuc)</li><li>-d is me saying I want the default data storage location</li></ul><p>There are a few other options for the installer that are explained on the Github <a href="https://github.com/home-assistant/supervised-installer" rel="noopener nofollow">page</a>.</p><p>You will then need to navigate to (your-nuc-ip:8123) and you’ll be prompted to setup your user for Home Assitant.</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-08-at-9.47.00-AM.png" width="2272" height="1918" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-08-at-9.47.00-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-08-at-9.47.00-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-08-at-9.47.00-AM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-08-at-9.47.00-AM.png 2272w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-08-at-9.47.22-AM.png" width="2272" height="1918" alt="Intel NUC + Home Assistant Supervised" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-04-08-at-9.47.22-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-04-08-at-9.47.22-AM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2020-04-08-at-9.47.22-AM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-04-08-at-9.47.22-AM.png 2272w" sizes="(min-width: 720px) 720px"></div></div></div></figure><h2 id="in-conclusion">In Conclusion</h2><p>The whole setup process is definitely a bit more complex than installing Home Assistant on a Raspberry Pi, but now that I’m setup on the NUC everything is so much more snappy and I feel like I’m more in control and have options I didn’t know existed. That control definitely comes with quite the learning curve, but if you’re patient and willing to do some reading its totally worth it!</p>]]></content:encoded></item><item><title><![CDATA[Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant]]></title><description><![CDATA[<p>I used a couple Sonoff Basics to automate my Christmas lights this year. I setup a few automations based on how we wanted them to turn on and off. We are going to walk through manually adding a <a href="https://amzn.to/2sY3XNM" rel="noopener nofollow">Sonoff Basic R2</a> flashed with the <a href="https://github.com/arendst/Tasmota" rel="noopener nofollow">Tasmota</a> software without using auto discovery.</p>]]></description><link>https://jordanrounds.com/adding-sonoff-basic-r2-flashed-with-tasmota-to-home-assistant/</link><guid isPermaLink="false">5ef620596239532b6113e2cf</guid><category><![CDATA[Sonoff]]></category><category><![CDATA[Esp8266]]></category><category><![CDATA[Home Assistant]]></category><category><![CDATA[Hassio]]></category><category><![CDATA[Electronics]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Mon, 16 Dec 2019 14:54:00 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/06/config-validation-1.png" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/06/config-validation-1.png" alt="Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant"><p>I used a couple Sonoff Basics to automate my Christmas lights this year. I setup a few automations based on how we wanted them to turn on and off. We are going to walk through manually adding a <a href="https://amzn.to/2sY3XNM" rel="noopener nofollow">Sonoff Basic R2</a> flashed with the <a href="https://github.com/arendst/Tasmota" rel="noopener nofollow">Tasmota</a> software without using auto discovery. Then we will setup a basic automation. If you haven’t already flashed and configured Tasmota you might want to checkout my article about that first.</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://jordanrounds.com/sonoff-basic-r2-tasmota-no-solder/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Sonoff Basic R2 + Tasmota (no solder)</div><div class="kg-bookmark-description">This is a walkthrough of flashing a Sonoff Basic R2 device with the Tasmota
[https://github.com/arendst/Tasmota] firmware so that it can connect to an MQTT
broker. I decided to write this because I wanted an easy way to automate my Christmas
lights through Home Assistant. Doing this for the first t…</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://jordanrounds.com/favicon.ico" alt="Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant"><span class="kg-bookmark-author">Jordan Rounds</span><span class="kg-bookmark-publisher">Jordan Rounds</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4766-1.jpeg" alt="Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant"></div></a></figure><h2 id="switch-template-">Switch Template:</h2><p>The template is pretty straight forward, and you can reference the docs for adding an <a href="https://www.home-assistant.io/integrations/switch.mqtt/" rel="noopener nofollow">MQTT Switch</a> and all the different configuration options that are available. You can copy the template below into <em><em>config/configuration.yaml</em>.</em></p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">switch:  
  - platform: mqtt
    name: "Cord Switch"
    state_topic: "tasmota/stat/cord_switch/RESULT"  
    value_template: "{{ value_json.POWER }}"
    command_topic: "tasmota/cmnd/cord_switch/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    availability_topic: "tasmota/tele/cord_switch/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    qos: 1</code></pre><figcaption>cord_switch.yaml</figcaption></figure><p>This switch template is assuming you used the same topic formatting in my other article. Be sure your topics match what you configured in the Tasmota web ui.</p><h2 id="the-automation">The Automation</h2><p>This automation will turn on the lights in the morning around when I get up, then shut them off again around work. They then come on at night and shut off around bed time.</p><figure class="kg-card kg-code-card"><pre><code class="language-yaml">automation:
  - alias: "Christmas - Off Morning"
    trigger:
      platform: time
      at: "09:00:00"
    action:
      service: switch.turn_off
      entity_id: switch.cord_switch
  - alias: "Christmas - Off Night"
    trigger:
      platform: time
      at: "22:00:00"
    action:
      service: switch.turn_off
      entity_id: switch.cord_switch
  - alias: "Christmas - On Morning"
    trigger:
      platform: time
      at: "05:00:00"
    action:
      service: switch.turn_on
      entity_id: switch.cord_switch
  - alias: "Christmas - On Night"
    trigger:
      platform: time
      at: "17:00:00"
    action:
      service: switch.turn_on
      entity_id: switch.cord_switch</code></pre><figcaption>christmas.yaml</figcaption></figure><p>If you were using this automation for outdoor lights you might want to use the <a href="https://www.home-assistant.io/cookbook/automation_sun/" rel="noopener nofollow">trigger</a> for sunrise and sunset.</p><pre><code class="language-yaml">trigger:
  platform: sun
  event: sunrise</code></pre><h2 id="wrapping-up">Wrapping Up</h2><p>All thats left to do at this point is to check the config, and if there are no errors then restart Home Assistant. In the left nav click on Configuration and then Server Control. You’ll see this screen.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/config-validation.png" class="kg-image" alt="Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant" width="1400" height="1418" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/config-validation.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/config-validation.png 1000w, https://jordanrounds.com/content/images/2020/06/config-validation.png 1400w" sizes="(min-width: 720px) 720px"></figure><p>Once you’re here click the Check Config button and give it a minute. You should see a Configuration valid message. If not you will see errors telling you the lines that have the issue.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/valid.png" class="kg-image" alt="Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant" width="1208" height="576" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/valid.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/valid.png 1000w, https://jordanrounds.com/content/images/2020/06/valid.png 1208w" sizes="(min-width: 720px) 720px"></figure><p>After the configuration is validated, click the restart button down at the bottom to restart Home Assistant.</p><p>Now you’re set to go with some automated Christmas lights.</p>]]></content:encoded></item><item><title><![CDATA[Sonoff Basic R2 + Tasmota (no solder)]]></title><description><![CDATA[<p>This is a walkthrough of flashing a Sonoff Basic R2 device with the <a href="https://github.com/arendst/Tasmota" rel="noopener nofollow">Tasmota</a> firmware so that it can connect to an MQTT broker.</p><p>I decided to write this because I wanted an easy way to automate my Christmas lights through Home Assistant. Doing this for the first time offered</p>]]></description><link>https://jordanrounds.com/sonoff-basic-r2-tasmota-no-solder/</link><guid isPermaLink="false">5ef625846239532b6113e30c</guid><category><![CDATA[Sonoff]]></category><category><![CDATA[Esp8266]]></category><category><![CDATA[Tasmota]]></category><category><![CDATA[Mqtt]]></category><category><![CDATA[Home Assistant]]></category><category><![CDATA[Home Automation]]></category><dc:creator><![CDATA[Jordan Rounds]]></dc:creator><pubDate>Fri, 13 Dec 2019 13:53:00 GMT</pubDate><media:content url="https://jordanrounds.com/content/images/2020/06/IMG_4766-1.jpeg" medium="image"/><content:encoded><![CDATA[<img src="https://jordanrounds.com/content/images/2020/06/IMG_4766-1.jpeg" alt="Sonoff Basic R2 + Tasmota (no solder)"><p>This is a walkthrough of flashing a Sonoff Basic R2 device with the <a href="https://github.com/arendst/Tasmota" rel="noopener nofollow">Tasmota</a> firmware so that it can connect to an MQTT broker.</p><p>I decided to write this because I wanted an easy way to automate my Christmas lights through Home Assistant. Doing this for the first time offered many different paths and the internet is full of a bunch of tutorials. Mainly I wanted to put together a clear end to end of everything needed and how to do it using macOS. All setup and screenshots will be done using macOS Catalina. The one assumption made is that you’ve already got an MQTT broker setup.</p><h3 id="hardware-used-">Hardware used:</h3><p><a href="https://amzn.to/2P9lQlG" rel="noopener nofollow">USB Serial Adapter</a></p><p><a href="https://amzn.to/2LXk6Kj" rel="noopener nofollow">Jumper Wires</a> or <a href="https://amzn.to/34a059s" rel="noopener nofollow">Header Pins</a></p><p><a href="https://amzn.to/2sY3XNM" rel="noopener nofollow">Sonoff Basic R2</a></p><h3 id="software-used-">Software used:</h3><p><a href="https://github.com/marcelstoer/nodemcu-pyflasher" rel="noopener nofollow">NodeMCU PyFlasher</a></p><p><a href="https://www.ftdichip.com/Drivers/VCP.htm" rel="noopener nofollow">FTDI VCP Drivers</a></p><p><a href="https://github.com/arendst/Tasmota/releases" rel="noopener nofollow">tasmota.bin</a></p><p><a href="http://workswithweb.com/mqttbox.html" rel="noopener nofollow">MQTTBox</a></p><h2 id="start-with-the-software">Start with the Software</h2><h3 id="download-tasmota">Download Tasmota</h3><p>You can download the latest version of Tasmota from the <a href="https://github.com/arendst/Tasmota/releases" rel="noopener nofollow">releases page</a> on Github. The current version as of writing this is <a href="https://github.com/arendst/Tasmota/releases/tag/v7.1.2" rel="noopener nofollow">v7.1.2</a>. Scroll down through the list and download the file named tasmota.bin towards the end of the list of files.</p><p><em><em>Note: There are others you can use most of which are in various different languages. An explanation of the different versions is on the release page if you are interested. Once downloaded set that to the side for now.</em></em></p><h3 id="let-s-download-and-install-pyflasher-">Let’s download and install PyFlasher.</h3><p><a href="https://github.com/marcelstoer/nodemcu-pyflasher/releases" rel="noopener nofollow">Here</a> you will find the releases page on Github. Go ahead and grab the latest release, which currently is <a href="https://github.com/marcelstoer/nodemcu-pyflasher/releases/tag/v4.0" rel="noopener nofollow">V4.0</a>.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-10-at-5.17.05-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1544" height="1068" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-10-at-5.17.05-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-10-at-5.17.05-PM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-10-at-5.17.05-PM.png 1544w" sizes="(min-width: 720px) 720px"><figcaption>Drag, Drop, Done!</figcaption></figure><h2 id="next-download-the-driver-for-the-usb-serial-adapter-from-ftdi-">Next download the <a href="https://www.ftdichip.com/Drivers/VCP.htm" rel="noopener nofollow">driver</a> for the USB Serial Adapter from FTDI.</h2><p>Be sure to pick the right one for the operating system you are on. Installing this on macOS is fairly straight forward with one gotcha. If you're installing the latest Mac driver, its actually signed by Apple.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-06-26-at-9.53.47-AM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1464" height="1100" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2020-06-26-at-9.53.47-AM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2020-06-26-at-9.53.47-AM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2020-06-26-at-9.53.47-AM.png 1464w" sizes="(min-width: 720px) 720px"></figure><h2 id="moving-on-to-prepping-the-sonoff-r2">Moving on to prepping the Sonoff R2</h2><h3 id="rip-everything-apart-">Rip everything apart!</h3><p>First step is to take the caps off the left and the right side of the R2. Then you are going to push the back plastic through the openings on the left and right to detach the top from the bottom.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4765.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4765.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4765.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4765.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4765.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Step 1: Remove the left and right caps</figcaption></figure><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4766.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4766.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4766.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4766.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4766.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Step 2: Remove the front from the back.</figcaption></figure><p>Once thats all done you will just be needing the board and can set everything else off to the side.</p><h2 id="next-let-s-get-the-usb-to-serial-adapter-ready-">Next let’s get the USB to serial adapter ready.</h2><p>Make sure the little black jumper is connecting the 3v3 pin to the JP pin.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4767.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4767.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4767.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4767.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4767.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Make sure we have the correct voltage set for the Sonoff R2v</figcaption></figure><p>Go ahead and connect your four jumper wires to the remaining pins, which are RXD, TXD, GND, and VCC.</p><p><em><em>Note: If you don’t have jumper wires and want to use the cable that came with the serial adapter, you could alternatively insert some header pins into the female end of that cable and have the same setup as below.</em></em></p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4768.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4768.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4768.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4768.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4768.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Jumper wires connected.</figcaption></figure><p>Through the back of the board insert the jumper wire pins into the appropriate holes. They are as follows from the serial adapter to the R2 board.</p><ul><li>GNG → GND</li><li>VCC → 3V3</li><li>TXD → RX</li><li>RXD → TX</li></ul><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4771-2.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4771-2.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4771-2.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4771-2.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4771-2.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Jumper wires through the back of the board.</figcaption></figure><p><br>If you have the serial adapter plugged in you should see the R2 start to light up and flash green. Now turn the board over and let it rest on the jumper wires.</p><h2 id="flashing-time-">Flashing time!</h2><h3 id="get-the-r2-into-programming-mode-">Get the R2 into programming mode.</h3><p>Everything is now set to begin flashing the board.</p><ol><li>Unplug the serial adapter.</li><li>Hold down the tall black button.</li><li>Plug in the serial adapter.</li><li>Release the button.</li></ol><p>The ESP8266 chip on the R2 board will now be in programming mode.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4772.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4772.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4772.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4772.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4772.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Finger + Button</figcaption></figure><h3 id="flashing-settings">Flashing Settings</h3><p>Open up NodeMCU PyFlasher.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.36.20-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1674" height="1524" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-12.36.20-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-12.36.20-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2019-12-11-at-12.36.20-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.36.20-PM.png 1674w" sizes="(min-width: 720px) 720px"></figure><p>First click the select box for Serial port and look to see that your serial adapter shows up.</p><p><em><em>Note: If it doesn’t show up try pressing the refresh button to the right. If it still doesn’t show up, try restarting your computer to fix the issue.</em></em></p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.36.34-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1166" height="252" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-12.36.34-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-12.36.34-PM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.36.34-PM.png 1166w" sizes="(min-width: 720px) 720px"><figcaption>usbserial-AC01A7BM is our serial adapter</figcaption></figure><p>Click the browse button and select the location where you downloaded tasmota.bin. Next select the following settings.</p><ul><li>Baud rate: 115200</li><li>Flash mode: Dual Output</li><li>Erase flash: yes</li></ul><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.37.24-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1674" height="1524" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-12.37.24-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-12.37.24-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2019-12-11-at-12.37.24-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.37.24-PM.png 1674w" sizes="(min-width: 720px) 720px"><figcaption>All the proper settings</figcaption></figure><p>After you have everything set, click the Flash NodeMCU button and wait until it tells you to restart the R2.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.38.34-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1674" height="1524" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-12.38.34-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-12.38.34-PM.png 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/Screen-Shot-2019-12-11-at-12.38.34-PM.png 1600w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.38.34-PM.png 1674w" sizes="(min-width: 720px) 720px"><figcaption>Success!</figcaption></figure><p>At this point unplug the serial adapter and plug it back in to get the R2 to reboot.</p><h2 id="time-to-configure-tasmota">Time to Configure Tasmota</h2><h3 id="setup-wifi">Setup Wifi</h3><p>Open the wifi settings on your phone. Look for a network being broadcast thats named tasmota-xxxx where xxxx will be some numbers. Tap on that network and you should be prompted with a wifi configuration screen.</p><p>Next you can tap the Scan for wifi networks link and then select your network from the list that shows up or directly enter the ssid into the AP1 SSId field. Then enter your password in the AP1 Password field.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4773.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="369" height="800"></figure><p>Once you have everything entered tap on the Save button and you will see a screen telling you the R2 is restarting and connecting to your network.</p><h3 id="get-the-ip-address">Get the IP Address</h3><p>After the Sonoff R2 restarts and connects to your network you’ll need to get its ip address.</p><p><em><em>Note: This can be done through your router or an ip scanner application. It will show up with a hostname of tasmota-xxxx just as it did when we connected to it through wifi in the previous step.</em></em></p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4776.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="389" height="640"></figure><p>The photo here is an example of what I saw when looking for the newly connected wifi device inside of my Eero App.</p><h3 id="open-tasmota">Open Tasmota</h3><p>In your browser put in the ip address and you will see the main page for your R2.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.42.31-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1424" height="1664" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-12.42.31-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-12.42.31-PM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.42.31-PM.png 1424w" sizes="(min-width: 720px) 720px"></figure><p>Next click on Configuration and then Configure MQTT and you will see a screen like below.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.44.03-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1424" height="1664" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-12.44.03-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-12.44.03-PM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-12.44.03-PM.png 1424w" sizes="(min-width: 720px) 720px"></figure><p>Start by entering in the hostname or ip of your MQTT broker. Optionally a different port, username and password. The topic should be a unique identifier for your R2, so go ahead and change the default of Tasmota to whatever you’d like to name it.</p><p>At this point you could simply save and the Sonoff R2 would now be sending and receiving MQTT messages.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-4.41.37-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1424" height="1664" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-4.41.37-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-4.41.37-PM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-4.41.37-PM.png 1424w" sizes="(min-width: 720px) 720px"><figcaption>Example of my settings</figcaption></figure><p><em><em>Note: I did make the conscious choice to configure my Tasmota flashed devices manually with Home Assistant and not use the auto discovery feature for no other reason that I wanted complete control and the auto discovery scares me. I also added Tasmota to the beginning of the full topic and all future devices I add will use Tasmota as the root of their topics as well.</em></em></p><h3 id="what-will-the-topics-look-like">What will the topics look like?</h3><p>You’ve defined your unique %topic% and the %prefix% will be one of 3 things: cmd, stat, and tele. Cmd is for issuing commands or asking for status. Stat will report back status or configuration messages. Tele will report telemetry info.</p><p>In my case an example topic would be:</p><pre><code>tasmota/stat/sonoff_basic</code></pre><p>The payload might look like:</p><pre><code>{“POWER”:”ON”}</code></pre><p><em><em>Note: I used </em></em><a href="http://workswithweb.com/mqttbox.html" rel="noopener nofollow"><em><em>MQTTBox</em></em></a><em><em> to do my testing.</em></em></p><h3 id="optional-configuration">Optional Configuration</h3><p>I also went into Configuration → Configure Other and changed the Friendly Name to be the same as the Topic name that I configured in MQTT.</p><p>The final thing I did was set the PowerRetain option in the console.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-4.56.11-PM.png" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="1420" height="1664" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/Screen-Shot-2019-12-11-at-4.56.11-PM.png 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/Screen-Shot-2019-12-11-at-4.56.11-PM.png 1000w, https://jordanrounds.com/content/images/2020/06/Screen-Shot-2019-12-11-at-4.56.11-PM.png 1420w" sizes="(min-width: 720px) 720px"></figure><p>From the main menu click on Console. In the input type “PowerRetain ON” and press return. The state of the power messages will now be retained and anytime something such as Home Assistant connects to the broker they will know the last state of the device.</p><h2 id="putting-it-back-together">Putting it Back Together</h2><p>So, I chose to add the R2 to an <a href="https://amzn.to/36yYiMU" rel="noopener nofollow">extension cord</a>, but you could easily do the same thing to add it directly to the cord of anything you want to plug into an outlet. I used an extension cord since this is going to control my Christmas lights and I’d like to reuse it for other things once Christmas is over.</p><p>First go ahead and pop the R2 board back into the plastic enclosure. Set it in the base and snap the top on. The first time I did this I attached the cord before doing this and then realized I had to take the whole thing apart again.</p><p>Next let’s get the extension cord ready. You’ll need a <a href="https://amzn.to/34kN6le" rel="noopener nofollow">wire stripper</a> and a scissors or knife.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4780.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4780.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4780.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4780.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4780.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Supplies</figcaption></figure><p>Start off by cutting the extension cord. I cut mine near the plug and gave it enough length that the R2 will rest on the ground. You can make the cord whatever length you’d like so if you want a 1 foot cord just cut off the excess.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4782.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4782.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4782.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4782.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4782.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Cut and stripped</figcaption></figure><p>Once you have it cut, take a scissors or knife and cut between the two wires about a half inch or so. Then take the wire stripper and strip about 1/4" off. It really doesn’t need to be much.</p><p><em><em>Note: You might be wondering which wire goes in L (load) and which goes in N (neutral). If you look and feel the cord you’ll notice that one side is smooth and one is ribbed or not smooth. The not smooth one will be inserted into N.</em></em></p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/cord-annotated.jpg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/cord-annotated.jpg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/cord-annotated.jpg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/cord-annotated.jpg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/cord-annotated.jpg 2400w" sizes="(min-width: 720px) 720px"></figure><p>Insert the male end or piece of the cord with the actual plug in the end of the R2 that says Input. Then tighten it down with a small flat head screwdriver.</p><p>Ribbed Wire → N</p><p>Smooth Wire → L</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4786.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4786.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4786.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4786.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4786.jpeg 2400w" sizes="(min-width: 720px) 720px"><figcaption>Tight but not too tight.</figcaption></figure><p>Do the same with the other end of the extension cord on the Output side of the R2. Once both parts of the cord are secured put the caps on either side and tighten down the screws included in the box with a small phillips screwdriver.</p><figure class="kg-card kg-image-card"><img src="https://jordanrounds.com/content/images/2020/06/IMG_4787.jpeg" class="kg-image" alt="Sonoff Basic R2 + Tasmota (no solder)" width="4032" height="3024" srcset="https://jordanrounds.com/content/images/size/w600/2020/06/IMG_4787.jpeg 600w, https://jordanrounds.com/content/images/size/w1000/2020/06/IMG_4787.jpeg 1000w, https://jordanrounds.com/content/images/size/w1600/2020/06/IMG_4787.jpeg 1600w, https://jordanrounds.com/content/images/size/w2400/2020/06/IMG_4787.jpeg 2400w" sizes="(min-width: 720px) 720px"></figure><p>Now go plug it in and you are set to go!</p><h1 id="wrapping-up">Wrapping Up</h1><p>These are all the steps for setting up the Sonoff R2 using Tasmota and getting it talking with your MQTT broker. At this point you can integrate and control it however you would like either via its web interface or over MQTT. In another article I’ll show how to manually add these devices to Home Assistant, and setup some basic automations.</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://jordanrounds.com/adding-sonoff-basic-r2-flashed-with-tasmota-to-home-assistant/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant</div><div class="kg-bookmark-description">I used a couple Sonoff Basics to automate my Christmas lights this year. I setup
a few automations based on how we wanted them to turn on and off. We are going
to walk through manually adding a Sonoff Basic R2 [https://amzn.to/2sY3XNM] flashed with the Tasmota [https://github.com/arendst/Tasmota…</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://jordanrounds.com/favicon.ico" alt="Sonoff Basic R2 + Tasmota (no solder)"><span class="kg-bookmark-author">Jordan Rounds</span><span class="kg-bookmark-publisher">Jordan Rounds</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://jordanrounds.com/content/images/2020/06/banner-1.png" alt="Sonoff Basic R2 + Tasmota (no solder)"></div></a></figure>]]></content:encoded></item></channel></rss>