I have my washing machine plugged into a tasmota flashed smart plug that reports electricity usage. I am able to see how much power is being used in order to tell if the washing machine is running or not. The problem is that during the cycle the power usage will drop to the same amount as it is at when it is off. When it is off it usually draws between 0.054 and 0.06 amps. When it is running it will go from 0.054 to 2 amps throughout the cycle. Due to this issue I can’t use a simple threshold binary sensor. There must be a way to use a template sensor, but I have not been able to figure anything out that is consistent. Here is my latest attempt:
washing_machine:
value_template: >-
{% set amps = states("sensor.sonoff_energy_current_2") | float %}
{% set time_now = as_timestamp(now()) | float %}
{% set time_washing_machine_last_changed = as_timestamp(states.binary_sensor.washing_machine.last_changed) | float %}
{% set time_diff = time_now - time_washing_machine_last_changed %}
{% if amps > 1 %}
On
{% elif amps < 0.07 and time_diff > 600 %}
Off
{% endif %}
How do I get this to work?