Hi,
I’m trying to build an automation which will allow me to monitor the state of a dishwasher. I’ve found a few online guides but whatever I try the automation never seems to fire.
Here is what i’ve put in place.
Firstly i’ve defined an input select to track the state:
input_select:
dishwasher_status:
name: Dishwasher Status
options:
- Idle
- Running
- Finished
initial: Idle
And then i’ve defined the automation itself. For the time being I have only made the automation which switches from ‘Idle’ to ‘Running’:
- alias: Set dishwasher active when power detected
trigger:
- platform: numeric_state
entity_id: sensor.dishwasher_watts
above: 6
action:
- service: input_select.select_option
data:
entity_id: input_select.dishwasher_status
option: Running
The sensor which monitors for the power is built using a template because the value itself comes from the switch (I think it’s a TP-Link HS110). Here is what the template looks like:
dishwasher_watts:
friendly_name_template: "{{ states.switch.dishwasher.name}} Current Consumption"
value_template: '{{ states.switch.dishwasher.attributes["current_power_w"] | float }}'
unit_of_measurement: 'W'
For the sake of testing i’ve actually plugged a lamp into the plug because it’s easier for me to toggle the state using such a device. Otherwise i’d have to wait for the dishwasher to complete a full cycle before I could test again. The lamp pulls just over 7 watts when on so i’d expect it to trigger the automation but nothing seems to happen.
Any clues are gratefully received ![:slight_smile: :slight_smile:](https://community.home-assistant.io/images/emoji/twitter/slight_smile.png?v=9)
I used a template sensor using the wattage as an input and the state of the sensor becomes idle, running, rinsing based on the wattage (trial and error). I can then use those states in automations
dishwasher_status:
friendly_name: "Dishwasher Status"
value_template: >-
{% if (states('sensor.dishwasher_power') |float) < 2 %}
Idle
{% elif ((states('sensor.dishwasher_power') |float) > 60) and ((states('sensor.dishwasher_power') |float) < 80) %}
Rinsing
{% else %}
Running
{% endif %}
I’m using the following for my washing mashine which is connected to a HS110 too. Since the power usage sometimes drops and then rises again, I need to wait a short time in order to make sure the state has really changed. I’ve got the time and the power for that after a little testing.
input_select:
status_waschmaschine:
name: Status Waschmaschine
options:
- Ausgeschaltet
- Stillstand
- Waschen
icon: mdi:washing-machine
sensor:
- platform: template
sensors:
waschmaschine_verbrauch:
friendly_name: Verbrauch Waschmaschine
entity_id:
- switch.waschmaschine
value_template: >-
{% if is_state('switch.waschmaschine', 'unavailable') %}
{{ 0.00 | float }}
{% else %}
{{ state_attr('switch.waschmaschine', 'current_power_w') | float }}
{% endif %}
unit_of_measurement: 'W'
icon_template: 'mdi:power-cycle'
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'
You need to make sure that the state of the watts-sensor is below 6 before going up. Otherwise the automation will not trigger.