I made an automation to detect and monitor the status of your dumb appliances, so you don't have to🔌- V2.1.1✨

I made an automation to detect and monitor the status of your dumb appliances, so you don't have to🔌- V2.1.1✨
Photo by Greg Rosenke / Unsplash

Automation Blueprint for Home Assistant


Monitor the state of an appliance - by leofabri


This is the automation I made to control the state of the most power-hungry appliances in my house.

There aren’t numerous blueprints that do what I want, and I’m sure that I have the skills to automate my machines without wasting money to buy them new. Here’s my cheap and reliable solution that addresses the problem, once and for all.

I use this for my dishwasher and washing machine and the results have been great! The blueprint is very extensible and easy to use.

My family ❤️s this thing! Even if they don’t understand its complexity and get what all the fuss is about.

As I said, I’m sharing this with everyone. I’m sure that you’ll find it useful!


Features

For the record: there is more inside but, here's a summary of what this thing allows you to do:

  • 🎛️ More triggers: more control, even across Home Assistant reboots!
    • This automation is triggered on each power reading. I'm doing the starting/finishing thresholds magic in the "actions" section, and you can also add some of your own.

      The objective of this blueprint is to allow more granular control over what's happening and do that reliably.

  • ⏱️ Faster machine start-to-finish detection: one of the problems that I always face is timing. What if you want to measure how long it took for your appliance to complete its job? The automation has to be very reactive. This logic should solve that problem for you.

  • 📉 Unreliable power absorption filtering and inhibition: This is useful! It prevents the blueprint from thinking that a job was completed as soon as the power falls below the finishing power threshold. You can set your timing here.

  • 📅 Set your custom actions for each of the following conditions:

    • when an overload occurs

    • when the overload situation is solved, now paused

    • when the appliance is plugged back in, now paused

    • when the overload situation is solved, now resuming

    • when a new job cycle begins

    • when a job cycle resumes

    • when a job cycle is finished

      All of these are optional!


  • 🥷 The appliance has its own State Machine

    • So that you can tell if it's in one of the following states:

      • unplugged - The appliance is no longer powered. It happens when the user manually turns off the smart socket (from HA or the socket itself).

      • idle - There is no pending job, the machine is powered but idling.

      • paused - Indicates that a job is pending (incomplete cycle) but the appliance is not performing it. The inhibitors of these state are the datached_overload and unplugged states. In this condition, the power consumption is lower than the finishing power threshold. The appliance must be off (maybe the user turned it off manually or maybe the job needs some time to recover). The blueprint is waiting for the appliance to resume.

        Pro Tip! You could also use this to diagnose and warn if a job is not resumed after x minutes.

      • detached_overload - This happens when, during a cycle, the appliance used too much power and was therefore suspended. It is also technically unplugged.

      • job_ongoing - Triggered in two cases:

        • when a new job cycle begins: the previous one is completed and the Starting Power threshold is surpassed.
        • when a job is resumed.
      • job_completed - Triggered when the current incomplete job cycle is finished. The appliance consumes less than the Finishing Power threshold (also with the possibility of selecting for how long)

    Note: Each state transition is handled automatically, you just have to provide the initial configuration.

Let's install it!


📋Requirements: What do I need to run this blueprint?

To achieve this level of control the socket must have some basic features:

  • Power monitoring (a polling rate of circa 60 sec. or less for best results)
  • ON/OFF control over HomeAssistant
  • State reporting (if it's ON or OFF)

Mine is a Meross MSS310EU, but most smart sockets should be supported.

One more thing:

  • OPTIONAL: To get the pause state to work properly, you also need another automation that can detect an overload. I'm not the author of any of that, but the one I'm using is here (disclaimer: it's just in Italian 🍝).

⚙️ Initial Setup: Let's make some helper variables (mandatory!)

There are two possible ways of doing this:

  • Setup via the UI [Discouraged but Beginner Friendly]: newcomers that might be a little bit into shiny-but-dark UIs 😎 might want to set up this blueprint following this documentation here.

    ...

  • Setup via the old school YAML [Optimal & Suggested]: The best way of creating what we need is to create a package (suggestion provided by @HollyFred) because it allows us to create all the necessary helpers (timers, input_booleans, etc) in one shot. Continue reading for this one ⬇️

Creating a package is super easy. Some of you may already have the right configuration in place, but I'll show you how to do that anyway.

Note: you need to have the VScode integration enabled. This will allow you to manually edit the necessary files. Need help with that? Read this.

Back to us, here are the two steps for creating a package:

  1. Make sure that you have a directory called 'packages'.

    If you are a beginner or you are starting fresh with your HA installation, likely, the packages dir is not present.

    To add it, you can:

    Open your HomeAssistant VSCode editor and create a directory called packages (at the same level as the configuration.yaml file).

    OR

    Issue this command in the terminal section of your VSCode:

    cd /config && mkdir packages

    easy peasy.

    Result: You should see the packages directory at the same level as the configuration.yaml file.

  2. Make sure that the packages support is enabled inside of the configuration.yaml file as shown below:

    homeassistant:
         ## Packages support enabled - Includes every package that is inside the packages/ directory
         packages: !include_dir_named packages/
    

Now we are ready to create our first package.

Open the packages/ directory and create a file with the name of your appliance.

For example, I'm calling mine washing_machine.yaml but yours could be different. It's always better to call it something like <your_appliance_name>.yaml

PRESETS - If want to simplify this even more, check out one of the already pre-made packages I prepared for you.

Remember that in order to use the blueprint you'll always need these four ingredients inside a package (like so):

A. The State Machine

input_select:
  <your_appliance_name>_state_machine:
    name: <Your Appliance Name> - State Machine
    options:
      - unplugged
      - idle
      - paused
      - detached_overload
      - job_ongoing
      - job_completed
    icon: mdi:<your_appliance_icon>

B. The Job Cycle indicator

input_boolean:
  <your_appliance_name>_job_cycle:
    name: <Your Appliance Name> - Job Cycle
    icon: mdi:<your_appliance_icon>

C. The delay timer

timer:
  <your_appliance_name>_delayed_job_completion_timer:
    name: <Your Appliance Name> - Delayed Job Completion Timer
    duration: "00:15:00" # <- Note that the time here. Leave it 15 min
    restore: true
    icon: mdi:<your_appliance_icon>

D. The automation self-trigger

input_boolean:
  <your_appliance_name>_automation_self_trigger:
    name: <Your Appliance Name> - Automation Self-trigger
    icon: mdi:<your_appliance_icon>

Important! Don't forget to edit all the fields <your_appliance_name>, <Your Appliance Name> and <your_appliance_icon> accordingly.


➕ Download & Import

Are you trying to update to a newer version? Let's do that in a snap! Follow this guide.

If you have just created your package, please reboot Home Assistant (at this page -> Verify & if okay, Reboot)

  1. Add this blueprint to your Home Assistant Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
  2. Create a New Automation from that blueprint
  3. Configure the variables as indicated inside the blueprint's UI.

That's it!


Results 🎉

You should see the 4 new entities:

Warning | always use those entities as indicators, do not change their values manually! Leave that to your automation

my alt text

Washing Machine entities


During a job cycle:

power usage example

This is my washing machine. Power usage example


appliance history image

The State machine. The one in light blue is a simulated overload situation.

Congratulations! Your appliance is now smarter 🧠




___

Versions & Changelogs:

📯Important notice! 🚨

🆕 The code has been updated

  1. Version 2.1.1 of 07/21/2022 - [FIX!]

    • Fixed this bug:

      Description:

      When you don’t indicate the Appliance suspended entity - which I marked as optional - the automation becomes unresponsive, thus making the optional value a required one.

    • Added some new documentation. You can decide to make your helpers through the UI instead of VSCode.
    • We are now using packages instead of overloading the configuration.yaml file with the helpers.

    GUIDE: Are you trying to update? Follow these instructions.

  2. The changes related to the older versions are shown here.


The code of this blueprint is also available on my [u]GitHub[/u], and on leofabri.com.

...

Did you like it? Leave a ❤️ below

The code of this blueprint is also available on my GitHub, and on the Home Assistant Community