Home Assistant (HA) is an open-source smart home system that allows you to connect your smart home devices like your TV, fan, cameras, thermostats, lights, and sensors to a central server that accepts data feeds from the devices and provides orchestration of automated tasks. As a user, you can build intricate automation using Home Assistant's user-friendly, unified web-based user interface. HA includes a plug-in for MQTT, so it seemed a good candidate to build some dashboards for my observatory operations.
I had been peripherally aware of the MQTT standard for IoT (Internet of Things) but a posting on CloudyNights showing a sophisticated dashboard for an observatory piqued my interest. While the posting was about Windows based ASCOM / NINA data, I knew that indi-allsky, my All Sky Camera (ASC) software, supported MQTT, so I could create dashboards using MQTT that could consume ASC data as well as other data I could produce with my INDI based observatory environment. A project was born!
You can download HomeAssistant as a hard drive image for Oracle Virtualbox, so for development purposes I did so, hoping to transfer the results to a standalone Raspberry Pi 4B for production purposes. I also created a Ubuntu VM running indi-allsky.
When the HA image boots you will see a HomeAssistant console. You generally don’t interact with the console but it tells you where you can access the HomeAssistant web interface. In this case http://homeassistant.local:8123. If for some reason your network doesn’t propagate the zeroconf names for your servers the IP address is fine too.
Accessing this URL takes you to a default dashboard that has a weather forecast on it and nothing else.
We are going to create a new dashboard, but first we need to populate our HA with some data from our indi-allsky ASC. First, install a Mosquitto server in HomeAssistant – click on Settings/Add-ons and search for MQTT. Click on the Mosquitto broker, and Install. This will set up a server in HA to receive data from our ASC software via MQTT.
Under People in HA, all a new person named indi-allsky and set the password. This provides a secure login between indi-allsky and HA. Set the LocalAccess only toggle On.
Under Settings in HA, select Devices and Services then Add Integration. Type MQTT in the search bar then select MQTT. This will add MQTT integration to the server and connect to the plugin.
In the indi-allsky ASC software, there is a configuration screen for MQTT under Config. Click on the Enable MQTT Publishing toggle and add the HA host into the correct field. Set the password field to the password you set for the indi-allsky account in HA. Ensure the port is set to Set the Reload on Save toggle to On and Save.
From a command line enter the following:
cd indi-allsky
source virtualenv/indi-allsky/bin/activate
./misc/home_assistant_auto_discovery.py
This will populate HA with the data available from the ASC software. If you now go to Tools / Log you should see an entry like below to know it’s running.
[INFO] MainProcess-3311/Upload-7 generic.connect() [52]: Connecting to 10.7.10.58 (1883) as indi-allsky with paho_mqtt
Now we can populate a dashboard with our ASC data in HA! If you go to the Overview Dashboard you can see the fields that have been added, including the ASC current image.
Under Settings select Dashboards and Add Dashboard. Select New Dashboard from Scratch. I picked md-telescope as an icon but do what you like!
Open the Dashboard by clicking on the side menu entry for it then the pencil to edit it. Click on the pencil next to the Home tab on the top left of the dashboard, and change the View Type to Sections (experimental). Now you can click on a section, and in the By Card section, choose Picture. Delete whatever is in Image path and add “indi-allsky Camera” to the Image entity. You now have your allsky camera view on your dashboard!
Adding more elements from the indi-allsky MQTT feed is very similar. My initial dashboard is at the top of this article. Next I’ll write some Python to feed telescope and observatory information to the HA dashboard as well. See you next time!
Hey friend! I thought I was the only one who piped his allsky into hass!