🔌 Detect and monitor the status of an appliance based on its power consumption - V2.1.0 - Updated!

This is the automation I made to control the status 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 and buying 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!


:clipboard: Features

For the record: there is more inside. Anyway, here’s a summary:

  • 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
  • The appliance has its own State Machine

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

  • More triggers: more control, even when Home Assistant reboots!
    This automation is triggered on each power read. 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 automation is to permit a more granular control over what’s happening.

  • 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: 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 own timing.

Interested? Let’s install it!


What do I need to run this blueprint? 🗸

Premise

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

  • power monitoring (polling rate of a maximum of 60 sec for best results)
  • ON/OFF control over HASSIO
  • status reporting

Mine is a Meross MSS310EU, but it shouldn’t matter that much.

  • To get the detached_overload state to work properly, you need something that can detect an overload. I’m not the author of any of that, but the one I’m using is Ha_PowerControl (disclaimer: it’s just in Italian :spaghetti:).

Let’s make some helper variables (mandatory)

Head over to configuration.yaml and add the following pieces of code:

PRESETS - If want to simplify this even more, check out one of the pre-made configuration.yaml examples that I prepared.

1. 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>

  # ... <- Your other input_select(s) (if you have any)

2. The Job Cycle indicator

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

  # ... <- Your other input_boolean(s) (if you have any)

3. 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>

  # ... <- Your other timers (if you have any)

4. The automation self-trigger

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

  # ... <- Your other input_boolean(s) (if you have any)

Important! Please make sure to edit all the <your_appliance_name>, <Your Appliance Name> and <your_appliance_icon> fields accordingly.

# Example (Washing Machine):
#
# <your_appliance_name> = washing_machine
# <Your Appliance Name> = Washing Machine
# <your_appliance_icon> = washing-machine (taken from here https://materialdesignicons.com/)

# # # Result:
# # input_select:
# #   washing_machine_state_machine:
# #     name: Washing Machine - State Machine
# #     options:
# #       - unplugged
# #       - idle
# #       - paused
# #       - job_ongoing
# #       - job_completed
# #     icon: mdi:washing-machine

# # and so on ...

PRESETS - If want to simplify this even more, check out one of the pre-made configuration.yaml examples that I prepared.


:heavy_plus_sign: Download & Import

Are you trying to update? You should follow this instead.

If you have just created your helpers, 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

Results :tada:

You should see the 4 new entities:

Warning! always use the 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:


:postal_horn:Important notice! :rotating_light:

:new: The code has been updated

  1. Version 2.1.0 of 05/31/2022 - [FIX! | IMPROVEMENTS]
  • ±FIXED± the timer: an issue was not allowing the timer to finish. The delay should now be working.
  • +ADDED+ Added two more triggers: when HA starts, and when the automation is reloaded.
  • /CHANGED/ The description inside the automation has been updated/improved.
  • /CHANGED/ The order of definition of the input entities is now different.
  • /CHANGED/ There’s a new version tag visible inside the blueprint’s description.

    Want to update? Read here

- older versions -

  1. Version 2.0.0 of 05/20/2022 - [MAJOR UPDATE] Introduces a ton of new features:
  • ±FIXED± some subtle :bug::bug::bug:: I hate bugs (the coded ones ofc)! I did notice some strange and unwanted behavior during some state transitions. V1.0.1 seems to become unreliable when the user manually turns on and off the smart socket. This is a fix to that and other smaller things.
  • +ADDED+ Low Power Threshold → job_completed inhibition: @siklosi found that some appliances may intermittently absorb less than the Low Power Threshold, and that causes the automation to act like if multiple jobs were started and finished consecutively. This version aims to fix this issue by waiting and checking if, during that period, the appliance’s power consumption rises again. The only disadvantage is that waiting for a long time also means that a possible job length estimate is less accurate because the state machine is not as reactive.
  • +ADDED+ Automation can now trigger itself: This is very useful because in a case like the above, when the appliance consumes 0 Watts steadily, there would be no trigger, as no change in power absorption is detected. The self-triggering solution will now prevent it from being ‘stuck’ in the same state because of this problem.
  • +ADDED+ detached_overload state: The new detached_overload state was introduced to make things tidier and clearer to understand. The pause state indicates that the appliance is not resuming the previous job.
  • /CHANGED/ The automation now runs in restart mode, not in single-mode anymore. I did this because I am prioritizing the trigger over the internal checks.
  1. Version 1.0.1 of 05/16/2022 - [FIX!] Fixes the error of the ‘idle’ state which was not working correctly.

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

Did you like it? Leave a :heart: below

7 Likes

Code of the blueprint (V2.1.0)

→ 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! Although, in some super-duper rare cases it might get stuck in the current state. It never happens when the appliance is running, but it might when the job cycle finishes exactly when HA is rebooting.
    This is no longer happening since V2.1.0.

  • 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

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 status 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.

1 Like

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 now?

  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?