State chage not triggering automation

Hi,
I’m testing an smtp notification for my Roomba to send out an email when the bin is full.

I’ve configured the automation :

  • entity : Roomba Bin Full
  • state trigger
  • when Roomba Bin Full state changes to “On”
  • send emaiil

the notification part is working, but the trigger isn’t.

When I don’t put any value of “On”, so it just triggers when it has “a” state change it does trigger.
But I only want it to trigger when it changes to “On”

On, Off, Unavailable are possible values, so that should be OK

Post the automation’s YAML.

Reference: FAQ Guideline 11, Format it properly

- id: '1677757132894'
  alias: Roomba Bin Full Notification
  description: ''
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.roomba_bin_full
    to: 'on'
  condition: []
  action:
  - service: notify.email_notification
    data:
      message: Roomba bin is full
      title: Roomba bin is full
  mode: single

What’s the current state value of binary_sensor.roomba_bin_full? It can be found in Developer Tools > States.

The automation you posted will trigger when the state of binary_sensor.roomba_bin_full changes to on. In other words, if it’s state is off or unavailable and then changes to on it will trigger the automation.

Default state when it’s connected is “Off”

I tried changing it via developer tools > states (change state from Off to On)
Changing the state itself works, but it doesn’t trigger the automation.

When configuring I also select the state from the dropdown, so i’d think that is correct

If you set it to 'On' it won’t work. Try setting it to 'on'.

It may be shown as “On” in the UI for “friendliness” but is 'on’ behind the scenes. Try vacuuming a lot and see what happens with a real state change.

1 Like

thanks!
It indeed does change to on in the configuration, so that’s ok.

I’ll leave it this way for some days to trigger a “real” bin full event, and will post back.

The YAML example you posted above shows that you already had the correct format on in the State Trigger.

When you select On in the UI, the Automation Editor actually saves it as on in the automation’s YAML.

If you want to test the automation’s trigger, go to Developer Tools > States and select binary_sensor.roomba_bin_full. It should appear in a form at the top the page. Assuming the binary_sensor’s state is currently off, change it to on then click the Set State button. That’s sufficient to trigger the automation’s State Trigger.

1 Like

thanks!
I already tested it that way, and set the state with the button.
It changes the value correctly, but doesn’t trigger the mail to be sent.

I hope it’ll trigger when it is full, and changes the state itself, but I doubt it.

The strange thing is, that if I don’t put any from / to status, so it just triggers on a changed state, it does send out the email.
But I don’t want to get an email if it goes to unavailable for example

Thanks everyone!
It’s working now!

I did an available home assistant update yesterday, and this morning another one was available.
Tested again, and it immediately triggers the event, so working correctly

Basically, nothing that was mentioned in this topic fixed the problem.

It fixed itself after you upgraded Home Assistant.

Is that correct?

I did some more testing to be sure, and the issue was indeed the use of the capital O for On.
I used that one in the developer mode, since it showed that way in the dropdown.

So basically when testing, I should always type small characters and no capitals?

The example you posted above contains on not On.

As I explained, it doesn’t matter if you select On from the available choices in the UI because the Automation Editor will save it as on in YAML. The proof is visible in what you posted.

If your example contained

to: 'On'

then it would not have triggered.
However it clearly shows it is

to: 'on'

indeed
But i guess the issue was with the value I entered with developer.
I used it with a capital there.

Look at what you wrote in your first post. It’s discussing the automation you created, namely the automation you posted containing this line:

to: 'on'

If you tested the automation by using Developer Tools > States to force the value of binary_sensor.roomba_bin_full to On then it will clearly not trigger the automation because it’s listening for on.

that one is the code from the yaml file itself in the fileshare, not from developer

And that was, as far as I can tell, the problem. OP was forcing a state change to “On” and not understanding why the automation wasn’t triggering. All sorted now.

Your latest reply suggests you misunderstood my post. However, no worries; the problem is solved.

yes, indeed
I sent the code from the wrong location :slight_smile:
Thanks for the assistance!

Just started out with HA, and now that this is working, I understand how it works, and can start my other automations :slight_smile:

Most important that I want to configure is to shutdown my pool heater in summer if I take too much power from the grid! … So still got some time :smiley: