Monday 11 April 2022

Home Assistant: adding devices

The story so far is that I have installed Home Assistant (HA) successfully on an RPI4 and I can access the Home Assistant console through a browser session which allows me to configure functions and look at the current status.

HA has helped me by auto-discovering a number of "integrations", which are devices and systems it can interact with.  I have been able to instruct HA to show me the status of my VirginMedia SmartHub on the dashboard.  Google Home (GH) / Assistant have already given me the ability to control a SmartSwitch, RGB colour bulb and Nest Mini Speaker with voice control, so HA has a hard act to follow.

GH is limited in the number of devices it can deal with and the range of functions.  Typically if something is GH enabled and quite new it can be setup easily, otherwise there is nothing you can do.  I would particularly like to be able to play some of my own music, and GH won't play specific tracks or albums without a subscription to premium version of Spotify, YouTube etc.  I am hoping to be able to combine the voice activation functions of GH into HA so that I have the convenience of GH and the extra capabilities of HA combined.

Playing Music

HA was kind enough to discover my DLNA server which runs on a Raspberry Pi.  I mainly use it for watching videos on the TV but it also has access to my shared music.  Clicking on the server card on the integrations page causes it to be configured automatically and added to the default dashboard.  Clicking on the dashboard card allows me to navigate through the music directories and choose a music track (just the one) to play.


 By default, it plays in the browser but I can direct it to play on the Nest Mini speaker instead 😊.   In fact the Google Cast integration which was setup automatically contains the  Nest Mini as the "Office Speaker" entity for me to use.  


Choosing the Office Speaker card on the dashboard also allows me to select music to play.  In addition to the DLNA server I can choose local media, radio browser and Google TTS (text to speech).  Local media simply chooses music from the PC/iPad/phone I am using for HA access.  The radio browser integration provides a load of radio channels from around the world including a comprehensive selection of UK stations.


TTS is quite fun, just type a sentence and it is read out for you - good news I can configure for a British accent.  This may come in very useful as I can send the text to any speaker device.  

I was very pleased that my Pure Jongo JOG and JOB (T4 and A2) speakers show up as DLNA renderers in the integrations list.  This means I can send music, radio or messages to any or all of them.

We are doing very well discovering useful HA facilities, I can now choose music/sounds from a variety of sources and play on a number of different speakers.  These don't yet provide a useful solution but they are essential building blocks.




Adding Switches and Lights and music player

Although the music devices are interesting, I want something I can control automatically using HA.  I have four eWelink sonoff smart switches which I purchased for home automation some time ago and I would like to be able to turn them on and off.  Googling HA + sonoff gives me a guide to configuring sonoff 

The first step is to choose add-on configuration.  I needed to add the eWelink repository and I can then install the eWelink Smart Home app and add eWelink to the HA sidebar.  In the add-on information page for eWelink I can open the web UI and sign on to my eWelink account.

For a technical reason, relating to the APIs used I have to set up a scene containing the devices and add some information to the system config, configuration.yaml.  After restarting HA a new card called "flasher" (from my eWelink definition) which turns the switch and attached LED strip on or off.

I now wanted to add my RGB light.  The appropriate integration is from a company called Tuya.  I already have the Tuya SmartLife app to control my RGB colour bulb but I also needed to register with the Tuya IoT platform to facilitate HA integration and obtain an authorisation key.  Finally I can add the integration and I have a new card on my dashboard to control the light.


The third new integration I want to add is MPD, I am hoping this can provide the starting point for music integration.  Installation consists only of adding a couple of lines, including the MPD server IP,  to the configuration.yaml file. Using a new MPD card on the dashboard I can now start and stop music on my MPD player.  This is excellent.


HA now knows about the devices I want to control and I am ready to move on to the next stage, controlling them. 

No comments:

Post a Comment