Hi Community,
i recently build an automation, which introduced a “Dishwasher status” based on its power consumption.
The Automation is split in 4 different parts, to represent each state of the current cylce.
To keep track of the dishwasher cycle, I utilized a input_select
helper, which has the following 4 states:
- idle
- running
- cleaning
- finished
a template sensor is derived from this input_select, to keep track of the changes.
It works pretty well:
Now i want to archieve to keep track of the runtime of each cycle, but i cant figure out how?
My idea is to utilize the last_changed
attribute of the sensor, to keep track of the changes.
Start: Switch idle -> running
End: Switch running -> finished
Subtract these two timestamps to get the runtime.
Automations
idle:
alias: Dishwasher Idle
description: ""
triggers:
- type: power
device_id: 0370e39c6053c1454a80f9cfae8b4895
entity_id: af61253b10feaf366e6318d6da69bfe9
domain: sensor
trigger: device
below: 1
for:
hours: 0
minutes: 10
seconds: 0
conditions:
- condition: state
entity_id: input_select.dishwasher_status
state: Finished
actions:
- action: input_select.select_option
metadata: {}
data:
option: Idle
target:
entity_id: input_select.dishwasher_status
mode: single
running:
alias: Dishwasher Running
description: ""
triggers:
- type: power
device_id: 0370e39c6053c1454a80f9cfae8b4895
entity_id: af61253b10feaf366e6318d6da69bfe9
domain: sensor
trigger: device
above: 10
for:
hours: 0
minutes: 0
seconds: 10
below: 100
conditions:
- condition: or
conditions:
- condition: state
entity_id: input_select.dishwasher_status
state: Idle
- condition: state
entity_id: input_select.dishwasher_status
state: Cleaning
actions:
- action: input_select.select_option
metadata: {}
data:
option: Running
target:
entity_id: input_select.dishwasher_status
mode: single
cleaning:
alias: Dishwasher Cleaning
description: ""
triggers:
- type: power
device_id: 0370e39c6053c1454a80f9cfae8b4895
entity_id: af61253b10feaf366e6318d6da69bfe9
domain: sensor
trigger: device
above: 1500
for:
hours: 0
minutes: 0
seconds: 10
conditions:
- condition: state
state: Running
entity_id: input_select.dishwasher_status
actions:
- action: input_select.select_option
metadata: {}
data:
option: Cleaning
target:
entity_id: input_select.dishwasher_status
mode: single
finished:
alias: Dishwasher finished
description: ""
triggers:
- type: power
device_id: 0370e39c6053c1454a80f9cfae8b4895
entity_id: af61253b10feaf366e6318d6da69bfe9
domain: sensor
trigger: device
above: 2
for:
hours: 0
minutes: 2
seconds: 0
below: 10
conditions:
- condition: state
entity_id: input_select.dishwasher_status
state: Running
actions:
- action: input_select.select_option
metadata: {}
data:
option: Finished
target:
entity_id: input_select.dishwasher_status
- action: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.dishwasher_cycles
- action: counter.decrement
metadata: {}
data: {}
target:
entity_id: counter.dishwasher_pods
mode: single