Use a TP-Link HS110 to monitor my washing machine

The automation runs nicely now without the delay period. I set the config to trigger a notification between 1.2 and 1.5 watts in the end so if I turn the machine on then off (and don’t set it running) I don’t get a notification. At idle the machine is between 0.9 and 1.1 watts and at the end of a cycle when the door is locked it’s between 1.2 and 1.5 watts.

1 Like

Further developments with the TP-Link HS110 plug:

I’ve implemented a 60 second delay for when the current is <1.5 watts at the end of the washing machine cycle to wait for the locked door to open. So I only get the notification after the door opens. Plus if I turn the machine on the off and don’t set a cycle running it doesn’t send a notification. I did this with the below code:

switch:
  - platform: tplink
    host: 192.168.1.206
    name: "Washing Machine"

sensor:
  - platform: template
    sensors:
      washing_machine_current:
        friendly_name: 'Washing Machine Current <1.5 watts'
        value_template: '{{ states.switch.washing_machine.attributes["Current consumption"] | replace(" W", "") | float <1.5 }}'

notify:
  platform: pushbullet
  api_key: xxxxx
  name: pushbullet

automation:
  - alias: "Notify when the washing machine cycle is complete"
    trigger:
      platform: state
      entity_id: sensor.washing_machine_current
      from: 'False'      
      to: 'True'      
      for:
        seconds: 60

action:
      service: notify.pushbullet
      data_template:
        title: "The washing machine has finished."
        message: "It's ready to be emptied"
4 Likes

Hmm, this the same guy who was about to give up? Now tweaking the code to make it even better!

Nice work man; glad you stuck with it!

2 Likes

It’s very rewarding when it works hence I stuck with it! I’ve now got it notifying Kodi when the washing machine door unlocks at the end of the cycle (so when I’m watching the TV an on screen message flashes up) as well as Pushbullet sending a notification to my phone (which is spoken out loud with TTS) and my PC.

I wasn’t able to have the same automation doing two actions, I think perhaps my formatting was off so I created a second duplicate automation for Kodi.

switch:
  - platform: tplink
    host: 192.168.1.206
    name: "Washing Machine"

sensor:
  - platform: template
    sensors:
      washing_machine_current:
        friendly_name: 'Washing Machine Current <1.5 watts'
        value_template: '{{ states.switch.washing_machine.attributes["Current consumption"] | replace(" W", "") | float <1.5 }}'

notify:
  - platform: pushbullet
    api_key: xxxxxx
    name: pushbullet

  - platform: kodi
    name: kodi
    host: 192.168.1.106
    port: 80

automation:
  - alias: "Notify Pushbullet when the washing machine cycle is complete"
    trigger:
      platform: state
      entity_id: sensor.washing_machine_current
      from: 'False'      
      to: 'True'      
      for:
        seconds: 55

    action:
      service: notify.pushbullet
      data_template:
        title: "The washing machine has finished."
        message: "It's ready to be emptied"
     
Automation 1:
  - alias: "Notify Kodi when the washing machine cycle is complete"
    trigger:
      platform: state
      entity_id: sensor.washing_machine_current
      from: 'False'
      to: 'True'
      for:
        seconds: 55

    action:
      service: notify.kodi
      data_template:
        title: "The washing machine has finished."
        message: "It's ready to be emptied"
3 Likes

Can you share - you automation scripts. Im setting this up as a request from my wife.

Thank you in advance.

Here’s the one for the washing machine

sensor:

washing_machine_watts:
  value_template: '{{ states.switch.hs110_washing_machine.attributes["current_consumption"] | replace(" W", "") | float }}'
  unit_of_measurement: 'W'   


# True when washer power level is below 3.4 watts, high threshold of resting state
# Default state is true
    washing_machine_power_down:
      value_template: "{{ states('sensor.washing_machine_watts') | int < 3.4 }}"

    washing_machine_power_up:
      value_template: "{{ states('sensor.washing_machine_watts') | int > 3.4 }}"


    stopwatch:
      friendly_name: "Time Elapsed"
      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 %}
      entity_id:
        - automation.stopwatch_start
        - automation.stopwatch_update
        - automation.stopwatch_stop

automation:
- alias: "Washing Machine Finish iOS Notification"
  hide_entity: true
  trigger:
    - platform: state
      entity_id: sensor.washing_machine_power_down
      from: 'False'
      to: 'True'
      for:
        minutes: 3
  condition:
    condition: state
    entity_id: input_boolean.washing_machine_switch
    state: 'on'
  action:
    - service: input_boolean.turn_off
      entity_id: input_boolean.washing_machine_switch
    - service: input_boolean.turn_off
      entity_id: input_boolean.stopwatch
    - service: notify.ios_jonos_iphone
      data_template:
        title: "Washing Done"
        message: "Time Taken: {{ states('sensor.stopwatch') }}"
        data:
    - condition: time
      after: '07:00:00'
      before: '22:30:00'
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.google_home
        volume_level: 0.27
    - service: tts.google_say
      entity_id: media_player.google_home
      data_template:
        message: "The Washing Machine has finished"
3 Likes

Thank you…

Where are the automations that you list under the entitys… I have tried your stop watch and get plenty of errors

Ooops, missed that out out!

automation:
  - alias: "Stopwatch Start"
    hide_entity: true
    trigger:
      platform: state
      entity_id: input_boolean.stopwatch
      to: "on"
    action:
      - service: input_boolean.toggle
        entity_id: input_boolean.dummy

  - alias: "Stopwatch Stop"
    hide_entity: true
    trigger:
      platform: state
      entity_id: input_boolean.stopwatch
      to: 'off'
    action:
      - service: input_boolean.toggle
        entity_id: input_boolean.dummy

  - alias: "Stopwatch Update"
    hide_entity: true
    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


input boolean:
  dummy:
    name: "Dummy"
    initial: off
1 Like

Thanks I had got

I’ve got alerting on my washing machine a couple of months ago as well. Now including a way to only alert the people at home, or wait until the first one comes home :sunglasses:

But… I’ve noticed that HA often sends me alerts during the night that the laundry is finished when it actually wasn’t in use.
It seems that every once in a while that plug has a small power peak (although i don’t see it in HA history) and that then triggers my automation:

automation:
  - alias: Action - Set washing machine as finished
    id: '1514637057229'
    trigger:
    - platform: numeric_state
      entity_id: sensor.washingmachine_watts
      below: '5'
      for:
        minutes: 5
    condition: []
    action:
    - service: input_boolean.turn_on
      entity_id: input_boolean.washingmachine_finished

I think setting a condition would solve the issue. A condition such as, if the power usage has been >0 W in the past 30 minutes. But this conflicts with the trigger. Any suggestions?

I’m having the same problem, random notifications. I’m thinking about setting up a trend or statistics sensor to sample and track the rise (and fall) of the power consumption over a 30 second period to determine whether the washer is off or on.

perhaps it’s a bit too late for you, but I’ve solved it with the following code that I put together in a package. It invokes a script that determines who to alert, but you can replace that with every type of notifier.
This code has been rock solid on me for over two months now.

#-------------------------------------------
#  Washing Machine Related Packages
# @Naveci
#-------------------------------------------

#-------------------------------------------

switch:
  - platform: tplink
    host: x.x.x.x
    enable_leds: true

sensor:
  - platform: template
    sensors:
      washingmachine_amps:
        value_template: '{{ states.switch.washing_machine.attributes.current_a}}'
        unit_of_measurement: 'A'
        friendly_name: 'Washing Machine ampère'
      washingmachine_volts:
        value_template: '{{ states.switch.washing_machine.attributes.voltage}}'
        unit_of_measurement: 'V'
        friendly_name: 'Washing Machine voltage'
      washingmachine_watts:
        value_template: '{{ states.switch.washing_machine.attributes.current_power_w}}'
        unit_of_measurement: 'W'
        friendly_name: 'Washing Machine current consumption'
      washingmachine_total_kw:
        value_template: '{{ states.switch.washing_machine.attributes.total_energy_kwh}}'
        unit_of_measurement: 'kWh'
        friendly_name: 'Washing Machine total consumption'

input_boolean:
  washingmachine_finished:
    name: Washingmachine Finished
    initial: off
  washingmachine_running:
    name: Washingmachine Running
    initial: off

input_select:
  washingmachine_status:
    name: Washingmachine Status
    options:
     - "Powered Off"
     - "Running"
     - "Finished"
    initial: "Powered Off"
    icon: mdi:washing-machine

#-------------------------------------------
group:
  washing machine:
    name: Washing Machine
    view: no
    entities:
      - sensor.washingmachine_amps
      - sensor.washingmachine_volts
      - sensor.washingmachine_watts
      - sensor.washingmachine_total_kw

#-------------------------------------------
automation:
  - alias: Action - Set washing machine to running
    id: '1514637041932'
    trigger:
    - platform: numeric_state
      entity_id: sensor.washingmachine_watts
      above: '5'
      for:
        minutes: 10
    condition: []
    action:
    - service: input_select.select_option
      data:
        entity_id: input_select.washingmachine_status
        option: "Running"

  - alias: Action - Set washing machine as finished
    id: '1514637057229'
    trigger:
    - platform: numeric_state
      entity_id: sensor.washingmachine_watts
      below: '10'
      for:
        minutes: 10
    condition:
    - condition: state
      entity_id: input_select.washingmachine_status
      state: "Running"
    action:
    - service: input_select.select_option
      data:
        entity_id: input_select.washingmachine_status
        option: "Finished"

  - alias: Notify - Washing machine finished
    id: '1514634021340'
    trigger:
    - platform: state
      entity_id: input_select.washingmachine_status
      to: "Finished"
    condition:
    - condition: state
      entity_id: group.hometracking
      state: 'home'
    action:
    - service: script.notify_engine_present_people
      data_template:
        title: 'Washing Machine:'
        message: "The washing program is finished. Please take out the laundry."
    - service: input_select.select_option
      data:
        entity_id: input_select.washingmachine_status
        option: "Powered Off"

  - alias: Notify - Washing machine finished when someone arrives
    id: '1514631344131'
    trigger:
    - platform: state
      entity_id: group.hometracking
      to: 'home'
    condition:
    - condition: state
      entity_id: input_select.washingmachine_status
      state: "Finished"
    action:
    - service: script.notify_engine_present_people
      data_template:
        title: 'Washing Machine:'
        message: "The washing program has been finished for {{ ((as_timestamp(now())-as_timestamp(states.input_boolean.washingmachine_finished.last_updated))/60)|round(0) }} minutes. Please take out the laundry."
    - service: input_select.select_option
      data:
        entity_id: input_select.washingmachine_status
        option: "Powered Off"

PS. the group home tracking is just a group that I put ourselves in to see whether anyone is home. Our own entities are filled by one or more devices as well. So for myself, I track my two phones and laptop to see if any of those three is home.

1 Like

Thanks @naveci. I have very similar code but it seems my Tasmota powered Sonoff POW is spiking at random times of the day which may be causing my random notifications.

image

I have a condition around my TTS notifications so they only fire between 0900 and 2000 which sorts most of it but I was looking to see if there way a way to average out these spikes to minimize the false detections. Like you, I track the power usage and when it’s low for 10 seconds I say it is ended.

- alias: 'Laundry: Washing Ends'
    trigger:
      - platform: numeric_state
        entity_id: sensor.washing_machine_power
        below: 10
        for:
          seconds: 10

I’ve just tweaked my on boolean so it looks for higher power usage and waits longer to trip the input boolean to mark the washing machine as active.

automation:
  - alias: 'Washing Begins'
    trigger:
      - platform: numeric_state
        entity_id: sensor.washing_machine_power
        above: 55
        for:
          seconds: 45

I had a similar issue with my Sonoff Pow on the washing machine @xbmcnut, solved the notification power spike issue by adding in a condition that the switch must be on for the notification to fire.

- alias: Washing has Finished - Jason
  hide_entity: true
  trigger:
    platform: state
    entity_id: binary_sensor.washing_machine_power
    from: 'off'
    to: 'on'
    for:
      minutes: 1
  condition:
    condition: state
    entity_id: switch.sonoff_pow_1
    state: 'on'
  action:
    service: notify.jason
    data:
      message: "The Washing has Finished"

Thanks @kanga_who. I should have posted my full code as I have that already but I sometimes get random notifications which shouldn’t happen.

automation:
  - alias: 'Washing Begins'
    trigger:
      - platform: numeric_state
        entity_id: sensor.washing_machine_power
        above: 55
        for:
          seconds: 45
    condition:
      - condition: state
        entity_id: input_boolean.washing_active
        state: 'off'
    action:
      - service: input_boolean.turn_on
        entity_id: input_boolean.washing_active

  - alias: 'Laundry: Washing Ends'
    trigger:
      - platform: numeric_state
        entity_id: sensor.washing_machine_power
        below: 10
        for:
          seconds: 10
    condition:
      - condition: state
        entity_id: input_boolean.washing_active
        state: 'on'
      - condition: time
        after: '09:00:00'
        before: '20:00:00'
    action:
      - service: tts.google_say
        entity_id:
          - media_player.kitchen_home
          - media_player.gaming_room_home
          - media_player.ensuite_speaker
        data_template:
          message: "The washing machine has finished"
      - service: input_boolean.turn_off
        entity_id: input_boolean.washing_active
1 Like

I had phantom “dryer done” notifications too. I noticed it wasn’t a spike but wifi dropout on the hs110 with the readings going from nothing to zero. I have my config for the hs110 documented here if anyone is interested http://inspectmygadgets.com/making-a-dumb-dryer-smart/

thanks to your guide explained in detail I managed to do everything perfectly without problems. Thank you so much for sharing!

1 Like

I had a problem with my dishwasher “powering down” and double triggering. Some sort of drying cycle I guess but it gave a false trigger of completing. I solved it by counting the power cycles using the variable component (a must have HA add-on IMHO).

Here is what I did:

Create the template sensor to represent the dish washer. On is based on trigger power level

  - platform: template
    sensors:
       appliance_washon:
        friendly_name: Appliance Dishwasher
        value_template: >-
          {% if is_state('switch.plug_158d00024ef7d1', 'off') %}
            off
          {% elif (states.switch.plug_158d00024ef7d1.attributes.load_power|float) < 10 %}
            standby
          {% elif is_state('switch.plug_158d00024ef7d1', 'on') %}
            on
          {% else %}
            failed
          {% endif %}

Added a variable to monitor false power downs

variable:
  washing_offcount:
    value: 0

Automation to alert when on. Note it will only alert if variable is 0. If 1 it is a “false start” and will be ignored

- id: '1537094498820'
  alias: DishOn
  trigger:
  - entity_id: sensor.appliance_dishon
    for:
      minutes: 1
    platform: state
    to: 'on'
  condition: []
  action:
  - below: '1'
    condition: numeric_state
    entity_id: variable.washing_offcount
  - data_template:
      message: dishwasher on {{ now() }}
    service: persistent_notification.create

Automation for when finished. It will only trigger when variable is 2.

- id: '1537094852909'
  alias: DishOff
  trigger:
  - entity_id: sensor.appliance_dishon
    for: 0:01:00
    from: 'on'
    platform: state
    to: standby
  condition: []
  action:
  - data:
      value_template: '{{ ((variable.state | int) + 1) }}'
      variable: washing_offcount
    service: variable.set_variable
  - above: '1'
    condition: numeric_state
    entity_id: variable.washing_offcount
  - data:
      value: '0'
      variable: washing_offcount
    service: variable.set_variable
  - data_template:
      message: dish off {{ now()}}
    service: persistent_notification.create

Lastly, in the event someone cancels mid-cycle, a timeout. The dish washer will power down for 10 minutes so a 15 minute timeout would indicate something abnormal.

- id: '1541081691156'
  alias: DishOffTimeout
  trigger:
  - entity_id: sensor.appliance_dishon
    for: 00:15:00
    platform: state
    to: 'off'
  condition: []
  action:
  - above: '0'
    condition: numeric_state
    entity_id: variable.washing_offcount
  - data:
      value: '0'
      variable: washing_offcount
    service: variable.set_variable
  - data_template:
      message: dishwasher off by timeout {{ now() }}
    service: persistent_notification.create

For notification just change the persistent_notification service to the notification of your choice.

Hope this helps.

This is what I recently created based on what I’ve found related to the TP-Link HS110 power plug. Maybe it’s useful.

I know, automation can be simplified so droger and wasmachine are together in a single automation, but that’s still on my todo list.