Washing machine - save power turn off after x min in stanby


#1

I have a sonoff pow r2 linked to my washing machine, to get a notification when it’s finished.

The automation looks like this:

- alias: Waschmaschine - Benachrichtigung
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: binary_sensor.wash_state
    to: 'off'
  action: ... (notification)

in binary_sensor.yaml

wash_state:
  value_template: "{{ states.sensor.wash_mean.state | float > 10 }}"

in sensor.yaml

- platform: statistics
  entity_id: sensor.wash_power_w
  max_age:
    minutes: 3

I need this meanvalue to even the curve so it don’t switch on and off at spikes. And I use the binary sensor to show the state in the UI. I know that I could bypass this in the automation.

Ok, so now my issue:
I’d like to turn off the the washing machine with the sonoff, when it is in standby for let’s say 15 minutes to save some power.

This is my automation to do this:

- alias: Washing machine off - after x min standby
  initial_state: 'on'
  trigger:
    platform: time_pattern
    minutes: '/5'
    seconds: 00    
  condition:
    - condition: state
      entity_id: switch.power_washing_machine
      state: 'on'     
    - condition: state
      entity_id: binary_sensor.wash_state
      state: 'off'
      for: '00:15:00' 
  action:
    - service: homeassistant.turn_off
      entity_id: switch.power_washing_machine

But this doesn’t work as expected.
The problem is that it takes a little while to get the mean value above the threshold to turn the binary sensor too true.

So if the power of the washing machine is off and I turn it on manually (at the sonoff), there is a good change the automation will turn it of in the next 0-3 minutes, depending when the every-5min-trigger fires. If the meanvalue is still below the threshold, the washing maching gets turned off.

I missing a smart condition here. This might be obvious but I currently cannot see it.
Glad for any ideas.
@petro you show your skills regularly, any idea on this one?


#2

add:

for: '00:15:00'

to the first power_washing_machine condition. Then they both need to be in their state for 15 minutes, which should be what you’re looking for. No?


#3

Thanks, I think you are right. This should solve this.


#4

I think there is still a chance this automation can fail, this would mean it turns off a running washing machine.

This is the scenario I’m thinking about.

One load is finished. Approx. (depending on the trigger) 15 to 20 min after that it would turn off power.
If I come back to unload and start another load a few minutes before the trigger fires to turn it off, there is a big chance it will turn it off, because the mean value of the power takes a little bit to go over the certain threshold.
So im the 5min-Trigger triggers in that lets say 3 minutes, the conditions (power and wash_state will be true) will be passed threw and the machine turns off.

Adding the the current value of the power will make it a little better. But my dryer has some weird spikes when it goes to standby (normal 3W, some spikes at 150W, don’t know why, but it does that in the first few minutes)

So adding this will make it more reliable, but if it has that mike in the that moment, it will pass trough and again turn off the machine.

- condition: numeric_state
  entity_id: switch.power_washing_machine
  below: 10

Maybe adding another

for: '00:02:00'

to that condition would work, as this woudl cut out the spikes. Also maybe the meanvalue is unnecarry for that automation. And I should only use the realtime value.
What do you think @petro

EDIT: unfortunately for is not valid fot a numeric_state condition


#5

Not sure, really needs to be tested. I don’t know how your power meter works. Personally, i’d try to make the signal work ASAP and transform it into an on/off signal if possible.


#6

The power meter is a Sonoff pow and it measures the power in W and reports it’s value every 30 seconds over mqtt.

Because I got some spikes (also some minimums) I had to use a meanvalue (3 min) to make the on off state reliable.
Now it seems like I cannot use that meanvalue for the „turn off“ automation.
But again maximums and minimums could disturb this automation and led to wrong triggers.


#7

Because of the spikes the washing machine would go on and off, while it is in a certain state (on or off).

Example: washing machine is on, but it doesn’t do anything (let’s it sit for a while). The power will go below the threshold and will report machine off (but it’s still on).

The other way around: machine in off but when it beeps it has those spikes. They go higher than the threshold and report on.
Because of this I need the meanvalue.

But as described in the scenario above the meanvalue could be to slow sometimes.

I don’t know if I could describe it understandable.


#8

have you tried using a filter?

I’d recommend an outlier and a low pass. That should weed out just about everything and give you a nice trend that should be usable.


#9

Thanks, I didn’t know about that one yet. I will defiantly use that one for my basement temperature sensor which totally looks like the picture in the example.

But won’t that filter also take a while to until it goes over the certain threshold?

As I said before I used a statistic sensor (mean value)

And this one works perfect to notitfy me when the washing machine is finished.
Meanvalue is set to 3 minutes, so it evens out the curve. But this means it takes up to 3 minutes until a change is noticiable. Of course if it’s a sudden drop or high you will see it earlier in the mean value.

Wouldn’t the filter do the same thing?