Zone not working as trigger

Hello,

I have created an automation which should notify when people are entering different zones.
The gist of the automation is:

trigger:
  - platform: state
    entity_id:
      - person.mrX
    to: home
    id: mrX-Home
  - platform: state
    entity_id:
      - person.mrX
    id: mrX-work
    to: zone.work
...
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - mrX-work
        sequence:
          - service: tts.speak
            target:
              entity_id: tts.google_en_com
            data:
              cache: true
              media_player_entity_id: media_player.kodi
              message: mrX is back home
              language: en
      - conditions:
          - condition: trigger
            id:
              - mrX-work
        sequence:
          - service: tts.speak
            target:
              entity_id: tts.google_en_com
            data:
              cache: true
              media_player_entity_id: media_player.kodi
              message: mrX is at work
              language: en

The trigger with home works fine but triggers like zone. don’t get fired.

mrX has the companion app and I can track his whereabouts with fairly accurate precision.
If I check the map when mrX is at work it show he is … at work and when I use the Developer Tools the state shows as “work”.

What am I doing wrong?

You know that the state is 'work' and yet are looking for a state of 'zone.work'. Why?

Have you tried to: 'work' ? Or shorter (although I understand your code above is probably just an example):

trigger:
  - platform: state
    entity_id: person.mrx
    not_to: not_home
action:
  - service: tts.speak
    target:
      entity_id: tts.google_en_com
    data:
      cache: true
      media_player_entity_id: media_player.kodi
      message: mrX is at {{ states('person.mrx') }}
      language: en
2 Likes

Here’s a working blueprint where I do this stuff.
You are welcome to use it or use the code to get your stuff running.
Community link for my Person blueprint

1 Like

Hey @Troon thanks! It turns out that using the state without zone. and matching exactly the case for the name of the zone solves the problem.
My question is then what is the difference in using work and zone.work?

The main issue for me was that the autocompletion in the GUI, when creating automations, only shows a few states, namely:

  • home
  • away
  • unavailable
  • unknown

but none of the custom zone names. When checking the documentation I understood that for those I had to prefix them with zone. which in my understanding was sort of implicit in the predefined ones; home == zone.home

The way a state trigger works is that it looks at the state of the entity. When a device tracker is in a zone then the state is the friendly name of the zone, not the zone’s entity_id. See https://www.home-assistant.io/integrations/device_tracker#device-states

1 Like

I get what you say but home also has a friendly name, I called my HA “terra” so in the developer tools I have:
zone.home friendly_name: terra
but when I use it in automations I only specify home
for work I have:
zone.work friendly_name: work
and then I need to use the friendly name …

Read the link :wink: