Adding HomeKit Devices to HomeAssistant

One of the first smart home devices I purchased was a Meross MSS425F power strip, which has 4 individually controllable sockets and a group of 4 USB ports that are controlled in a single block. At the time I had not yet discovered Home Assistant, and was using the Apple Home application to control my smart home.

This device was the last thing I did not have in Home Assistant and it was leaving my night time automation incomplete - so it was time to finally get it added in. There is a HomeKit Device integration, but I couldn’t see from the pre-requisites how to get this device discovered - although it is pretty easy. The basic steps I took were:

  1. With my iPhone on Wi-Fi network I wanted the device to join, add device to Home through the Meross app
  2. Remove the device from the Apple Home app
  3. Home assistant will now discover it. The Configure button will prompt for the HomeKit code on the bottom of the device

…and that is it. The first two steps were not immediately obvious from the Home Assistant documentation, but are probably required for most WiFi HomeKit devices.

Backing Up Docker Services

This week I had an issue where one of the Raspberry Pis that I use for self-hosting some services stopped working. It started with docker pull commands failing due to unknown paths that looked to be complete gobbledegook, and ended up with the Pi not booting at all. Checking the disk, it was full of filesystem errors that could not be repaired - I’m pretty sure the SSD it was using had previously been retired due to similar problems, so it was time for a replacement.

Taking a new SSD and reprovisioning this Pi was the easy part thanks to the Raspberry Pi Imager and the Ansible playbook I had written when I first setup the server. That handles the core OS configuration and many configuration files, including the Docker compose files that defines the services that I run. What it does not include is data.

This server had backups taken on a very ad-hoc basis, and as is often the case the topic of backups becomes a prority again after a data loss event (even if it was largely recoverable from the failing SSD).

» Continue reading

Using Actionable Notifications in Home Assistant

I’ve seen a bunch of videos on YouTube lately that included actionable notifications in automations, but it’s not something I’d ever used before.

The Home Assistant companion documentation shows plenty of examples of how to include the actions in the notifications, but not much on how to actually respond to the action events. I came across this post that I found was a good starting point for my automation.

My initial use case for this was for a notification in the morning when the kids should be out to school, to prompt me to turn out any lights that they have inevitably left on.

My current automation for this is as follows. This checks if any of three lights are still on at 8am on a weekday, and if so sends a notification to my phone with the option to turn them off.

alias: Notify - Kids lights left on
description: ""
  - platform: time
    at: "08:00:00"
  - condition: and
      - condition: time
          - mon
          - tue
          - wed
          - thu
          - fri
        alias: Is it a weekday?
      - condition: or
          - condition: state
            entity_id: light.childone_room_cloud_light
            state: "on"
          - condition: state
            entity_id: light.childone_room_bulb
            state: "on"
          - condition: state
            entity_id: light.childtwo_bedroom_main_bulb
            state: "on"
        alias: Are any of the boys lights on?
  - alias: Set up variables for the actions
      action_no: "{{ 'NO_' ~ }}"
      action_turnoff: "{{ 'TURNOFF_' ~ }}"
  - alias: Notify Mobile
    service: notify.mobile_app_twelve
      message: Boys lights are still on. Turn off?
          - action: "{{ action_turnoff }}"
            title: Turn off lights
          - action: "{{ action_no }}"
            title: Leave On
  - alias: Wait for a response
      - platform: event
        event_type: mobile_app_notification_action
          action: "{{ action_no }}"
      - platform: event
        event_type: mobile_app_notification_action
          action: "{{ action_turnoff }}"
  - alias: Perform the action
      - conditions: "{{ == action_no }}"
        sequence: []
      - conditions: "{{ == action_turnoff }}"
          - service: light.turn_off
            data: {}
                - light.childone_room_bulb
                - light.childtwo_bedroom_main_bulb
                - light.childone_room_cloud_light
mode: single

Updating the Unifi Controller URL in Home Assistant

In the last few weeks I’ve been changing over the domain name that my lan runs on. This broke some of the Home Assistant integrations I use, like the Unifi integration - but there is no option in the UI to reconfigure the controller URL. Now I could have removed & re-added the integration, but that would have resulted in recreating the entities with a new name (usually with a “_2” suffix).

So to work around this I have found where the configuration which is performed through the UI is stored - /config/.storage/core.config_entries. This is where all the warnings come in - you are not meant to manipulate this file manually. Things may break, the world may end. Ensure you have good backups and keep a hold of your towel.

For the Unifi integration, this file will contain an object like this:

        "entry_id": "0820e19d88fb12000d1ca989774c98f2",
        "version": 1,
        "domain": "unifi",
        "title": "Home",
        "data": {
          "host": "",
          "username": "metrics",
          "password": "<REDACTED>",
          "port": 443,
          "verify_ssl": true,
          "site": "default",
          "controller": {
            "host": "",

To update the URL for my controller I stopped my Home Assistant container, edited the URLs in this file, then started Home Assistant back up. This same approach also worked for the Pi-hole integration.

Bin Sensors in Home Assistant - Scrape

Continuing on from last week’s post, I’ll cover the new (and hopefully improved) version which adds to the Mushroom Chips I use at the start of my main dashboard. This is a slightly more complicated approach, but should also be kept up to date if the schedule changes as it uses the Scrape Integration to pull the information directly from a website.

Dashboard Chips

My local council has a webpage per street in the area which shows which bin(s) are due to be collected in the current week. The main index page for this is here - Bin collections and calendar.

Once you select a region and a street, you are presented with something like this:

Bin webpage example

This shows either one or two bins depending on the schedule for the current week, as well as their names. From this I’ll be picking up what the type of bin is as well as the colour for using in the chip.

For each bin, this is the HTML that we ultimately want to extract values from is:

  <h4>Food and garden <br/><p>No liquids, oils or plastic bags. <a href="">More info</a></p></h4>
  <img src="" alt="red bin">

» Continue reading