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

Bin Sensors in Home Assistant - Shell & Template

As part of my Home Assistant dashboard I want to include useful information which is not directly related to smart devices in my home.

With the uptick in recycling in recent years, we now have 4 different bins that need to go out on the street on different weeks for collection. On the off-chance I’m one of the first in the street to be putting one or more of them out, I wanted a quick way to work out which should be going out.

The bins go out on a fixed day of the week, with a routine like this:

Bin Type Schedule
Black/Green - Non Recyclable Waste Thursday (Fortnightly)
Burgundy - Food and garden Thursday (Fortnightly)
Blue (paper and card) Thursday (4 Weekly)
Light Grey - Glass, cans and plastics Thursday (4 Weekly)

My first version of this dashboard element looks like this:

Dashboard Card

This shows:

  1. The bin(s) that are due to go out next
  2. The day & date of the next collection
  3. The number of days until the next collection

This requires some custom sensors to hold the next collection date and type, and there are (at least) two approaches that can be taken to achieve this:

  1. Using the shell command integration and a pair of python scripts
  2. Using a couple of template sensors

» Continue reading

Counting Sensors in Home Assistant

I have been building up my Home Assistant dashboard for a while, mostly using Mushroom Cards. My main dashboard started off largely inspired by this Everything Smart Home tutorial and has continued to evolve as I have thought of new ways to make it more useful.

At the very top of my dashboard I have a few informational chips:

Dashboard Chips

From left to right is the built-in weather chip, followed by a count of the lights currently on and then a count of devices that have updates available to them.

These latter two chips use custom sensors created using the template integration and took a bit of fiddling to get working right, so I thought it was at least worth sharing my configuration. Yours will likely be a bit different depending on exactly what combination of devices & integrations you use. This integration is not currently configurable through the user interface so requires updates to the Home Assistant configuration.yaml file (or whereever you have your cusom sensors defined).

» Continue reading