Laundry finished message

Hi. 1.post
Im trying to write automation for my laundry machine. Its connected to a Sonoff POW R2, which i can read power state in entity.
I wish to get a message to my mobile when its finish.

First i want to make sure it is running ( >200W), AND then after i want to make sure its been under 1W for 8 minutes.
Then i want action for the message.for my phone.
Any suggestions? Code below.

- id: '1604004493078'
  alias: Vaskemaskin ferdig
  description: Fyrer når vaska er ferdig
  trigger:
  - platform: numeric_state
    entity_id: sensor.sonoff_10005bfb8f_power
    attribute: power
    below: '1'
    for: 00:08:00
  condition:
  - condition: numeric_state
    entity_id: sensor.sonoff_10005bfb8f_power
    attribute: power
    above: '200'
  action:
  - service: notify.mobile_app_sm_g973f
    data:
      message: Vasken er ferdig

Geir A.

1 Like

Sorry I can not help, don’t know anything about HA native automations, just using NodeRed myself. :slight_smile:

But I did a similar automation a few days ago, and I found it convenient to add a graphical notification on all home TVs using AndroidTV notifications component :

So it will display a message with an image of the washing machine or the dryer. If the TV is off it will switch it on, display the notification and then shutdown it 2 minutes later.

It has passed the WAF test, better than Alexa saying “Washing machine finished !”.

This is the code for my washing maschine. I’m using an input_select for the current state of the wasching maschine so that I can display the current state. When the power consumption changes the input_select is updated.

In my case I know that the laundry is done when the consumption is below 10W for 3 minutes.

input_select:
  status_waschmaschine:
    name: Status Waschmaschine
    options:
      - Ausgeschaltet
      - Stillstand
      - Waschen
    icon: mdi:washing-machine

automation:
  - alias: 'Waschmaschine - Ausgeschaltet'
    trigger:
      - platform: state
        entity_id: switch.waschmaschine
        from: 'on'
        to: 'off'
    action:
      - service: input_select.select_option
        data:
          entity_id: input_select.status_waschmaschine
          option: 'Ausgeschaltet'

  - alias: 'Waschmaschine - Stillstand'
    trigger:
      - platform: numeric_state
        entity_id: sensor.waschmaschine_verbrauch
        below: 10
        for: '00:03:00'
      - platform: state
        entity_id: switch.waschmaschine
        from: 'off'
        to: 'on'
    condition:
      - condition: state
        entity_id: switch.waschmaschine
        state: 'on'
    action:
      - service: input_select.select_option
        data:
          entity_id: input_select.status_waschmaschine
          option: 'Stillstand'

  - alias: 'Waschmaschine - Waschen'
    trigger:
      - platform: numeric_state
        entity_id: sensor.waschmaschine_verbrauch
        above: 20
        for: '00:01:00'
    condition:
      - condition: state
        entity_id: switch.waschmaschine
        state: 'on'
      - condition: state
        entity_id: input_select.status_waschmaschine
        state: 'Stillstand'
    action:
      - service: input_select.select_option
        data:
          entity_id: input_select.status_waschmaschine
          option: 'Waschen'

  - alias: 'Waschmaschine fertig'
    trigger:      
      - platform: state
        entity_id: input_select.status_waschmaschine
        from: 'Waschen'
        to: 'Stillstand'      
    action:
      - service: notify.telegram
        data_template:
        message: "Die Waschmaschine ist fertig."

I used to use a binary_sensor with hysteresis for this purpose, but now I simply use the wonderful wait_for_trigger in this automation:

alias: Clothes Washer Finished
description: Notify when clothes washer finishes cycle
trigger:
  - platform: numeric_state
    entity_id: sensor.aeotec_zw096_smart_switch_6_power
    above: '500'
condition: []
action:
  - wait_for_trigger:
      platform: numeric_state
      entity_id: sensor.aeotec_zw096_smart_switch_6_power
      below: '1'
    timeout: '3600'
    continue_on_timeout: false
  - data:
      message: 'The clothes washer finished at {{ now().strftime(''%I:%M'') }}.'
      title: Washer Done
    service: notify.mobile_app_pixel_4a
mode: single

if needed you could add a “for” to either one of those numeric states.

2 Likes

Thanks for replying.
I will give it a try. :smile:
2. machine load today :smile:

Geir A

1 Like

Here’s my setup, which is a bit more complex because I have a few more requirements I wanted to solve:

Requirements

  • Our machine is in the cellar and I wanted regular announcements when the washing is done but it has not yet been emptied
  • When finished, the machine is in standby until emptied and turned off. I couldn’t get reliable detection of the standby mode by looking at the power level alone so I needed to check the levels of several attributes
  • I don’t want the announcements when everyone is asleep
  • I don’t want announcements if the machine is turned on but the washing cycle has not yet been started.
  • The connection to the cellar is a bit hit and miss, so the socket ends up in unavailable state on a regular basis.

Hardware

  • Blitzwolf BW-SHP2 flashed with Tasmota using tuya-convert. Here it is with the washing machine on standby:

Machine state template

I solved the machine state by using a template sensor:

sensor:
  - platform: template
    sensors:
      washing_state:
        friendly_name: "Washing machine / Tumble dryer"
        value_template: >-
          {% set current_state = states("sensor.washing_state") %}
          {## CHANGEME - name of the sensor goes here ##}
          {% set prefix="sensor.blitzwolf_sw1_" %}
          {%- if is_state(prefix + "status", "unavailable") -%}
              {{ current_state }}
          {%- else -%}
              {% set current = states(prefix + "energy_current") %}
              {% set power = states(prefix + "energy_power") %}
              {% set apparentpower = states(prefix + "energy_apparentpower") %}
              {% set reactivepower = states(prefix + "energy_reactivepower") %}
              {% set factor = states(prefix + "energy_factor") %}
              {%- if(current|float == 0) -%}
                  off
              {%- elif(current|float < 0.2 and power|float < 10 and apparentpower|float < 30 and reactivepower|float < 30 and factor|float < 0.05) -%}
                  standby
              {%- elif(power|float > 100 or apparentpower|float > 50 or reactivepower|float > 50) -%}
                  running
              {%- elif(current_state == "off") -%}
                  {## could be on standby or running, but we just transitioned from off so assume running ##}
                  running
              {%- else -%}
                  {## Could be running on low power, or refreshing tumble dryer - no change ##}
                  {{ current_state }}
              {%- endif -%}
          {%- endif %}

Alerting

My first attempt used an automation to track everything and then send alerts, sleeping in between. Then I realised I could use the alert integration to do the regular announcements while a condition held.

To get the alerting, I need to track whether the machine was previously running when it enters standby state, and whether it is nighttime. The alert integration needs that to be made available as a boolean state. so time for another template sensor:

input_boolean:
  washing_on:
    name: "Washing machine running"
    icon: mdi:washingmachine
  night_mode:
    name: "Night mode"
    icon: mdi:weather-night

sensor:
  - platform: template
    sensors:
      washing_machine_ready:
        friendly_name: "Washing machine ready alert"
        delay_on: 00:04
        value_template: >-
          {{ is_state("input_boolean.washing_on", "on")
            and is_state("sensor.washing_state", "standby")
            and is_state("input_boolean.night_mode", "off")
          }}

And finally, the alert itself, which tells us how long the machine has been waiting:

alert:
  washing_machine_standby:
    name: "Washing machine on standby"
    entity_id: binary_sensor.washing_machine_ready
    repeat: 60
    can_acknowledge: true
    notifiers:
      - notify.household_speakers
    data:
      title: "Washing machine alert"
    message: >
      'Die Waschmaschine ist seit {{relative_time(states.sensor.washing_state.last_updated)|replace("hours","stunden")|replace("minutes","minuten")}}
      fertig
      '

Our smart speakers expect German language so I had to translate hours and minutes from the output of relative_time

Electricity costs

I also added template sensors to show how much it costs:

sensor:
      washing_cost_today:
        friendly_name: "Washing cost today"
        {## Multiply the electricity units used by price per unit ##}
        value_template: "{{- states('sensor.blitzwolf_sw1_energy_today') | float * 0.2745 | round(2, 'floor')  -}}"
        availability_template: >-
          {%- if not is_state("sensor.blitzwolf_sw1_status", "unavailable") %}
            true
          {%- endif %}
      washing_cost_yesterday:
        value_template: "{{- states('sensor.blitzwolf_sw1_energy_yesterday') | float * 0.2745 | round(2, 'floor')  -}}"
        availability_template: >-
          {%- if not is_state("sensor.blitzwolf_sw1_status", "unavailable") %}
            true
          {%- endif %}

This is what I have in the frontend interface:

Here is the Tasmota webpage with the machine on standby:

Screenshot_20201119_095243

2 Likes

Very nice, my next project. :slight_smile:

Looks good. A project in my future.
Thanks :slight_smile: