Home Assistant Community

Can´t get automation to trigger

automation
Tags: #<Tag:0x00007f3754fc0318>
#1

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:

0 Likes

#2
  trigger:
    platform: state
    entity_id: binary_sensor.washingmachine_idle
    to: 'on'
0 Likes

#3

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

1 Like

#4

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).

0 Likes

#5

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

0 Likes

#6

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

0 Likes

#7

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.

0 Likes

#8

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 }}
0 Likes

#9

It returns True.

0 Likes

#10

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.

0 Likes

#11

washing%20snip

Usually not 0.00W

0 Likes

#12

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

0 Likes

#13

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

0 Likes

#14

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."
0 Likes

#15

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?

0 Likes

#16

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.

0 Likes

#17

washing%20idle%20snip

0 Likes

#18

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:

0 Likes

#19

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

0 Likes

#20

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…?

0 Likes