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: