Numeric State Trigger Issue

I’m trying to run our robot vacuum when everyone leaves the house. The trigger is when the Numeric State of the zone is below 1, run the routine. I just ran a test, left the house, the zone went to 0, but the automation didn’t run. Any thoughts? Code below:

What entity are you using for a trigger? I think it’s zone.home that contains the number of people in the house.

In the UI that would give you “When [your zone name] is below 1”.


Zone.home

The attribute persons is a list of person entity IDs currently in the zone… it will never be a number below 1.

Leave the attribute field blank in the UI editor to trigger off the state, or just erase that line from the YAML:

trigger: numeric_state
entity_id:
  - zone.home
below: 1

When done properly, the expected description of the trigger should be “When Home is below 1”.

1 Like

Had to manually delete it and then it worked. Thanks!!

Why can’t the person attribute in the zone be below 1 of everyone left? Wouldn’t that be 0 at that point?

No it would be an empty list… it’s never a number.

1 Like

That makes sense, thanks again. Another question, now trying to do the opposite. When either person returns home, I want the Roomba to dock but only if both of us were gone as a qualifier. Here’s my current automation.

Currently if either of us comes home, but the other was already home, the Roomba docks (it basically makes a jet engine sound) every time. So I only want that to happen if both of us were gone to begin with.

I think that’s going to take a Template condition…

triggers:
  - trigger: numeric_state
    entity_id: zone.home
    above: 1
conditions:
  - condition: time
    before: "18:00:00"
  - condition: state
    entity_id: 
      - person.nick
      - person.b
    state: home
  - alias: The first person arrived home less than x minutes ago
    condition: template
    value_template: |
      {% set allowed_offset = 2 %}
      {{ now() - trigger.from_state.last_changed <= timedelta(minutes=allowed_offset)}}
actions:
#Your vacuum Dock actions

Do you think this will work?


If either person comes home and the vacuum is actively vacuuming, send them both home. If neither is vacuuming don’t run the routine. Will that logic work?

In the future please post properly-formatted YAML code instead of screenshots.

Your trigger could be a simple entity state trigger for the zone changing from 0 to 1.

I’d think you’d want to check for each vacuum cleaning separately, unless it’s not possible that only one is cleaning?

Something like this, but note that I don’t own a vacuum and don’t know what the appropriate states or actions are:

mode: single
triggers:
  - trigger: state
    entity_id:
      - zone.home
    from: "0"
    to: "1"
conditions: []
actions:
  - if:
      - condition: state
        entity_id: vacuum.roomba1
        state: "cleaning"
    then:
      - action: vacuum.dock
        target:
          entity_id: vacuum.roomba1
  - if:
      - condition: state
        entity_id: vacuum.roomba2
        state: "cleaning"
    then:
      - action: vacuum.dock
        target:
          entity_id: vacuum.roomba2