@turboc Your solution works like a charm, thanks!
I just implemented this, nice!
But it would be even nicer if we somehow could at a stopwatch so we could see running time, would that be possible?
I’ve been thinking about this too, using timestamps but haven’t had time to figure it out.
This could be done with IFTTT. You already have triggers to measure when the washer starts and stops, you could use this to automate timestamping on a Google Spreadsheet using IFTTT. Shouldn’t be too difficult
Not a bad solution, but I think we were both looking to do it within the framework of HA. But appreciate the idea; it may lead to something else. Thanks!
Check this out
input_boolean:
stopwatch:
name: Stopwatch
initial: off
dummy:
name: Dummy
initial: off
automation:
- alias: Stopwatch start
trigger:
platform: state
entity_id: input_boolean.stopwatch
state: "on"
action:
- service: input_boolean.toggle
entity_id: input_boolean.dummy
- alias: Stopwatch stop
trigger:
platform: state
entity_id: input_boolean.stopwatch
state: 'off'
action:
- service: input_boolean.toggle
entity_id: input_boolean.dummy
- alias: Stopwatch update
trigger:
platform: time
seconds: '/1'
condition:
condition: state
entity_id: input_boolean.stopwatch
state: 'on'
action:
service: input_boolean.toggle
entity_id: input_boolean.dummy
sensor:
- platform: template
sensors:
stopwatch:
friendly_name: "Stopwatch"
value_template: >
{% if is_state('input_boolean.stopwatch', 'on') %}
{{ (now() - states.automation.stopwatch_start.attributes.last_triggered).total_seconds() | int }}
{% elif is_state('sensor.stopwatch', 'unknown') %}
0
{% else %}
{{ states('sensor.stopwatch') }}
{% endif %}
unit_of_measurement: 'sec'
entity_id:
- automation.stopwatch_start
- automation.stopwatch_update
- automation.stopwatch_stop
group:
stopwatch:
name: Stopwatch
entities:
- input_boolean.stopwatch
- sensor.stopwatch
That creates a sensor to display the number of seconds since input_boolean.stopwatch was turned on. I’m sure someone could come up with a custom component that works better, but it was interesting that this is possible with just the components currently available.
This is very cool - thanks for sharing it!
I took a different approach due to the fact that my automation went crazy every now and then. I took:
sensor:
- platform: statistics
name: statistics op wasmachine value
entity_id: sensor.energy_washing_machine
And for the automation part
automation:
- alias: ‘Wasmachine notify’
trigger:
platform: numeric_state
entity_id: sensor.statistics_op_wasmachine_value_mean
below: 2
action:- service: notify.pushbullet
data:
title: “'Wasmachine”
message: “De wasmachine is klaar”
- service: notify.pushbullet
This is very useful, I’ve implemented it with the washing machine monitoring code (so starting the washing machine starts the timer)
Is there any way to format it from ‘2614 seconds’ to ‘26 mins 14 sec’?
Also, any way to take the final time taken and place it into a notification? (just format it to show in the notification)
Sure is. Just change the value template to something like
value_template: >
{% if is_state('input_boolean.stopwatch', 'on') %}
{{ relative_time(states.automation.stopwatch_start.attributes.last_triggered) }}
{% elif is_state('sensor.stopwatch', 'unknown') %}
0 seconds
{% else %}
{{ states('sensor.stopwatch') }}
{% endif %}
You’ll probably want to remove unit_of_measurement
then, as it won’t make sense anymore.
As for putting it in a notification, you should be able to just use a template for the message and put the value of the sensor, i.e. {{ states('sensor.stopwatch') }}
. Just be sure to use data_template
instead of just data
.
Great, thanks! I’ll try this later.
I’m curious as to what you will learn from getting the elapsed time. Not critical, actually curious what this may yield. If you find anything interesting by monitoring it, it would be great if you could share your findings.
after a few cycles we can calculate more or less how much time is left to finish the washing, or how many washing I can do till Im off to work/out… thats all I could think of
For me it’s nothing important. At the moment I don’t know how long a typical wash takes, but it seems like a long time.
Now that I can monitor how much electricity is used I’m thinking of comparing the ‘typical wash’ for time and electricity used versus the ‘quick wash’ on our washing machine. Maybe it’s worth using the quick wash more often (nearly all the time) if there’s a big difference between time and electricity used (or maybe not!)
Just out of curiosity, which Z-Wave outlet is everyone using?
Both of those ideas are great, thanks for the replies.
I’m using two Aeotec Smart Switch 6’s myself.
I’m using TP-Link HS110 smart plugs
Interesting. I have a few HS110s but I’m wondering how you get the current energy usage to show up in Home Assistant. When I include my HS110s in my configuration all that I can see/control is the on/off state of the HS110 switch. Any insight? If so, have a few HS110s laying around that I might be able to use for this. Thanks!
I copied the code for the sensors from rpitera above:
- platform: template
sensors:
kettle_watts:
value_template: '{{ states.switch.hs110_1_kettle.attributes["Current consumption"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
kettle_daily_kw:
value_template: '{{ states.switch.hs110_1_kettle.attributes["Daily consumption"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kW'
kettle_daily_cost:
value_template: '{{ (states.switch.hs110_1_kettle.attributes["Daily consumption"] | replace(" kW", "") | float * 0.084) | round(2) }}'
unit_of_measurement: 'p'
kettle_amps:
value_template: '{{ states.switch.hs110_1_kettle.attributes["Current"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
kettle_kw:
value_template: '{{ states.switch.hs110_1_kettle.attributes["Total consumption"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kW'
kettle_volts:
value_template: '{{ states.switch.hs110_1_kettle.attributes["Voltage"] | replace(" V", "") | float }}'
unit_of_measurement: 'V'
washing_machine_watts:
value_template: '{{ states.switch.hs110_2_washing_machine.attributes["Current consumption"] | replace(" W", "") | float }}'
unit_of_measurement: 'W'
washing_machine_daily_kw:
value_template: '{{ states.switch.hs110_2_washing_machine.attributes["Daily consumption"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kW'
washing_machine_daily_cost:
value_template: '{{ (states.switch.hs110_2_washing_machine.attributes["Daily consumption"] | replace(" kW", "") | float * 0.084) | round(2) }}'
unit_of_measurement: 'p'
washing_machine_amps:
value_template: '{{ states.switch.hs110_2_washing_machine.attributes["Current"] | replace(" A", "") | float }}'
unit_of_measurement: 'A'
washing_machine_kw:
value_template: '{{ states.switch.hs110_2_washing_machine.attributes["Total consumption"] | replace(" kW", "") | float }}'
unit_of_measurement: 'kW'
washing_machine_volts:
value_template: '{{ states.switch.hs110_2_washing_machine.attributes["Voltage"] | replace(" V", "") | float }}'
Many Thanks! Below is my config...
**sensor.yaml**
# Value Template
- platform: template
sensors:
dryer_on:
value_template: "{{ states('sensor.dryer_power') | int > 3 }}"
washer_on:
value_template: "{{ states('sensor.washer_power') | int > 3 }}"
**automation.yaml**
# Dryer On
- alias: Dryer On
trigger:
platform: state
entity_id: sensor.dryer_on
to: 'True'
action:
service: input_boolean.turn_on
entity_id: input_boolean.dryer
# Dryer Off
- alias: Dryer Off
trigger:
platform: state
entity_id: sensor.dryer_on
to: 'False'
condition:
condition: state
entity_id: input_boolean.dryer
state: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.dryer
- service: notify.sms
data: { "message": "Dryer finished.", "target": [ "+##########", "+##########" ]}
# Washer On
- alias: Washer On
trigger:
platform: state
entity_id: sensor.washer_on
to: 'True'
action:
service: input_boolean.turn_on
entity_id: input_boolean.washer
# Washer Off
- alias: Washer Off
trigger:
platform: state
entity_id: sensor.washer_on
to: 'False'
for:
minutes: 3
condition:
condition: state
entity_id: input_boolean.washer
state: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.washer
- service: notify.sms
data: { "message": "Washer finished.", "target": [ "+#########", "+##########" ]}