Can´t get automation to trigger

Hello everyone,

So I am automating a push to ios, triggered by power usage drop - Well actually a push message to let me know when washing machine is done.

The push works when triggered manually, and the psuedo binary sensor works as intended - but I cannot make the trigger to trip no matter what I do. Please assist.

So first I define the psuedo binary sensor, which is set to true when the washing machine is off, and false when it is on (yeah I know, kinda upside down :slight_smile: )

binary_sensor:
  - platform: template
    sensors:
      washingmachine_idle:
        friendly_name: 'Washing Machine Idle'
        value_template: '{{ states.switch.tvattmaskin.attributes["current_power_w"] | replace(" W", "") | float < 1.5 }}'

And the automation:

automation:
  alias: wm_done
  trigger:
    platform: state
    entity_id: binary_sensor.washingmachine_idle
    to: 'True'
  action:
    service: notify.ios_ivans_iphone
    data:
      title: "Washing is done."
      message: "Washing machine stopped."

Any great ideas? :kissing_heart:

  trigger:
    platform: state
    entity_id: binary_sensor.washingmachine_idle
    to: 'on'

and verify the state of the automation is ‘on’, as well.

1 Like

Should you discover that your Template Binary Sensor fails to update itself (and only updates on startup) specify the entity_id so Home Assistant know what it should be monitoring.

binary_sensor:
  - platform: template
    sensors:
      washingmachine_idle:
        friendly_name: 'Washing Machine Idle'
        entity_id: switch.tvattmaskin
        value_template: "{{ state_attr('switch.tvattmaskin', 'current_power_w') | replace(' W', '') | float < 1.5 }}"

Without entity_id, Home Assistant inspects the value_template and attempts to find the entities that should be monitored for state-changes. If it is unsuccessful, the template binary sensor will only be updated once when Home Assistant starts and never again (until the next restart).

Thanks for you replies. No success though. Any more hacks?

Hm… I´m missing a dash or indent at alias - aint I?

not necessarily.

if you only have one automation then it’s not required. and if there was a problem with syntax the config check should throw an error. It’s not so I don’t think it’s that syntax issue.

maybe the issue is with the template itself?

post a screen shot of the “switch.tvattmaskin” in the dev states page with all of its attributes showing.

Paste this into Home Assistant’s Template Editor and confirm it reports either True or False

{{ state_attr('switch.tvattmaskin', 'current_power_w') | replace(' W', '') | float < 1.5 }}

It returns True.

Good! That means the template works properly.

When the Template Binary Sensor uses that template it will report True as on and False as off. Those are the two states you can use for triggering an automation.

washing%20snip

Usually not 0.00W

Ok, so changing back to True again. Any other ideas? I thought this should be an easy one… :slight_smile:

no don’t switch it to ‘true’. leave it to ‘on’. that’s what @123 was telling you.

A binary sensors reports its state as on or off. Just look in the States page and you’ll see that. Your automation’s trigger should use on.

binary_sensor:
  - platform: template
    sensors:
      washingmachine_idle:
        friendly_name: 'Washing Machine Idle'
        entity_id: switch.tvattmaskin
        value_template: "{{ state_attr('switch.tvattmaskin', 'current_power_w') | replace(' W', '') | float < 1.5 }}"


automation:
  alias: wm_done
  trigger:
    platform: state
    entity_id: binary_sensor.washingmachine_idle
    to: 'on'
  action:
    service: notify.ios_ivans_iphone
    data:
      title: "Washing is done."
      message: "Washing machine stopped."

while you are on the states page look to see what the current state of your “binary_sensor.washingmachine_idle” is? on or off? and does it exist?

I was wondering if the syntax of the template might be an issue. That’s why I was asking for that screen shot just to verify it wasn’t reporting in some weird json format that needed the square brackets.

washing%20idle%20snip

Yeah, nothing but the string True returns. No markup or any other chars.

I found a lost “binary_” in my text. Got overwritten in a save somehow, I guess. Testing that now. Again with your above ideas. Hold on :+1:

did you ever verify that the automation state was ‘on’? i don’t see an answer to that question i asked above.

Sorry, I replied with a screenshot of the state page entity, showing the binary_sensor as on. Maybe you searched for something else?

I amtracking the psuedo binary sensor as icon in home assistant card and it changes from on to off and back to on again as intended.

Is it possible to get extended log information? Right now it doesn´t show triggers etc…?