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

Here is another fun addition to the project. I wanted to be able to show how long an appliance job had been running in the UI. You can add this sensor template to the package: file (in this example, the washing_machine.yaml package):

template:
  - sensor:
      - name: Washing Machine Job Elapsed Time
        state: >
          {% if is_state('input_boolean.washing_machine_job_cycle', 'on') %}
            {% set hf = ((now() - states.input_boolean.washing_machine_job_cycle.last_changed).total_seconds() / 3600 ) %}
            {% set h = hf | int %}
            {% set m = ((hf - h) * 60) | round %}
            {{ '%s hour' % h if h > 0 }}{{ 's' if h > 1 }} {{ '%s minute' % m if m > 0 else 'less than a minute'}}{{ 's' if m > 1 }}
          {% else -%}
            off
          {% endif %}

and that will update once a minute with the elapsed time while the job is running. Template sensors are neat.

6 Likes

I have a timer for cycle end for my washing machine, it’s about 5mins(it had to be that long)
However, sometimes we’ll switch off the power after washing machine is finished, but before timer expires. In that case, state machine will be ‘job ongoing’ as power sensor will go to ‘unavailable’. Can I somehow use those 5mins OR sensor goes to unavailable for cycle end?

I’m loving this automation, thanks for this.
@millercentral’s version got me thinking however, that I would like to match washing machine’s actual states more closely, not just unplugged → idle → job ongoing → job completed / idle

It would be helpful for us to expose the following states:

  • off (as opposed to unplugged): 0 W - dial is set to off
  • idle: 1 W (or less than 4 W at least) - dial is set to a program but no active job
  • timer (or using pause even): 4 W - manual delay for cycle start of 3, 6 or 9 hours.

Sometimes we mess up the timer, so be nice to be able to double check, or a few times washing machine has cancelled the timer for no obvious reason, so it’d be helpful to be notified if that happens.

What would be the most viable approach to allow extending the system to extend / add further states for different power threshold’s ?

Thank you for the amazing job @millercentral. Hopefully, after yesterday, my studies mostly completed (the thesis is the only thing left).
I’ve spend a lot of time away from the HA community, and my personal environment for testing this automation and the other thing has been left behind of many versions… I would like to continue the work on this automation.
I’m reviewing what you’ve changed. Please let me know if we can implement some of your recent additions to the main code. I would love this to be a collaborative project, feel free to get in touch if you want to join some of the changes to the main repo.

1 Like

I initially decided to use the “unplugged” state to better reflect the fact that the appliance is actually not plugged but I think that off could be a valid option if we want to increment the abstraction a bit more. One more thing, how could we detect if the appliance is set to have a manual delay for cycle start?

Sometimes we mess up the timer, so be nice to be able to double-check, or a few times the washing machine has canceled the timer for no obvious reason, so it’d be helpful to be notified if that happens.

Yes, this would be a nice addition.

What would be the most viable approach to allow extending the system to extend/add further states for different power threshold’s?

Unfortunately, I’m afraid it’s not as easy as adding some additional states to the state machine. First, we need to be able to determine if the additional states can be recognized based on a previous state or from the data of the smart socket.

One more thing to mention is that I usually try to make every update as lees breaking as possible… I’m sure people already hate the way we have to update blueprints. I’m trying to keep it easy for everybody. Changing the states is a big change

hi @leofabri, hi all,
I love this blueprint, it makes dealing with dishes, clothes and even coffees far easier.

for one minor challenge I might need your advice or even an extension of the blueprint.
When I am not immediately getting the clothes out of the washing machine when it has finished, it switches off. To open the door, I have to switch it on again. And the automation detects an additional cycle. I switch off the machine immediately after I have opened the door, and the cycle ends. and I get the message that a cycle has ended.

Similar story for the coffee machine, when I switch it on, the automation detects it and starts a cycle. Sometimes I forget to start the the creation of the coffee and the machine switches off. nevertheless it informs me that the cycle has finished and “the coffee is ready”.

What I would need is to set a minimum duration of the power being above the configured threshold.
e.g. in the case of the washing machine, 3min.

I hope I could get my challenge and wish across.

Hi @leofabri,

This blueprint seems incredibly useful in our household where laundry often ends up forgotten.

I’m running into an issue where it seems to a bit too well. Our dryer starts a “reduce wrinkle” program after the real program has finished. As a result the job_complete state gets triggered roughly every 2 minutes. The power usage drops to around 2 watts at the lowest and spikes to 130 momentarily. During this extra program I’d like to consider the job done.

Is there any way to accomplish this?

Just set ‘Finishing power threshold’ to, say, 3?

finishing power threshold is currently set at 3.

What happens is that the dryer stays in a low power mode and occasionally spins up. Only when we manually turn off the dryer, does the power usage drop to 0. Every spike is currently detected as a new cycle.

Is it possible to set the minimum duration to consider it a proper cycle? Eg: if the power usage is above the starting threshold for more N seconds, transition to job_ongoing.

I see. What’s your Starting power threshold? From the pic you attached previously it seems like you have a spike to around ~200W when the cycle starts - why don’t you use that as starting power threshold?
That way these small spikes won’t count as a new job, as they are <200W.

Clever! I think should work.

Power hover around a 100 for about a minute before increasing. So a higher starting threshold should work as expected, albeit with a slight delay. Though I don’t think that really matters for my use case.

Hello again :slight_smile:
does anyone have an idea for my challenge to define a minimum duration of the power being above the configured threshold?

Cheers

After some use of this automation with my dishwasher, I have a suggestion for you.

I found that when the washing cycle is completed, my dishwasher however still mantains a certain stable low power consumption level as it’s still on, until it’s physically turned off.

Unfortunately, as expected, similar low power consumption levels occur sometimes for brief periods (a few minutes) during the cycle.
This could be overcome setting a “delayed Job Completion duration” value, but this causes the side effect of a delay of many minutes before the automation is allowed to detect a job completion.

In my case, but the same might be valid for other types of appliance, the cycle duration is actually almost fixed, as my dishwasher always runs the same program.

So my suggestion to improve the automation would be to add a further optional parameter called something like “After job started do not check job completion before:” with a value in minutes (default 0 min, i.e. not used).

In this case when the final power consumption falls under the selected threshold, the job completion state may be detected immediately without delay as the possible intervening power falls during the cycle are not taken into account.

Thanks for your nice work!

hi

thank you for this great blueprint. I was wondering if it is possible to have some kind of translation for the state of the machine. The reason is, we are native German speaking, and it would look better if the state would be e.g “fertig” instead of “job_completed” . Is this somehow possible?
Thanks
BR
Daniel

hi @andrus
I mentioned a similar idea/enhancement request:

it’s good to know that it’s not only me thinking about such an improvement.

Hi, @niknol, I have read your post, but if I understood correctly, you proposed a new ‘minimum duration of the power being above the configured threshold’, while I actually propose a new value (minutes) after the blueprint has detected a job_ongoing state, before which not to check for a job_completion state, regardless of any power level variation occurring during this interval, so the level could stay near zero even for many minutes during the cycle w/o triggering a job_completion state.

The reason for example a dishwasher is that its washing cycle never lasts less then a certain amount of time, so it’s safe and easier to ignore any power variation before this interval has expired.

This broken for me in the latest HA update - 2023.11

EDIT: It was my fault!

Yes, @andrus you’re right.
two different but a bit similar enhancements. @leofabri Perhaps they could be implemented in one go …

I have a water softener that’s got me stumped. It takes about 2.5 watts all the time. When it goes through a regeneration cycle, a valve opens, stays open for a few hours, then closes. You can see one of these regeneration cycles in the picture below on Nov 6 from about 12:30 AM to 3:30 AM as two spikes up to about 5.8 W.


It also has a built in light. When I open the lid to add salt, the light comes on and takes about 7.2 W, which you can see on Nov 7 at about 2:00 PM.
So the question is, how do I detect the regeneration cycles, but not the lid opening?

If you can do without the light, then, if possible, you could remove the bulb, or at least replace the light bulb with a LED one having a less power requirement. :thinking:

1 Like