šŸ”Œ Detect and monitor the state of an appliance based on its power consumption - V2.1.1 - Updated!


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 :heart: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:

  • :control_knobs: 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.

  • :stopwatch: 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.

  • :chart_with_downwards_trend: 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.

  • :date: 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!


  • :ninja: 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!


:clipboard: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 :spaghetti:).

:gear: 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 :sunglasses: 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 :arrow_down:

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.


:heavy_plus_sign: 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 :tada:

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

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 :brain:


___

Versions & Changelogs:

:postal_horn:Important notice! :rotating_light:

:new: 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 GitHub, and on leofabri.com.

ā€¦

Did you like it? Leave a :heart: below

54 Likes

Code of the blueprint (V2.1.1)

ā†’ You can find it here ā†

Iā€™m not pasting it in the topic because the webpage would hang :sweat_smile:



Q&A - Things you may want to know

#general

  • Is this able to survive reloading automations and Home Assistant? ā€” Yes!

  • Why is this thing so big? That monstrosity doesnā€™t even show correctly on my small screen! ā€” I know :sweat_smile:. There are many conditions, and those increase the visual width of the blueprint in the UI. On mobile devices, itā€™s going to be a pain, but whatā€™s important here is that things work and that all the possible situations are handled.

  • How is this different when compared to Notify or do something when an appliance like a dishwasher or washing machine finishes? ā€” Itā€™s very very different and much more articulated. Read here for more info.

  • Will this slowdown Home Assistant? ā€” I donā€™t think so. The blueprint will run every time a new power read is polled by HA. If thereā€™s no state change, the automation is basically not doing anything and completes super quickly.

  • How do I update to a new version? ā€” Please follow the steps here.

#overloads

  • What is an overload situation? When does it happen? ā€” An overload occurs when the appliance is drawing too much power and this affects the entire home grid. This usually triggers your circuit breaker.

  • Is this blueprint a solution to my overloads? ā€” Nope. It just stores the states of your appliance, it doesnā€™t diagnose anything, it notes that it happened.
    HA_PowerControl is instead a separate package that takes care of detaching the loads progressively based on a settable priority. It does work, but the appliance is not self-conscious of being the cause of an overload. The detached_overload state adds that consciousness.

  • Do I really need HA_PowerControl? ā€” No. Iā€™m allowing the user to bind this blueprint to whatever system they have for handling those situations.
    You might not want to use anything, in that case, leave the ā€œAppliance Suspended entityā€ empty.

  • HA_PowerControl is just in Italian :spaghetti:ā€¦ is there no other alternative? ā€” I was unable to find anything yet. I asked the author if Iā€™m allowed to translate it, but itā€™s still too early to talk about a release.

  • What does this blueprint do during an overload? ā€” If the ā€œAppliance Suspended entityā€ was configured, the state machine should transition to the detached_overload state.

Got more questions? Ask below! :slightly_smiling_face:

1 Like

How do I know if there is a new version?

Easy!
Look for the current version number in the title.
Now, open one of the automations that currently uses this blueprint and notice the version tag:

To update:

  • Open this page Open your Home Assistant instance and show your blueprints. (just click the link, itā€™s magical) and scroll till you find ā€œMonitor the state of an appliance - by leofabriā€ and delete it by clicking on the trash bin :wastebasket:. Donā€™t worry, weā€™ll add it right back in a few sec, you can leave the automation as it is for now.

  • Create the missing helpers (entities) as shown in the instructions

  • Add the blueprint again Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled. and reload home assistant.

  • Open your automation and add the previously created helpers (entities)



The documentation ends here.


1 Like

Hi, thanks for great blueprint. I tried it and itā€™s working fine for my washing machine, but for drying itā€™s sending multiple notifications because there are periods when power meter registers 0W consumption and automation thinks that job is finished multiple times. Is it possible to add timeout for cases like this. Here is how consumption graph looks for my dryer (there are periods of little more than 30 seconds with 0W consumptionā€¦ at least reported by teckin sp22 power meter).

2 Likes

Hi @siklosi thank you for your appreciation! :wink:
Speaking about the dryer problem, Iā€™m on it right now. Itā€™s odd though :laughing: At first, I thought that an appliance performing job would never consume less than a certain amount (definitely not 0 Watts!) but maybe, due to the sensitivity of your power meter, that gets approximated and my blueprint is unable to distinguish the states.

I was thinking about adding some sort of timer to delay the job_completed event and at the same time watch for spikes in power consumption during that period.

I already have the logic in place but Iā€™m having some difficulties debugging this thing, as I donā€™t have the appliance. For now, I decided to use my toaster lol XD.

Iā€™ll definitely get back to you as soon as I have something reliable.

Big news! Version 2.0.0 is now public :boom: :boom:
There are a ton of changes!

As always, feel free to share your impressions!

@siklosi it should fix your issue :wink:

1 Like

Thank you for this super-interesting blueprint! I read it through and am impressed by the work you put in there. I see a big part of the complexity is overload situations. I just cannot image what such an overload situation could be.

Do you use it to detect your circuit breaker cutting power or what could detach your appliances from the grid in those overload situations?

Hey! I appreciate that you like it! Yeah, I put so much effort into the overload situation because appliances tend to be the main cause of blackouts in my house. My circuit breaker is so dumb and it doesnā€™t detach things until itā€™s too late :sweat_smile:
Here instead, Iā€™m using HA_PowerControl and the smart sockets to decide when to do that, prior to a total blackout. This is just perfect when, for example, you have your dishwasher and washing machine are running concurrently (thatā€™d be a 4KW load!).

I have a 16A breaker on the appliance line, and Iā€™m allowing a total power consumption of 3,3KW from the grid before considering it as overload.

HA_PowerControl detaches the configured loads progressively based on a settable priority. Itā€™s great but in some cases, itā€™s not flexible enough. The problem is that the appliance is not self-conscious of being the cause of an overload, so I added it here, and Iā€™m allowing the user to bind this blueprint to whatever system they have for handling those situations.

3 Likes

What a great explanation, thanks. A bit ā€œshockedā€ by :wink: the weird circuit breakers but I see how everything makes perfect sense for these cases and how your blueprint contributes to giving your appliances some consciousness. Thanks for letting me know!

1 Like

good one :joy:

Iā€™ve updated the documentation a bit, it should be clearer now. There are no changes in the code (we are still at version 2.0.0).

Outstanding post!!!

Thank you @Tismo

@leofabri - hello, im testing your blueprint, just finished the integration and the washing machine status is unplugged, when the socket is turned on:


any ideas what to set differently? thx for any hints

PS: would be possible to add also the door sensor to this blueprint? :blush:

Hi @Mio3000,
could you please make sure that in your automation, the ā€œSmart appliance socketā€ entity is selected correctly? From what I can see, it should point to sensor.washing_machine_socket.
Also, it could be that the State machine is not selected, because the unplugged state is always shown as the default one, and that canā€™t be a coincidence :neutral_face:

If that doesnā€™t solve the issue please paste the yaml file of your automation.

# Your automation should look something like this:
alias: My washing machine automation
description: ''
use_blueprint:
  path: leofabri/appliance-status-monitor.yaml
  input:
    # Things that I saw on the screenshot you posted
    appliance_socket: switch.washing_machine_socket # <- Made a typo here, it has to be a switch
    appliance_power_sensor: sensor.washing_machine_power
    appliance_state_machine: input_select.washing_machine_state

    # Things that I didn't see. 
    # I'm assuming that the naming matches the documentation
    appliance_job_cycle: input_boolean.washing_machine_job_cycle
    delayed_job_completion_timer: timer.washing_machine_delayed_job_completion_timer
    automation_self_trigger: input_boolean.washing_machine_automation_self_trigger



Regarding the door sensor, I think that this goes outside the scope of the blueprint. Mine wants to be a universal solution and the feature you are referring to is very targeted.
You can definitely pair another automation to mine and do what you want with it. Itā€™d certainly be easier since you now know the state of your appliance.

@leofabri - hello, here is my automation config:

- id: 'XXX'
  alias: Monitor the status of the Washing machine
  description: ''
  use_blueprint:
    path: leofabri/appliance-status-monitor.yaml
    input:
      appliance_socket: switch.washing_machine_socket
      appliance_power_sensor: sensor.washing_machine_power_corrected
      appliance_finishing_power_threshold: 2
      appliance_job_cycle: input_boolean.washing_machine_job_cycle
      appliance_state_machine: input_select.washing_machine_state
      appliance_suspended_sensor: input_number.washing_machine_suspended_entity
      automation_self_trigger: input_boolean.washing_machine_automation_self_trigger

@Mio3000 - Looks right to me.

I have a few questions for you:

  1. Did your automation ever run?

  2. What happens when you press the Run Actions button?


    Did it run?

  3. Is there anything in your timeline?

@leofabri -

  1. I didnt use the washing machine after i created the automation.
  2. looks like run actions fixed the issue and now i have correct ā€œidleā€ state:

thank you for your help, i will monitor it when i will use the washing machine again.
In case of any issues i will write here

Thatā€™s why :joy:

The automation has to be triggered at least once to know the initial state :wink:

In the next release, Iā€™ll put a couple more triggers to run the blueprint even after HA or the automations get reloaded.

This blue print is absolutely fantastic. Thanks for all your hard work on it. I have it working perfectly with my tumble dryer and washing machine. My dishwasher however keeps sending finished alerts when only part way through the program. I have the timeout set to the max of 900 seconds but am still getting alerts before it has finished cleaning my dishes. Could you advise what I could look to change to stop this happening?