Automation – Automation Fixation https://automation.moebius.site A site dedicated to home automation and technologies. Sun, 28 May 2023 07:18:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 156416546 Home Assistant and Apple Watch – Actions and Complications Guide https://automation.moebius.site/home-assistant-and-apple-watch-actions-and-complications-guide/ Thu, 29 Sep 2022 01:21:53 +0000 http://automation.moebius.site/?p=1579

Introduction

In this guide, I’ll be going through how to make the most of the integration between Apple Watch and Home Assistant including Actions and an overview and examples of key complication types for the Apple Watch.

I’m using the new Apple Watch Series 8 and the latest watch OS 9 (as of September 2022).

If you haven’t seen my video on enabling remote access and installing and integrating the iOS app, please check it out first.

For the purposes of the video and to keep it simple, I’m going to be doing all of this via the iOS Home Assistant and Watch Apps and the Apple Watch itself.

Adding an Action

First off, let’s add an Action. Despite the name, an action is a trigger that you can use from your Apple Watch for a Home Assistant automation.

  • From the Home Assistant app on your phone, Go to Settings –> Companion app
  • Then select Actions
  • Tap on the + symbol to add a new action
  • Then select a name, display text, color and icon
  • In this example, the action will be to toggle a switch
  • Keep the name simple as you will need to use this in the next step
  • Name: Light
    • Text: Light Switch
    • And then within the Icon screen, search for an appropriate icon. I’ve searched for the toggle_switch icon.
    • The screen shows a preview of what it will look like and you can also change the background colour
    • Once you have completed this, Save, go back to the previous screen and make sure you click done in the top right to save the settings in the companion app.

Linking Action to Automation

Next we need to link the iOS action we just created, to do perform an actual action. In this example, I will link the action to toggle a switch.

  • Go to Settings –> Automations & Scenes
  • Then create a new automation
    • Event type: ios.action_fired
    • Event data: actionName: “<name of action>”. In my case, we have selected light.
  • Action:
    • Service: switch:toggle
    • Choose Entity. For example, the entity I selected was my Front Door Light Switch
  • Save and select a name for your automation. For example, ‘Watch Light Automation’.

Access Action via Apple Watch

  • To use your actions on your watch, you can access this via the Home Assistant App
  • Simple go to your app screen and find the Home Assistant App
  • The action that was just created should be visible
  • Press it to toggle and fire the automation and press again to turn it off
  • You can see that the switch turned on from the history of the automation

That’s all there is in the Apple Watch Home Assistant App, however another way to quickly access the action is through adding a Home Assistant complication to your watch face and tapping on all complications will open the same actions screen.

Complication Overview

The next functionality with Home Assistant and the Apple Watch is the use of Complications and this definitely can get complicated. Let’s take a quick complication 101.

The term ‘complication’ is historically used for mechanical timepieces and regular watches and refers to additional functionality beyond simple time.

Let’s look at the positioning and examples of an Apple Watch Face. The positioning is important to understand when you build out the complications and configure them into a watch face.

Source: Apple.com

As of the recent watchOS 9 update, a number of complication templates are no longer working. The key complication templates to note that are currently working in the Home Assistant app as of the recent iOS 9 update are:

Circular

These are useful for showing quick round shaped values for ranges and simple status on Infograph and Modular watch faces:

Corner

Corner layouts show images, text and gauges in the corners of supported watch faces such as Infograph:

Inline

The Large Inline layout can be used at the bottom of a watch face such as Utility or Motion. These allow icons and text:

Rectangular

Rectangular layouts show images, text, gauges and titles across a large rectangular region:

As of the most recent iOS update, templates which are now deemed as legacy appear to no longer work in the Home Assistant app and are no longer visible. For those with existing complications, it looks like you have no current option but to re-create using the supported templates until there is a fix. The Home Assistant community has raised a bug which is still being investigated.

The impacted templates include:

  • Circular small
  • Modular Small
  • Modular large
  • Extra Large

I’d recommend avoiding any of these as they will not be visible and you will run into compatibility issues until the app has been updated to either support or remove them.

Template GroupTemplateWorking
Circular SmallCircular SmallNo
Extra LargeExtra LargeNo
GraphicBezel
GraphicCircularYes
GraphicCornerYes
GraphicRectangularYes
ModularLargeNo
ModularSmallNo
UtilitarianLargeYes
UtilitarianSmall
UtilitarianSmall Flat

Complication Limitations

  • Now there are some limitations with Complications including:
    • Automatic updates. Complications only update within a few minutes of 00, 15, 30 and 45 as Apple limits how often they are able to be updated
    • Manual Updates – You can do manual updates, however these are limited to 50 a day. Technically, you can add this as a service call, but it is limited and so complications that you want to refresh frequently might need to be reconsidered until push updates are supported.
  • App Delays – There are also app delays with complications and it takes a bit of time for the complication to reflect and be accessible in the app. You may need to play around and add/remove complications until it is visible in the Watch app. Make sure once you create, click done on the companion section of the Home Assistant app to ensure any updates get saved.

Key Complication Screens

There are three key screens that you need to get familiar with when creating complications. These are the:

  • Complication Management Screen: This is in the Home Assistant Companion App to manage created complications
  • The Face Management part of the Apple Watch app: This is to select the location of complications and build out your watch face
  • The Apple Watch Screen: To view the watch face

Complication Examples

Ok, Let’s go through each key working template using data from Home Assistant. We’ll start with the circular template.

Circular

  • Template: Closed Gauge Image
    • Gauge: {{ iif(is_state(‘switch.front_door_light’, ‘on’), 1, 0 ) }}
      In this example, I have used a binary state for the switch which will be on or off and set the formula to return 1 or 0 to add or remove the ring around the complication.
    • Icon: Light
  • Template: Open Gauge Image
    This template allows a gauge with an icon
    • Centre: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
      I’ve had to add in the formula to convert the status to a float to support the gauge value.
    • Icon: Printer
  • Template: Open Gauge Simple Text
    • Centre: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Bottom: BLK
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
      The difference here to the previous template is that you can use text instead of an icon.
       
  • Template: Open Gauge Range Text
    • Centre: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Leading: 0
    • Trailing: 100
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
      The Range template allows you to specify a different range e.g. if you wanted to show between two different values. In this case, I will still use 0 to 100.

Corner

  • Template: Gauge Text
    • Leading: 0
    • Outer:  {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Trailing: 100
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
    • Style
      • Fill – Shows a line completed up to the value
      • Ring – Shows a filled line with a ring on the value
  • For the corner, the values are similar to the other circular templates that we just went through and so will go through a gauge text example. This includes the leading and trailing values of the gauge with style fill showing the fill line up to the value or ring which shows a circle at the state value along a line.

Rectangular

  • The next template example is the rectangular standard. I’ve added in the Printer Ink header with the two body lines showing black and cyan ink levels
  • Template: Standard Body
    • Header: Printer Ink
    • Body 1: Black: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Body 2: Cyan: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Icon: Printer
  • Template: Text Gauge
    • Header: {{ states(‘sensor.epson_wf_3520_series’) }}
    • Body 1: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }
    • Style
      • Fill Shows a line completed up to the value
      • Ring Shows a filled line with a ring on the value

Inline

  • For the large inline example (Utilitarian Large), I’ll add some extra text to show PRINTER BLACK INK and the state and the % symbol at the end.
  • Template: Flat
  • Centre: PRINTER BLACK INK {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}%
  • Icon: printer

Conclusion

Thanks for getting to the end of this guide. Hopefully you have a better understanding of the Apple Watch integration with Home Assistant and now have some ideas on how to build out your actions and complications based on your own setup.

]]>
1579
Home Assistant with a Ring Doorbell in 2022 https://automation.moebius.site/home-assistant-with-a-ring-doorbell-in-2022/ Sun, 28 Aug 2022 11:07:00 +0000 http://automation.moebius.site/?p=1549 In this post, we will go through in detail how to integrate Home Assistant with a Ring doorbell, add an automation and download videos locally. If you haven’t seen my introduction video for first time users, please check it out as this video follows on directly from there including the Samba and Visual Studio Plugins used in this video.

What you need for this tutorial:

Step 1Adding the Ring Doorbell with Home Assistant

  • Open up your Home Assistant Browser
  • Navigate to Settings and then Device and Services
  • Select Add Integration in the bottom right
  • Search for Ring and select it
Home Assistant Ring Doorbell Tutorial
  • Follow the prompts to enter in the associated account details including 2FA if this has been enabled
  • Select the area where the device is located and then finish. If you need to create an area, select add new area and then add
  • The Ring integration should now be visible in the integration screen
Home Assistant Ring Doorbell Tutorial
  • If you go to the overview screen, the Ring sensors and key values should have been added as a new card
  • From here, you can see the sensors which show if a ding or motion is currently active, and historical details on the last activity, ding or motion. You can also see the volume settings and there are additional values to add such as battery level if you need them.
Home Assistant Ring Doorbell Tutorial
  • If you click on a value, you will be able to see the historical details.

Step 2Adding an Ring Doorbell Automation

Ok, now that we have integrated Home Assistant with the Ring platform, let’s add an automation for when something occurs with the doorbell.

  • Navigate to Settings and then Automations and Scenes
  • Click Create Automation and then Start with an empty automation
  • Let’s call this automation – “Front Door Light Motion” as I want to be able to turn on a switch when there is motion at the door
  • First we need to set up a Trigger to specify when the automation will start
  • Select Trigger type State and then the entity. We are going to select the binary sensor Front Door Motion
  • I will leave the From and To blank so that it switches on when the motion sensor is triggered
Front door light motion triggers
  • Now we need to select an Action, so select Action type call service and then switch turn on and then select the entity. In this case, I’m going to use the Front Door light switch.
Front door light motion actions
  • Once complete, Save the automation and return

Step 3 – Saving the Ring Doorbell Videos Locally

I’ve received a lot of requests on my older Ring video on how to save videos locally. Please note that you will need to have a Ring Plan for this to work.

  • To start, open up your configuration yaml file to add in the downloader module config.
  • Paste the following config and select an appropriate downloads folder:
Configuration.yaml file editing with download module
downloader: 
  download_dir: downloads 
  • Make sure you create also create a downloads folder that matches the config or you will get an error when trying to download
  • Go to Developer Tools and check that the configuration is fine and then restart Home Assistant.
Home Assistant Configuration validation
  • Back now in Settings, select Devices and Services and confirm the camera name so that we can use it in the next automation. e.g. camera.front_door
Ring Doorbell entity name
  • Go back to Settings, select Automations and Scenes
  • Click Create Automation and then Start with an empty automation
  • Let’s name this automation “Download Ring on Motion”
  • The Trigger again will be State and Front Door Motion
Download Ring Video on motion automation
  • You will need to add in a couple of Actions
  • Generally there will be some time required before the video is ready on the Ring Server, so I suggest adding a Delay step.
  • Add in “Wait for Time to Pass” and a 2 minute period to allow time for the video to upload to Ring and then download
  • Now we need a second action to download the file
  • Select “Call Service” and search for downloader
Ring Doorbell automation actions
  • Now click on the extra options to edit in YAML
  • Paste the code and adjust based on your camera name which we confirmed previously. In my case, it is camera.front_door and add in the filename script to name the file with an appropriate timestamp
Ring Doorbell automation Actions
data:
  url: "{{ state_attr('camera.front_door', 'video_url') }}"
  subdir: "{{ state_attr('camera.front_door', 'friendly_name') }}/{{ now().strftime("%m.%Y") }}"
  filename: "{{ now().strftime('%Y-%m-%d-at-%H-%M-%S') }}.mp4"
  • Save the automation and return to the previous screen
  • Trigger the automation to check if it worked
  • Navigate to the downloads directory using the Samba share addon and see if the video worked. This should show the last video recorded by the Ring.
Samba share download screenshot of Ring video
  • If the automation is triggered by actual motion, you will be able to see the history showing that it was triggered by state of Front Door Motion.
Download Ring on Motion History

Thanks for reading. If you liked this article, please like and subscribe to the YouTube video at the start of this page.

Additional Links:

]]>
1549
Home Assistant Beginner’s Guide in 2022 https://automation.moebius.site/beginners-guide-to-home-assistant-in-2022/ Sat, 27 Aug 2022 14:31:59 +0000 http://automation.moebius.site/?p=1518

Home Assistant is an Open source home automation tool that is constantly being updated and enhanced through contributions from a large DIY community. Home Assistant is perfect to run on a Raspberry Pi or a local server to bring together various different technologies for a cohesive ecosystem, create automation and rules and integrate with your smart speaker. This post is a Home Assistant Beginner’s Guide in 2022 and targeted to those who are planning to set up Home Assistant using for the first time and will cover the following topics:

  • Installing Home Assistant – Basic install from scratch on a Raspberry Pi
  • Understanding addons and top recommended Addons – Making use of the community and some of the great addons that are out there
  • Adding devices – Installing an example device for each installation type

Refer to my Instruction video here or follow the detailed instructions below:

What will you need:

  • Raspberry Pi (Model 3 or 4)
  • Power Supply (make sure the power supply is sufficient to avoid stability issues)
  • USB Cable for Raspberry Pi Power
  • > 32GB microSD card
  • Ethernet Cable

Installation

Step 1 – Determine which type of the Home Assistant build is correct for you.

Home Assistant is the program which we will be using and can pretty much be built to work on most key operating systems.

For the purposes of this article, we will be using Home Assistant for the Raspberry Pi.

Step 2 – Determine the correct image

Determine which device to which you will be deploying Home Assistant. For this guide, we will be installing onto a Raspberry Pi 3 Model B and have selected the Raspberry Pi 3 Model B and B+ 32bit image at the following link. You will need to copy the link to use in Step 4.

Home Assistant Beginner's Guide in 2022

Step 3 – Download and install flashing software

You will need software to install the Home Assistant image onto your MicroSD card. Etcher is a good option which is a free, open source software to flash devices.

Home Assistant Beginner's Guide in 2022

Step 4 – Flash Home Assistant image to MicroSD card

Use your preferred software to flash the image URL that you copied in Step 2.

Etcher image installation

Step 6 – Start up the Raspberry Pi

After inserting the MicroSD memory card, connecting Ethernet and power, you will need to wait for the device to initialise.

Step 7 – Connect to your Home Assistant installation

If all has gone well, you should now be able to connect to your Home Assistant installation through your browser. If your router supports mDNS then it will be accessible through http://homeassistant.local:8123 or else you will need to identify the IP address from your router e.g. http://192.168.x.x:8123. If it is not ready, then refresh and wait until you can see the “Preparing Home Assistant” screen.

Preparing Home Assistant

The screen will then automatically change and allow you to configure locale settings and create an initial account and password and confirm any discovered devices.

You should then be presented with the initial overview screen and potentially some devices that have automatically been detected on your network.

Home Assistant overview screen

The left sidebar has useful screens including:

  • Overview: The main screen to configure cards and views for managing and using your automations.
  • Energy: To view smart energy data
  • Map: To view devices sharing location in the Home Assistant App
  • Logbook: To view logs generated for Home Assistant system and linked services and devices
  • History: To view a historical view of logs
  • Media: To manage any configured media devices

Top Addons

Step 8 – Install Samba share add-on

You may already have some devices discovered, however you may need to edit configuration files to add additional devices and sensors. An easy way to do this is to add the Samba share add-on to allow editing outside of the browser. To do this:

  • Go to the Settings link in the left-hand side navigation panel
  • Click on Add-ons
  • Click Add-on store button
  • Click/search for Samba share and then Install
Samba share addon
  • Once installed, Click Start
  • Click Edit Config and be sure to enter in a user name and password as Samba share will open your Home Assistant device to the network:
Samba share addon configuration screen
  • Click Save and return to the previous screen.
  • Click Start to enable Samba share

Step 9 – Edit your configuration files

Your configuration files should now be accessible through Windows Explorer e.g. \\homeassistant.local\config or an IP address (same IP as how you reached Home Assistant in the browser):

Configuration files shared folder

The key configuration files are:

  • automations.yaml – Used to specify your automations and the underlying scripts that are executed. These can also be added from within the Home Assistant interface
  • configuration.yaml – The key configuration file which is where you will add your manual components and key configurations
  • scripts.yaml – Used to specify a sequence of actions to be executed by Home Assistant when turned on
  • secrets.yaml – Used to store your user names, passwords, APIs and other sensitive information to avoid disclosing via the configuration.yaml file

Additional Hints:

  • I use Visual Studio Code to edit my files as it helps maintain the strict formatting for the configurations and is free and open source.
Visual Studio editing screen
  • If you make changes to your configuration files, you can run a validation over the files to check if you have made any errors. Go to Developer Tools > Check Configuration.
Check configuration screen

Step 10 – Install Studio Code Server Addon

In the hint noted above, I use a locally installed version of Visual Studio Code, however there are new addons available to edit in-browser with Studio Code. To install, follow these steps:

  • Go to the Settings link in the left-hand side navigation panel
  • Click on Add-ons
  • Click Add-on store button
  • Click/search for Studio Code Server and then Install
  • Once installed, Start the addon
  • Select ‘Show in sidebar’ to make it visible
Studio Code Server tab

  • You will now be able to edit your configuration files from the browser
Studio Code Server configurations

Step 11 – Install MQTT Mosquito Broker

Local MQTT is one of the best options for communicating between devices and Home Assistant. Using MQTT locally will mean that in the event that you have power or internet issues, your devices can still communicate back and forth with Home Assistant. Toinstall, follow these steps:

  • Go to the Settings link in the left-hand side navigation panel
  • Click on Add-ons
  • Click Add-on store button
  • Click/search for MQTT Mosquito Broker and then Install
MQTT Mosquito Broker Addon

Installing MQTT takes a little bit more effort to set up and there are some additional steps.

  • First you should create a separate user account for MQTT and to do this, go to Settings, People and create an account such as mqttuser. You will need to allow the person to login and set an appropriate
  • You will need to select ‘allow login‘ to set a password and can further restrict this to allow log in from the local network.
Add user to Mosquito MQTT broker
  • If you want to lock down the account further, you can remove login ability afterwards and MQTT will still work
  • You now need to Configure the MQTT integration, so navigate to settings, configure button under MQTT
  • Follow the prompts to initialise and then under settings, enter in the mqtt user name and password that was just created
Edit Mosquito MQTT Broker options

Adding Devices

There are a few different ways to add devices including:

  • Automatically Discover
  • Installing Platform integration or Device
  • Manual

There are also different device classifications based on how the device communicates with Home Assistant:

ClassifierDescriptionProsCons
Assumed StateWe are unable to get the state of the device. Best we can do is to assume the state based on our last command.N/AN/A
Cloud PollingIntegration of this device happens via the cloud.Simple integration with cloud provider– Polling the state means that an update might be noticed later.
– Requires an active internet connection.
Cloud PushIntegration of this device happens via the cloud.– Simple integration with cloud provider
– Home Assistant will be notified as soon as a new state is available.
– Requires an active internet connection.
Local PollingOffers direct communication with device. Polling the state means that an update might be noticed later.– Does not require active internet connection
– Limited lag between messaging
– Privacy maintained as used within internal network
– Polling the state means that an update might be noticed later.
– More complex setup for devices generally required
Local PushOffers direct communication with device. Home Assistant will be notified as soon as a new state is available.– Does not require active internet connection
– Limited lag between messaging
– Privacy maintained as used within internal network
– Home Assistant will be notified as soon as a new state is available.
More complex setup for devices generally required
For more information, refer to the Home Assistant Guidance.

Step 12 – Adding an automatically discovered device

  • First of all, go to the “Settings” and “Devices and Services”.
  • Any discovered devices will have a blue heading noting ‘Discovered
Epson Printer discovered by Home Assistant
  • Home Assistant has picked up that I have an Epson printer on my network and shows on the screen.
  • Click Configure to follow the prompts to add the device and location

Step 13 – Adding a device through the UI

Next we will go through how to install a device or platform integration through the user interface.

  • Go back to Settings and “Device and Services”.
  • Select “Add Integration” in the bottom right
Add integration to Home Assistant
  • For this example, I’m going to add my Ring Doorbell
  • Search for the device or platform and select it
Ring integration with Home Assisstant
  • Enter in the associated account details including 2fA if this has been enabled.
  • Select the area where the device is located and then finish. If you need to create an area, select add new area and then add.
  • The Ring integration is now visible in the integration screen.
  • If you go to the overview screen, you can now see the last image on the camera and key details on last ding and motion.
Ring Overview Screen card

If you are interested in more Ring automations and details, check out my Ring integration post.

Step 14 – Adding a device manually

The final type of device is through manually adding it. This may be due to it not being supported or in the case I am about to show you, you want to add it through MQTT.

  • We can use Studio Code Server to edit our configuration files and add in the details.
  • For the example below, I have added in a Tasmota switch which will connect into my MQTT Broker
Ring configuration for downloader module
  • Now that we have updated the configuration file, navigate to the “Developer Tools” screen, use the Check Configuration button to see if the changes we made are valid and then Restart the system.
Home Assistant Beginner's Guide in 2022
  • Once it has restarted, in the Overview switch, I can see my Switch called “Coffee Machine” and I am able to turn it off and on.
Overview screen switch card

Hopefully you learnt something and enjoyed the Home Assistant Beginner’s Guide in 2022! If you haven’t checked out the video at the top of this page, please check it out and like and subscribe to my channel.

Good luck using Home Assistant!

]]>
1518
Connecting a stepper motor to Hassio/Home Assistant using a NodeMCU via MQTT https://automation.moebius.site/connecting-a-stepper-motor-to-hassio-home-assistant-using-a-nodemcu-via-mqtt/ Wed, 11 Sep 2019 13:56:50 +0000 http://automation.moebius.site/?p=304 What you will need (or equivalent):
  • NodeMCU (Banggood has them for $5.18)
  • ULN2003 Driver Board and 28BYJ-48 Stepper Motor (Banggood has them for $3.87)
  • Jumper Wires
  • USB Power to power the NodeMCU
  • Previously set up Home Assistant/Hassio. If you haven’t already seen my initial Hassio setup guide, please visit this link.

Step 1 – Connect your NodeMCU to the driver board and stepper motor

First of all, connect up your NodeMCU to the controller board using the following pin mappings. These are required as the code used below maps to these pins.

Step 2 – Install Arduino software, required libraries and configure

  • Software Install:
  • Board Support:
  • Install Board Support:
    • Install the board to allow additional board support for the NodeMCU. Select Tools –> Board –> Board Manager
    • Once loaded, search for ‘ESP’ and select and install the ‘ESP8266’ board
  • Install Libraries:
    • There are two libraries required for this code, ‘PubSubClient’ and ‘Stepper’
    • Click on Sketch –> Include Library –> Manage Libraries
    • When it has loaded, search for ‘Pubsub’ and select ‘PubSubClient’ and install
    • Then install ‘Stepper’ library by searching for ‘Stepper’ and installing
  • Configure Board:
    • Now you will need to configure the board by selecting board under Tools –> Board and find the ‘NodeMCU 1.0 (ESP-12E Module)’
    • Select the following options:
      • Upload frequency speed of ‘115200’
      • CPU frequency of ’80 MhZ’
      • Flash Size of ‘4M’
    • You shouldn’t need to change the others settings, so leave as default
    • Select the Port once you have plugged the NodeMCU into your computer. In my case it is coming up as ‘COM5’.

Step 3 – Configure Home Assistant MQTT

  • In your Home Assistant configuration.yaml file, make sure you have added in the MQTT component and selected a password
  • You can write the password directly in here or use the secrets file as I’ve done below and leveraged off the existing http_password:
mqtt:
password: !secret http_password

Step 3 – Upload and compile code on NodeMCU

For the code used in this example, I have used the original code from osoyoo.com (http://osoyoo.com/2017/05/17/nodemcu-lesson-16-stepper-motor-mqtt/) and adjusted as required. For a copy of the custom code used, download this file and update the following details:
  • The wifi ‘ssid’ and ‘password’ to your own network
  • The ‘mqtt_server’ to the IP address of your Home Assistant
  • Update the client.subscribe(“chickenDoor”) to the relevant topic. I’ve put ‘chickenDoor’ which is the topic that will be published to via Home Assistant and used in my scripts in the steps below
For noting:
  • ‘userName’ is the default home assistant MQTT username (i.e. ‘homeassistant’) and ‘passWord’ is the one that was selected in the MQTT component in your configuration.yaml file in Step 3
  • ‘clientId’ doesn’t matter for HomeAssistant, so put anything here
  • Changes to the original code:
    • I have added a few additional options such as the clockwise and counterclockwise loop (values 3 and 4), which runs the stepper 72 times. This is the amount I need my stepper to spin for the chicken door to go fully up and down. I’ve also put a delay of 50 so that it gives the motor enough time to think and continues the revolution immediately
    • I’ve also added in another option to turn off the motor (value 0) as the stepper will stay on and stay in place at the end of the cycle unless directed to turn off
    • Some other tweaks to make the Serial monitor show additional details and status

Step 4 – Configure Home Assistant/Hassio Scripts & Automations

  • Now in Home Assistant, I’ve made a few scripts which publish to the ChickDoor topic. These correspond to the values in the code, 1 and 2 for incremental spins and 3 and 4 for longer spins. I’ve also put in the stepper off for a value of 0.
  • I’ve also added a couple of automations to open and close the door. The first one is to close the chicken door at sunset.
  • This uses the sun trigger for when it is sunset and it will call the chicken door close (anticlockwiseloop) script and then turn off the stepper.
Scripts:
stepper_clockwise:
  alias: Chicken Door Step Up
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “1”
stepper_anticlockwise:
  alias: Chicken Door Step Down
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “2”
stepper_clockwiseloop:
  alias: Chicken Door Full Up
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “3”
    – service: script.turn_on
      data:
entity_id: script.stepper_off
stepper_anticlockwiseloop:
  alias: Chicken Door Full Down
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “4”
    – service: script.turn_on
      data:
        entity_id: script.stepper_off
stepper_off:
  alias: Chicken Door Off
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “0”
Sunrise Automation
The following automation is configured to open the chicken door and execute the clockwise loop script when the sun is rising.
Sunset Automation
The following automation is configured to close the chicken door and execute the anticlockwise loop script when the sun is setting. I’ve added a delay because my chickens like to stay out a bit later.

Step 5 – Compile and Upload

  • Just to make sure everything is fine, compile the code by clicking ‘Sketch’ –> ‘Verify/Compile’
  • Once completed, click ‘Upload’ to load the code into the NodeMCU
  • To view the status of the device, click ‘Tools’ –> ‘Serial Monitor’ (do this while it is uploading so that you don’t miss the log when the device starts)
  • If all is well, the Serial Monitor will show ‘Attempting MQTT connection.. connected’.

Step 6 – Test the scripts

  • Execute the scripts that were configured in ‘Step 4’:
  • When executing scripts, the Serial Monitor should show the commands received and action taken:
If everything went well then you should have a working stepper motor. This is a really cheap way to get a stepper motor working and connected to your Home Assistant/Hassio. There will be other uses besides a chicken door (e.g. blinds). Feel free to post here or on my video for any suggestions, feedback or questions.]]>
304
Home Assistant: Cheap and Easy Sprinkler Automation https://automation.moebius.site/hassio-home-assistant-cheap-and-easy-sprinkler-automation/ Wed, 30 Jan 2019 12:10:10 +0000 http://automation.moebius.site/?p=278 What you will need:
  • Sonoff Switch – I’m using the Sonoff Wifi Smart Switch with Tasmota firmware installed. See my video on how to install the switches ($15.57)
  • 24V Solenoid Valve – A quick search on Amazon. will find something similar
  • 24V Power Supply (1A 24W) – This one from Amazon will work
  • Dual end hose connector
  • Optional items
    • Reducer
    • Metal adapters – I bought these from Bunnings ($10.31 x 2)
  • Assumed existing items
    • Existing pump/mains water supply with a tap head
    • Existing Sprinkler System and pipes
Total Cost: $72.01 (or $92.63 with optional parts) If you haven’t already seen my initial Hassio setup guide, please visit this link.

Step 1 – Connect the Hose parts

Note: I’ve tried to keep the connections as simple as possible to avoid failure of connectors and potentially draining your tank or wasting mains water.
  • Add a reducer between the brass tap adapter (optional) and the tap to limit the amount of water coming through and to prevent unnecessary pressure on the connectors
  • Screw the brass top adapters (brass is optional — but recommended to ensure hose parts do not break and waste water) to the tap and the solenoid value
  • Connect the solenoid valve together with the tap using the Dual end hose connector

Step 2 – Connect the power

  • Wire up the power plug adapter to the solenoid cable
  • Plug the Sonoff switch into the power point
  • Plug the power supply in the Sonoff Switch
  • Turn on the power and test that the solenoid valve is working as expected

Step 3 – Ensure everything is water safe

Given that you are working around water, ensure the power supply, switch and power plugs are protected from water. I have taped up the connectors and used a plastic container for the switch and keeping my electric components in my pump’s water safe housing.

Step 4 – Turn on the water supply and power

Turn on the water supply and power and test if the sprinklers are turning on as expected.

Step 5 (Optional) – Install Automations for automatic sprinkler shutoff

If you are as forgetful as I am, you might want to add an automation to automatically shut off the sprinkler after a set period of time. I’ve set the following to turn off the switch after 15 minutes:   That’s all it takes for a simple, cheap automated sprinkler system. If you have any comments or questions, please feel free to leave them below.]]>
278
Hassio/Home Assistant: Integration with Google Home https://automation.moebius.site/hassio-home-assistant-integration-with-google-home/ Tue, 15 Jan 2019 13:20:00 +0000 http://automation.moebius.site/?p=170 This post is to take you through how to integrate your Google Home with your Home Assistant/Hassio. The Home Assistant website has a detailed guide including links at the following link.

If you haven’t already seen my initial Hassio setup guide, please visit this link and video

Step 1 – Enable remote access

This has been covered in a separate post. Click here to follow the directions to enabling remote access.

Step 2 – Create an API Key and linked project

From the Google Cloud API Console you will need to create an API Key. This is required if you want to be able to say “Hey Google, resync my devices” to update any devices added to or removed from Home Assistant.

Click on Create

Select a unique project name and click create. If the project name is not unique, Google will automatically append additional characters.

Step 4 – Create a project in Actions on Google console

Go to Actions on Google console and click add/import to import the project you created in Step 3.

Select the project name and click ‘Import Project’

Click the ‘Home Control’ category and then click ‘Smart Home’

Step 4 – Configure the project

Click ‘Build your action’ and then ‘Add action(s)’

Click ‘Add your first action’

Under the ‘Add fulfilment URL’ add in the following and click done:

Example ‘Add fulfilment URL’

https://xxxxx.duckdns.org:8123/api/google_assistant

Go back to the ‘Overview’ page and click on ‘Setup account linking’.

Keep the account creation as “No, I only want to allow account creation on my website’ and click ‘Next’.

Under ‘Linking type’ enter the following and click ‘Next’

Under Client information enter in:

Example configuration

– Client ID issued by your Actions to Google: https://oauth-redirect.googleusercontent.com/
– Client secret: This can be any value
– Authorization URL: https://xxxxx.duckdns.org:8123/auth/authorize
– Token URL: https://xxxxx.duckdns.org:8123/auth/token

Under ‘Configure your client’, add the following:email

Under ‘Testing instructions’, add anything you want and click ‘Save’

Step 5 – Enable testing for project

Click ‘Simulator’ on the left navigation panel

Click ‘Start testing’ and then click ‘Done’.

The device will now be visible in the Google Home app when attempting to add devices. Do not add the device yet.

Step 6 – Add configuration details into your Home Assistant configuration file

Open up your configuration.yaml file and insert the following configuration:

Example Configuration.yaml entry

google_assistant:
project_id: YOUR_PROJECT_ID
api_key: YOUR_API_KEY
exposed_domains:
– switch
– light
– group

Project_id: You should reconfirm the project_id in Actions on Google under Settings cog > Project settings > Project ID. This may be different to the original name you selected as Google will add additional characters if it is not unique.

api_key: Back in the Google Cloud API Console, click on the Overview page and then click ‘Enable’ for HomeGraph API

Under ‘Credentials’, click ‘Create credentials’, ‘API key’

Copy and paste the API key generated into your configuration.yaml file (or secrets.yaml file if you are using this).

Rename the key to something logical so you know what it is for e.g. Hassio Key. Then click ‘Save’.

Save your configuration.yaml file and then restart the Home Assistant server from Configuration > General > Restart

Step 7 – Link your Google Home to your Hassio test project

From within the Google Home App, add a new device by click on the “+” symbol for ‘Add’, ‘Set up a device’, then ‘Have something already set up?’.

Your app should now be visible (e.g. [test] my test app)

After clicking on the device, you will be redirected to your Home Assistant login screen. You will need to enter in your user name and password.

If all goes well, you will be automatically returned to the device management screen and your app should now be linked. A message will appear noting ‘[app name] is linked.

You will automatically be redirected to assign rooms to all the newly added devices from hassio.

The device will now show as being linked in the manage accounts section.

You should now be able to control your devices with your Google home app or google home speaker.

]]>
170
Hassio/Home Assistant: Enabling Remote Access https://automation.moebius.site/hassio-enabling-remote-access/ Mon, 14 Jan 2019 13:10:01 +0000 http://automation.moebius.site/?p=99 In order to access your Hass.io instance from outside of your network, you will need to enable remote access. This is also a prerequisite for enabling the Google Home integration. More information is available on the Home Assistant website at this link.

If you haven’t already seen my initial Hassio setup guide, please visit this link.

Step 1 – Install DuckDNS

You will need to install the DuckDNS addon with Let’s Encrypt support to obtain a valid SSL certificate and domain name for encrypted traffic. From within Home Assistant, click on the Hass.io page on the left hand side navigation menu and click on the add-on store.

Find DuckDNS and click install.

Step 2 – Create a token and domain name

Click through to DuckDNS website and select a domain name and generate a token

Step 3 – Update the configuration in the DuckDNS addon

Copy the token and domain name generated and update the configuration in the DuckDNS addon. These details should match exactly as was generated in Step 2. Make sure you have changed the accept_terms to ‘true’.

Example Configuration

{
“lets_encrypt”: {
“accept_terms”: true,
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
},
“token”: “xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“domains”: [
“xxxxxxxx.duckdns.org”
],
“seconds”: 300
}

Step 4 – Update the configuration in the configuration.yaml file

Within the configuration.yaml file, uncomment the http: section and add in the details per the example below:

Example configuration

http:
base_url: https://xxxxxxxxxx.duckdns.org:8123
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem

Step 5 – Forward Port 8123 to Home Assistant

Within your router, you will need to forward port 8123 to your home assistant IP. If you haven’t already made your Home Assistant to have a static IP address, check my initial video for details on how to upload the network configuration via a USB memory stick.

Step 6 – Restart the device

Restart your Home Assistant by going to Configuration > General > Restart.

Step 6 – Connect via the external address

Your Home Assistant instance should now be accessible from the external domain specified in the previous steps. e.g. https://xxxxxxx.duckdns.org:8123

]]>
99
Hassio/Home Assistant: Installing a Sonoff Switch (Tasmota Firmware) https://automation.moebius.site/hassio-installing-a-sonoff-switch-tasmota-firmware/ https://automation.moebius.site/hassio-installing-a-sonoff-switch-tasmota-firmware/#comments Sun, 06 Jan 2019 12:49:45 +0000 http://automation.moebius.site/?p=88 The Sonoff switches that have been flashed with Tasmota Firmware are compatible with Home Assistant/Hassio. The following guide will take you through the steps to install the required components to allow you to use the switches for automations.

What you will need:

If you haven’t already seen my initial Hassio setup guide, please visit this link.

Option 1 – Installing using Wemo Emulation

Step 1 – Enable Belkin Wemo Emulation

Open your Sonoff Switch interface

Navigate to Configuration > Configure Other, select “Belkin WeMo” and click Save.

Step 2 – Restart your device

Restart your device and your switch will automatically be detected by Home Assistant and visible in the Overview page.

Step 2 – Customize the switch name (optional)

You can customize the name through clicking on the device and clicking on the settings cog.

Change the name and click Save.

The new name will now be reflected in the Home Assistant Overview screen.

Option 2 – Installing through MQTT

While this option takes a bit more effort, I’ve found this to be more reliable than the emulation option.

Step 1 – Enable MQTT on the Switch

As per the Option 1 above, navigate to Configuration > Configure Other, ensure that MQTT is selected as enabled and click Save. If you have enabled the emulation above, you can change it back to “None” to avoid duplicate devices detected.

Step 2 – Add MQTT configurations to Home Assistant configuration.yaml file

For each of the switches to be added, add in the details of the MQTT topics that will be used. I have used the following configurations for a device:

configuration.yaml

mqtt:
password: !secret mqtt_password

switch:
– platform: mqtt
name: “sonoff1795”
state_topic: “stat/sonoff-1795/RESULT”
value_template: ‘{{ value_json[“POWER1”] }}’
command_topic: “cmnd/sonoff-1795/POWER1”
availability_topic: “tele/sonoff-1795/LWT”
qos: 1
payload_on: “ON”
payload_off: “OFF”
payload_available: “Online”
payload_not_available: “Offline”
retain: true

Note: Be sure to include your mqtt_password in your secrets.yaml file.

Step 3 – Restart your device

Within Home Assistant, restart under Configuration > General > Restart.

Step 4 – Configure MQTT on the Sonoff Switch

Navigate to your Sonoff switch’s interface and go to Configuration > Configure MQTT. The details here should match what you have put in your configuration.yaml and secrets.yaml file.

Step 5 – Restart your device

Per Step 3. The switch should now be visible within the Home Assistant Overview screen.

Step 6 – Customize the switch name (optional)

Within Home Assistant, navigate to Configuration > Customization and select the newly installed Switch. Edit the name and click Save.

The new name will now be reflected in the Home Assistant Overview screen.

]]>
https://automation.moebius.site/hassio-installing-a-sonoff-switch-tasmota-firmware/feed/ 2 88
Hassio/Home Assistant: Installing a Ring Doorbell and simple automations https://automation.moebius.site/hassio-home-assistant-installing-a-ring-doorbell-and-simple-automations/ Sun, 06 Jan 2019 12:20:35 +0000 http://automation.moebius.site/?p=65 The Ring doorbell system is compatible with Home Assistant/Hassio. The following guide will take you through the steps to install the Ring Doorbell component and sensors to allow you to use the Doorbell for automations.
Additional details are available under the Ring Component page at the Home Assistant website.

What you will need:

  • A Ring Doorbell
  • Lights for automation (optional) – I’m using the Xiaomi Yeelight Ⅱ RGBW 10W 
  • Switch for automation (optional) – I’m using the Sonoff Wifi Smart Switch

If you haven’t already seen my initial Hassio setup guide, please visit this link. Refer to my Instruction video here or follow the detailed instructions below:

Step 1 – Add Ring configurations to your configuration.yaml and secrets.yaml file

Configurations.yaml

Create a new section for all the ring related configurations.
You will likely already have a ‘sensor’ component, and so add the ring platform as a new line underneath.


If you have not already used camera and binary_sensor components, then add new ones. Otherwise, add the ring platform underneath the existing components.

secrets.yaml

Add in your Ring user name and password details.

Step 2 – Restart your device

Restart your device under Configuration > General > Restart

You should now be able to see the various sensors in your Home Assistant Home page.

Step 3 – Add an automation using the Ring Sensors

I’m currently using the following automations for my Ring Doorbell:

  • Doorbell Motion Light – When Motion is detected and it is dark, turn on my front lamp and garage light.
  • Doorbell Motion Light Auto Off – After motion has stopped, wait and then turn off the front lamp and garage light.
  • Doorbell Motion Notification (when light off) – When Motion detected, flash my kitchen light and play a ding on my Google Home.
  • Doorbell Motion Notification (when light on) –
    When Motion detected, flash my kitchen light and play a ding on my Google Home.
  • Doorbell Ring (when light off) – When doorbell rings, flash my kitchen light and play a ding on my Google Home.
  • Doorbell Ring (when light on) – When doorbell rings, flash my kitchen light and play a ding on my Google Home.

Note: I had some issues with lights staying on, so have made two versions for the notifications to ensure if the light was off before, it will stay off.

Doorbell Motion Light

Triggers:

Conditions:

Actions:

Doorbell Motion Light Auto Off

Triggers:

Conditions: N/A
Actions:

Doorbell Motion Notification (when light off)

Triggers:

Conditions:

Actions:

Doorbell Motion Notification (when light on)

Triggers:

Conditions:

Actions:

Doorbell Ring (when light off)

Triggers:

Conditions:

Actions:

Doorbell Ring (when light on)

Triggers:

Conditions:

Actions:

]]>
65
Hassio/Home Assistant: Initial Installation Guide https://automation.moebius.site/hassio-initial-installation-guide/ Sun, 06 Jan 2019 12:08:46 +0000 http://automation.moebius.site/?p=48

Home Assistant is an Open source home automation tool that is constantly being updated and enhanced through contributions from a large DIY community. Home Assistant is perfect to run on a Raspberry Pi or a local server to bring together various different technologies for a cohesive ecosystem, create automation and rules and integrate with your smart speaker.

This article is targeted to those who are planning to set up Home Assistant using Hassio for the first time. Refer to my Instruction video here or follow the detailed instructions below:

What will you need:

Step 1 – Determine which type of the Home Assistant build is correct for you.

Home Assistant is the program which we will be using and can pretty much be built to work on most key operating systems. However, there are a couple of different builds that are available depending on the technology and purpose for automation including:

  • Hass.io – Hass.io aka Hassio is an appliance (locked down) version of Home Assistant and is recommended for beginners.
  • Hassbian – Raspbian Linux flavor, Debian on Pi, preconfigured for HomeAssistant. This is recommended for advanced users or people who wish to do more on their Raspberry Pi.

For the purposes of this article, we will be using Hassio. The Hassio site has a detailed installation instructions within their webpage however, there are a few steps that are unclear which are further explained below.

Step 2 – Determine the correct image

Determine which device to which you will be deploying Hassio. For this guide, we will be installing onto a Raspberry Pi 3 Model B and have selected the Raspberry Pi 3 Model B and B+ 32bit image at the following link. Commence download of the file as it will take some time depending on your download speed.

Step 3 – Download and install flashing software

You will need software to install the Hassio image onto your MicroSD card. I recommend using Etcher which is a free, open source software to flash devices.

Step 4 – Flash Hassio image to MicroSD card

Use your preferred software to flash the image downloaded in Step 2 onto a MicroSD card.

Step 5 – Install the WiFi connectivity instructions

If you are planning to use WiFi on your Hassio build, then you will need to create a file on a USB memory stick and plug it into the Raspberry Pi before you boot it up.

  • Format the USB stick in FAT32 format
  • Create a folder called Network and a file called hassos-wifi within the Network folder (i.e. \network\hassos-wifi).
  • Edit the file and include your network configuration instructions and update the ‘address1’ to align to an IP address that is in the range of your router
  • Some people have noted that saving the file using Notepad is fine, however others have noted that a program such as Notepad++ is required to save the file with encoding as ANSI and line ending to UNIX

I’ve used the following config:

[connection]
id=my-network
uuid=72111c67-4a5d-4d5c-925e-f8ee26efb3c3
type=802-11-wireless
[wifi]
mode=infrastructure
ssid=**SSID Name**
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=**WIFI Password**
[ipv4]
method=manual
address1=192.168.1.190/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;

Where **SSID Name** and **WIFI Password** are your own network details

Step 6 – Start up the Raspberry Pi

After inserting the MicroSD memory card and the USB memory stick, power on your Raspberry Pi and connect to an HDMI monitor if you wish to view the boot up sequence.

Step 7 – Connect to your Hassio installation

If all has gone well, you should now be able to connect to your Hassio installation through your browser. If your router supports mDNS then it will be accessible through http://hassio.local:8123 or if you have used my configuration in Step 5, then it will be accessible through the static IP
http://192.168.1.190:8123.

The Hassio installation may still be setting up and you will see the following “Preparing Hass.io” screen.

Wait a while and then refresh until it is accessible to then allow you to create an initial account with a password.

You should then be presented with the initial state screen and potentially some devices that have automatically been detected on your network.

Step 8 – Install Samba share add-on

You may already have some devices discovered, however you will need to get access to the configuration files to add additional devices and sensors. An easy way to do this is to add the Samba share add-on.

  • Go to the Hass.io link in the left-hand side navigation panel
  • Click Add-on store in the tool-bar
  • Click Samba share and click Install
  • Edit the config and click Save and include the following details:

Config

{
“workgroup”: “WORKGROUP”,
“username”: “*****“,
“password”: “*****“,
“interface”: “wlan0”,
“allow_hosts”: [
“10.0.0.0/8”,
“172.16.0.0/12”,
“192.168.1.0/16”
]
}

Make sure you update the “username” and “password” to your required details and “interface” should be eth0 if you are using ethernet or wlan0 if you are using wifi and allow hosts to be updated to align to the IP range you selected in Step 5.

  • Click Start to enable Samba share
  • If you are having any issues, view the log at the bottom of the screen for more details. The log will say “Waiting for connections” when it is ready to access.

Step 9 – Edit your configuration files

Your configuration files should now be accessible through Windows Explorer e.g. \\192.168.1.190\config (depending on what static IP you selected in the config in Step 5.

The key configuration files are:

  • automations.yaml – Used to specify your automations and the underlying scripts that are executed. These can also be added from within the Hassio interface
  • configuration.yaml – The key configuration file which is where you will add your components and key configurations
  • customize.yaml – Used to add a friendly/custom name to the entity_id for supported entities. This will be updated if you customize names from within the Hassio interface
  • groups.yaml – Used to allow the user to combine multiple entities into one
  • scripts.yaml – Used to specify a sequence of actions to be executed by Home Assistant when turned on
  • secrets.yaml – Used to store your user names, passwords, APIs and other sensitive information to avoid disclosing via the configuration.yaml file

Additional Hints:

  • I use Visual Studio Code to edit my files as it helps maintain the strict formatting for the configurations and is free and open source.
  • If you make changes to your configuration files, you can run a validation over the files to check if you have made any errors. Go to Configuration > General.
  • You can map your network drive for easy access to your configuration files.
]]>
48