Use a TP-Link HS110 to monitor my washing machine

See my blog post here regarding my Sump Pump, it’s nearly identical to a washing machine, however you’ll have to play around with the delay and period where the washhing machine returns to zero when the cycle is complete. I would reccomend using an input_bolean for that - flip it on when the cycle starts, flip it off when you are sure that it is finished (based on power draw from the HS110).

I was following this post on how to set up washer/dryer notifications and it just doesn’t like this part:

- alias: 'Dryer Done'
  trigger:
    platform: state
    entity_id: sensor.aeotec_smart_switch_6_power_11
    state: '0.0'
  condition:
    condition: state
    entity_id: input_boolean.dryer_switch
    state: 'on'
  action:
    - service: notify.pushbullet
      data:
        message: 'Robert, the dryer is done.'
    - service: input_boolean.turn_off
      entity_id: input_boolean.dryer_switch

When I do a validation it says that state is not valid and I think it means state: '0.0'
I am assuming things might have changed syntax wise in time, any idea what’s the correct automation for the dryer? Thanks in advance :slight_smile:

Is the state of your sensor really a string with the text ‘0.0’?

Or is it a numeric value?

Made some changes to what @rpitera had above, so that it looks like the washing machine automation and it now works.

Hi there,

i am also trying to monitor my washingmachine with a tp-link-hs110.
i cannot get it working, my ‘ashing Machine Current <1.5 watts’ entitiy keeps saying TRUE also when the machine is running.

i have added a part of my config.yaml below:

Configuration. yaml:

 #Wasmachine
      washing_machine_current:
        friendly_name: 'Wasmachine Uit'
        value_template: '{{ states.switch.wasmachine.attributes["current power w"] | replace(" W", "") | float <1.5 }}'
        unit_of_measurement: 'W' 
         
# Wasmachine
switch:
  - platform: tplink
    host: 192.168.1.24
    name: "Washing Machine"

notify:
  - platform: pushbullet
    api_key: xxxxxxxxxxxxxxxxxxxxxx
    name: pushbullet
> Automation.yaml:
> - id: '1600266834522'
>   alias: Bericht wasmachine gereed
>   description: ''
>   trigger:
>   - entity_id: sensor.washing_machine_current
>     for: '60'
>     from: 'False'
>     platform: state
>     to: 'True'
>   condition: []
>   action:
>   - data_template:
>       message: Wasmachine kan leeggemaakt worden
>       title: Wasmachine gereed
>     service: notify.pushbullet
>   mode: single
> - id: '1600326684866'
>   alias: Bericht Wasmachine gereed - Google home
>   description: ''
>   trigger:
>   - entity_id: sensor.washing_machine_current
>     for: '60'
>     from: 'False'
>     platform: state
>     to: 'True'
>   condition: []
>   action:
>   - data_template:
>       message: Hello, the Washingmachine is ready
>     entity_id: media_player.huiskamer_thuis
>     service: tts.google_say
>   mode: single

Can someon point me in the good direction?
thanks!

I think i found it, the attribute needs underscores ‘current_power_w’
Going to test it again.

Hi Tom, question, why don’t you merge the two automations into one? Is there are reason for it?

Your template sensor could be a binary sensor as well.

Hello. I’ve been banging my head against the wall. I can see the tp_link HS110. No problem. I created the template and can see the entities, but they are constantly empty. Nothing ever changes. I feel like I’m missing something. Here’s the portion of configuration.yaml. Thanks for any direction you can set me in.

sensor:
  - platform: template
    sensors:
      washingmachine_amps:
        value_template: '{{ states.switch.washing_machine.attributes.current_a}}'
        unit_of_measurement: 'A'
        friendly_name: 'Washing Machine Amps'
      washingmachine_volts:
        value_template: '{{ states.switch.washing_machine.attributes.voltage}}'
        unit_of_measurement: 'V'
        friendly_name: 'Washing Machine Volts'
      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'

If you don’t need to expose the individual attributes through the UI, I would remove the templates and just test the sensors directly in your automations.

If you go into Developer Tools -> States and choose your HS110 from the drop-down list, you’ll see the entity ID as well as the names of the relevant attributes. Make sure that the attributes you are testing (e.g. states.switch.washing_machine.attributes.current_a) match up with the entity ID and attribute names in the States page.

You can also use the States page to monitor the current data in the various attributes, whcih will rule out some potential causes of the problem (e.g. if your HS110 is not reporting energy consumption, or can’t connect to your network, then the States page will also show everything as 0; but if the States page shows correct data then you know the problem is with your templates).

Hi. I went into Developers Tools - > States and all I see for my switch.washing_machine is my friendly name. Nothing else. I removed the templates and restarted and its the same thing. No states.
Does it matter that the device was added through the TP-LINK Kasa integration rather than manually adding it? As I mentioned, I can see and control the switch through HA without issue.

Yes, that will be the cause of the problem - but I’m not sure how to fix it, maybe someone with more knowledge of this specific device can help.

If you can see the device in Lovelace then you may be able to find the correct entity ID and attribute names by editing the relevant Lovelace card?

I found the problem…I have the wrong plug. I THOUGHT I was buying an HA110 but I got an HS100.
Sorry for the “stupid user” error and thank you for your help.

Hi,

i am a beginner with yaml, so if you got tips how to improve it. please let me know.

Hey @dennis84de, could you please offer some insights to this?

I am trying to create a binary sensor for SmartIR to understand if the AC connected to the HS110 plug draws power (more than 10 watts) so to report the AC as “on” and if it is less than 10 watts to report as “off”.

I am using the standard configuration to get all the power values from the plug and I added the binary sensor but I cannot make it show up as False. It is always “True” even if the current consumption in watts is less than 10.

Here is what I have in my configuration.yaml

# TP-Link HS110 energy monitoring
sensor:
  - platform: template
    sensors:
      ac_bedroom_amps:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Current"
        value_template: '{{ states.switch.ac_bedroom.attributes["current_a"] | float }}'
        unit_of_measurement: 'A'
      ac_bedroom_watts:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Current Consumption"
        value_template: '{{ states.switch.ac_bedroom.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'
      ac_bedroom_total_kwh:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Total Consumption"
        value_template: '{{ states.switch.ac_bedroom.attributes["total_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      ac_bedroom_volts:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Voltage"
        value_template: '{{ states.switch.ac_bedroom.attributes["voltage"] | float }}'
        unit_of_measurement: 'V'
      ac_bedroom_today_kwh:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Today's Consumption"
        value_template: '{{ states.switch.ac_bedroom.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      ac_bedroom_current:
        friendly_name_template: 'AC Bedroom <10 watts'
        value_template: '{{ states.switch.ac_bedroom.attributes["Current consumption"] | replace(" W", "") | float <10 }}'

Do you have any idea of what is wrong?

Thank you

We would need to see the config of the binary sensor… do you get the proper values for these sensors or are these not working either?

Actually, my config for the binary sensor are the last 3 lines in my above.

ac_bedroom_current:
  friendly_name_template: 'AC Bedroom <10 watts'
  value_template: '{{ states.switch.ac_bedroom.attributes["Current consumption"] | replace(" W", "") | float <10 }}'

Obviously I missing some values to make the sensor report as “False” instead of always “True”.

You need to make this a binary sensor.

binary_sensor:
  - platform: template
    sensors:
      ac_bedroom_current:
        friendly_name_template: 'AC Bedroom <10 watts'
        value_template: '{{ states.switch.ac_bedroom.attributes["Current consumption"] | replace(" W", "") | float <10 }}'

Hi @dennis84de,

Thank you for pointing me to the right direction. Indeed that did the trick after fiddling a bit with my code.

So, I used the "current_power_w"attribute that was already used in the initial code for the HS110 sensor to display the current consumption in watts and I also had to reverse the “<10” symbol to “>10” in order for it to report the “ON” or “OFF” state correctly.

This is what my binary sensor code looks like now:

# TP-LINK HS110 as binary sensor
binary_sensor:
  - platform: template
    sensors:
      ac_bedroom_current:
        friendly_name: 'Bedroom AC state'
        value_template: '{{ states.switch.ac_bedroom.attributes["current_power_w"] | float >10 }}'

And this is what I have for the HS110 as posted in the integration’s page:

# TP-Link HS110 energy monitoring
sensor:
  - platform: template
    sensors:
      ac_bedroom_amps:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Current"
        value_template: '{{ states.switch.ac_bedroom.attributes["current_a"] | float }}'
        unit_of_measurement: 'A'
      ac_bedroom_watts:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Current Consumption"
        value_template: '{{ states.switch.ac_bedroom.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'
      ac_bedroom_total_kwh:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Total Consumption"
        value_template: '{{ states.switch.ac_bedroom.attributes["total_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      ac_bedroom_volts:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Voltage"
        value_template: '{{ states.switch.ac_bedroom.attributes["voltage"] | float }}'
        unit_of_measurement: 'V'
      ac_bedroom_today_kwh:
        friendly_name_template: "{{ states.switch.ac_bedroom.name}} Today's Consumption"
        value_template: '{{ states.switch.ac_bedroom.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'

I don’t know if what I did is a good Yaml practice but as long as it works, I am happy with that.

Next up I am going to see how to integrate this state to the SmartIR addon but this is for another topic.

Thank you for your help.

Hi there,

the config worked fine, but since a month or two it does not work anymore.
Has something been changed with HA and TP link?

#Wasmachine
washing_machine_current:
friendly_name: ‘Wasmachine Off’
alue_template: ‘{{ states.switch.wasmachine.attributes[“current_power_w”] | replace(" W", “”) | float <1.5 }}’
unit_of_measurement: ‘W’