Need Help Automating My Washing Machine with HS110

Hey Guys, I’ve seen a bunch of people setup automations for their washing machines to get an alert when it’s done, using a smart plug that monitors power usage. I’m trying to do the same thing but I’m having trouble with the automation side of things.

I’m a HA noob but an IT professional so I know enough to be dangerous, please bare with me… I am running HA 2021.1.5 and trying to create the automation through HA and not YAML

I purchased a TP-Link HS110 and I have it integrated into HA and I can monitor the watts, volts etc. Some might say the hard part is over but I can’t seem to get the automation working and I’ll admit this is my first attempt at a HA automation.

As a proof of concept I’m just trying to get HA to turn on or blink a light when the watts going through the smart plug drop from 100w to less than 3w, as I can see my washing machine idles around 2.24w but never constant 2.24 and when running is over 100w.

I set my trigger type to “state”, entity is “sensor.my_tp_switch_watts”, from is “100”, to is “<3” and then I have it set for “1 minute”. Then I just added an action to flash the kitchen ceiling light.

Can I use the > symbol? I tried without it and just left it at 3w but then realized the machine wouldn’t idle at 3w for 1 minute. Can I not enter a timeframe and just have the trigger go from 100w-3w?

If this is not the right way to do it please let me know, I’ve tried reading through other people experiences but a lot of those posts are from years ago and using YAML, I see a lot of people using True and False instead of number of watts but I don’t understand that.

Any help would be much appreciated!

Cheers,

Ted

Post what you have. If you are using the Automation Editor to compose the automation, click the Overflow menu (three vertical dots) in the extreme upper right hand corner and select ‘Edit as YAML’. Copy-paste the displayed code into the forum post. Be sure to preserve its formatting by selecting the pasted code and clicking the </> icon in the menu.

Thanks for the quick reply Taras, here’s the code, I added another, slightly different, action with another light to see if the action was the problem. Normally I’d just try variation after variation until it worked but for this one I need to run the washing machine to test, hoping you can help without me needing to run the washer 30 times…

alias: Washing Machine
description: ''
trigger:
  - platform: state
    entity_id: sensor.my_tp_switch_watts
    from: '100'
    for: '1'
    to: <3
condition: []
action:
  - type: flash
    device_id: 8d701462c012ee7019928728b75f0589
    entity_id: light.kitchen_ceiling
    domain: light
  - type: turn_on
    device_id: 3690def24c41d3aa1531f087be420e97
    entity_id: light.dining_table_light
    domain: light
    brightness_pct: 100
mode: single

I don’t recall the default time units used by for but the usual way to indicate a period of 1 minute is like this:

    for: '00:01:00'

or like this:

    for:
      minutes: 1

This is invalid:

    to: <3

The value for to must be a valid state value (for the given entity) and not an expression requiring evaluation. Even if it did allow for it, it would have to be in the form of a Jinja2 template.

One possible way to do this would be to use a Template Condition. In this example, it examines all of the sensor’s state-changes and use the condition to determine if it should proceed to the action.

alias: Washing Machine
description: ''
trigger:
  - platform: state
    entity_id: sensor.my_tp_switch_watts
condition: "{{ trigger.from_state.state | int == 100 and trigger.to_state.state | int < 3 }}"
action:
  - type: flash
    device_id: 8d701462c012ee7019928728b75f0589
    entity_id: light.kitchen_ceiling
    domain: light
  - type: turn_on
    device_id: 3690def24c41d3aa1531f087be420e97
    entity_id: light.dining_table_light
    domain: light
    brightness_pct: 100
mode: single

You could make the condition a bit more lenient by changing the first test to:
trigger.from_state.state | int > 99

Hmmmmm, very interesting…

I think I see what you’re doing here, I need to understand conditions better. Can I just copy and paste this into my automations.yaml file?

Cheers,

Ted

I did this just 2 weeks ago with the help of this thread.

123 Taras solution over there works just fine.

I then went a step further and implemented Bart_van_Vliet’s solution with great success. Only some recalibration of the power usage for our washing machine was needed.

1 Like