Use a TP-Link HS110 to monitor my washing machine

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.

i am new to the smart home, but think is fun, i just got my TP-link HS110 and what to monitor the washing machine.
I now have it set up using entities card, not the most fun. But i need some help, i just got 1 senor of it/ entities. how do i split in to more?

You need to follow the tplink component setup guide, specifically the “Extracting Energy Sensor data” which will break out the values for you to use. I just came across this post only because amazon have these @£19 currently.

i think i am missing something, but can see what. i copy @naveci as mutch i understand…
any one see what i missing?

- id: '1562882387947'
  alias: Ny automation
  trigger:
  - above: '5'
    entity_id: sensor.my_tp_switch_watts
    platform: numeric_state
  condition: []
  action:
  - below: '4'
    condition: numeric_state
    entity_id: sensor.my_tp_switch_watts
  - alias: ''
    data:
      message: Testing testing 1-2-3
      title: This is a message
    service: notify.mobile_app_min_lur_ip_x 

Hi,

im using this code for my television and i love it. But i have 1 Problem inside of this part:

  - platform: template
    sensors:
      theframe_status_time:
        friendly_name: "The Frame Laufzeit"
        unit_of_measurement: 'Minuten'
        value_template: >-
          {%- if is_state('input_boolean.theframe', 'on') -%} {{ ((as_timestamp(now())-as_timestamp(states.input_boolean.theframe.last_changed))/60) | round | int }}
          {%- else -%} 0
          {%- endif -%}

In my Lovelace, its always showing 0. In my Message-automation its working and when i put the code into the template editor, it is showing up correctly. Do you have an idea? Only in Lovelace is al the time 0

Hi Erger, currently Im facing the same issue. Also Im using mean from the statistics sensor, and that doesn’t work wel either since a week or two. I planned to check on this Tonight, so expect an updated automation at the end of the day :smiley:

1 Like

Try adding the entity_id to the template sensor:

  - platform: template
    sensors:
      theframe_status_time:
        friendly_name: "The Frame Laufzeit"
        unit_of_measurement: 'Minuten'
        entity_id: input_boolean.theframe
        value_template: >-
          {%- if is_state('input_boolean.theframe', 'on') -%} {{ ((as_timestamp(now())-as_timestamp(states.input_boolean.theframe.last_changed))/60) | round | int }}
          {%- else -%} 0
          {%- endif -%}

I tried it, but still the same error.

Hi xirixiz. I was wondering why you’re using the statistics mean value, and not just the sensor.wasmachine_watts? I’m a beginner when it comes to HA, so this is a genuine question. I’m looking for a way for it to report to me faster when my washing machine is done. Wouldn’t the wasmachine_watts below 5 watts for 5 minutes be just as accurate, but much faster?

Also I noticed you do a homeassistant.turn_on on your input_booleans, but no homeassistant.turn_off when finished. Is there a reason for that?

@Rourke after troubleshooting automation that based heavily on @xirixiz … i yesterday gave up and came to same conclusion - and am now using direct sensor.washmachine_watts in a similar manner as you proposed… So far so good.

Btw - in my config I have homeassistant.turn_off … are you sure you did not miss it when copy pasting ?

BTW - the problem I had with platform: statistics … is that when my waschmachine finishes, it drops power usage (watts) to 0. And my tplink does only one status update (from whatever watts to 0),then nothing more (because state is still at 0 - so no change). Which essentially prevents statistics module to correctly calculate average… :frowning:

Good you got it working with watts. The mean value works for me, but it can easily take 10-15 minutes before it triggers the finished script. I don’t think I recognize the behavior you described in your last part of your post. It’s still considering 0 watts as part of the average/mean value as far as I know.

I’m still wondering why @xirixiz prefers the mean value. Perhaps it solves a problem in a situation I haven’t encountered yet.

But I’m gonna change it to watts and see how it works in my case.

Looking into the linked yaml file from xirixiz I don’t actually see a turn_off on the input_boolean of the wasmachine. I had to add it myself in the finished automation action. Not a problem really. :slight_smile:

@Rourke
Just a partial answer because I also use statistics and the mean value… for me the watts were all over the place, so using the statistics sensor it leveled it out enough that I could have cycle progress, like Washing, Rinsing, Spinning (although I never really finished perfecting it, it does somewhat represent what it’s doing) the most important part for me is that when my washer is done it leaves a green LED on until we open it again to remove the clothes. The statistics sensor allowed me to very accurately detect if that light is on, so we get reminders that there are wet clothes in the washer that need to be moved to dryer.

1 Like

This post is directed at the novice: I have been perusing this thread as I have recently purchased the TP110 plug specifically for laundering needs. There’s a lot of chatter about “inputs,” “booleans,” “template sensors,.” Since these plugs extract the info to HA by default, I just created an automation (ie “Washer-Clean”) that is based on numerical value for watts, with the amps used as the condition. I have yet to test this, and it might require more conditions, but it seems pretty logical to me.

Don’t mean to drift the thread but I have some of these; have you seen the load recommendations in the manual?

Supported Load Types:
Coffee Maker: 800 W
Desk Lamp: 235.2 W
LCD: 270 W
Heater: 1500 W
Humidifier: 260 W
Iron: 1500 W
Toaster: 850 W
Tower Fan: 50 W

I’d love to use one on my washer/dryer but haven’t dared due to this. Can anyone in the know with electrics share some wisdom? Don’t want anyone burning down their house!