Hello,
First post, and every bit the newbie.
I just configured an automation, based on code from some other post, to detect the washer machine start and ending, using the TPLink plugin to connect to a HS110 socket switch. The triggers are set up so that when power is more than 3 W for 1 minute, the machine is considered ON. When the power is less than 3W for more than 1 minute (and it was ON) the cycle has finished, so the boolean status flag is set to OFF and it sends a notification email. This all work successfully.
But now I would like to add some info to the notification email, in particular, the energy consumption for the finished cycle. In principle, it should be a simple calculation such as:
washer_dryer_total_kwh (at the time the washer finished) - washer_dryer_total_kwh (at the time the washer started).
What would be the easiest way to set up something like this…?
Thanks!
This is my relevant bits of the “configuration.yaml” file:
automation: !include automations.yaml
tplink:
discovery: false
switch:
- host: my.local.net.address
input_boolean:
washer_dryer_switch:
name: Power status
initial: off
icon: mdi:tumble-dryer
sensor:
- platform: template
sensors:
washer_dryer_amps:
friendly_name_template: "{{ states.switch.washer_dryer.name}} Current"
value_template: '{{ states.switch.washer_dryer.attributes["current_a"] | float }}'
unit_of_measurement: 'A'
washer_dryer_watts:
friendly_name_template: "{{ states.switch.washer_dryer.name}} Current Consumption"
value_template: '{{ states.switch.washer_dryer.attributes["current_power_w"] | float }}'
unit_of_measurement: 'W'
washer_dryer_total_kwh:
friendly_name_template: "{{ states.switch.washer_dryer.name}} Total Consumption"
value_template: '{{ states.switch.washer_dryer.attributes["total_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
washer_dryer_volts:
friendly_name_template: "{{ states.switch.washer_dryer.name}} Voltage"
value_template: '{{ states.switch.washer_dryer.attributes["voltage"] | float }}'
unit_of_measurement: 'V'
washer_dryer_today_kwh:
friendly_name_template: "{{ states.switch.washer_dryer.name}} Today's Consumption"
value_template: '{{ states.switch.washer_dryer.attributes["today_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
and this the relevant part of the “automations.yaml” file:
- id: washer_dryer_on
alias: Washer&Dryer On
trigger:
- above: '3'
entity_id: sensor.washer_dryer_watts
for:
minutes: 1
platform: numeric_state
action:
- entity_id: input_boolean.washer_dryer_switch
service: input_boolean.turn_on
- id: washer_dryer_off
alias: Washer&Dryer Off
trigger:
- below: '3'
entity_id: sensor.washer_dryer_watts
for:
minutes: 1
platform: numeric_state
condition:
- condition: state
entity_id: input_boolean.washer_dryer_switch
state: 'on'
action:
- entity_id: input_boolean.washer_dryer_switch
service: input_boolean.turn_off
- id: washer_dryer_done
alias: Washer&Dryer Done
trigger:
- entity_id: input_boolean.washer_dryer_switch
platform: state
to: 'off'
condition: []
action:
- data:
message: "Please remove the cloths"
title: "Washer&dryer has finised"
service: notify.notifier_email1