[Device Tracker] Associate a device tracker to different zone

I have two device_trackers pointing to two Mikrotik Access Points located in two different places (for example, Home and Work).
Through Home Assistant I have made sure that both are controlled through the device_tracker component.
I have some automations that are controlled by the presence or absence of a device in the home.
The same automations are however modified even if the device enters the area covered by the Access Point at “Work”
Is it possible to associate the second Access Point to a particular area and prevent it from interfering with the “Home” automation?
I would like a device state with three different state: home, work, not_home
Is it possible?
Thank you

So that’s a bit unclear. Let me see if I understand…

You have two device_tracker entities, one associated with an AP at home, and another with an AP at work. I assume they have two different entity_id’s, e.g., device_tracker.me_at_home and device_tracker.me_at work, is that right? Also, the first goes to the ‘home’ state when you’re at home, and the second goes to the ‘home’ state when you’re at work, is that right? Lastly, neither of these device_trackers have gps location information, is that right?

If I understood correctly, then I would suggest creating a template sensor and using that in your automations. Something like:

sensor:
  - platform: template
    sensors:
      my_loc:
        value_template: >
          {% if is_state('device_tracker.me_at_home', 'home') %}
            home
          {% elif is_state('device_tracker.me_at_work', 'home') %}
            work
          {% else %}
            not_home
          {% endif %}

Sorry pnbruckner, you’re right.
I try to explain myself in other words

This is my actual config:

configuration.yaml

device_tracker:
  - platform: mikrotik
    host: !secret mikrotik1_ipaddress
    username: !secret mikrotik1_username
    password: !secret mikrotik1_password
  - platform: mikrotik
    host: !secret mikrotik2_ipaddress
    username: !secret mikrotik2_username
    password: !secret mikrotik2_password

known_devices.yaml

mobile_phone:
  hide_if_away: false
  mac: AA:BB:CC:DD:EE:FF
  name: mobile_phone
  track: true

I have an automation with a trigger based on the status of the “mobile_phone”.
When the “mobile_phone” connects and disconnects from the “Home” Access Point, everything runs smoothly.
I do not want that when the “mobile_phone” is connected to the “Work” Access Point the status of “mobile_phone” becomes “home”, but remains “not_home” or changes from “not_home” to “work”.

Sorry, I forgot automation.yaml parts:

- id: '123456789'
  alias: Switch ON
  trigger:
  - entity_id: device_tracker.mobile_phone
    from: home
    platform: state
    to: not_home
  condition: []
  action:
  - data:
      entity_id: switch.home_switch
    service: switch.turn_on
- id: '987654321'
  alias: Switch OFF
  trigger:
  - entity_id: device_tracker.mobile_phone
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      entity_id: switch.home_switch
    service: switch.turn_off

@Kranzkie this might help you out, the template sensor that @pnbruckner mentioned in post #2 for your setup.

The problem is that the recognition of the device is done via Mac address, and therefore it is identical both at Home and at Work. I can not recognize which AP is connected to.
I can not understand how your solution can be integrated into this scenario.

Yes, given your clarifications, my solution won’t work. Honestly, I don’t know a lot about this type of device_tracker (since I don’t use it), but I’m not sure there is a way to tell which AP your device is connected to and have the corresponding device_tracker entity change state accordingly. Maybe someone else that uses this platform will know.

If you were using different device trackers then the scanner attribute could be used to work out which provided the update. Unfortunately using the same tracker at both locations rules that out.

I think it would be enough to include the IP address as an attribute (the two sites have different networks) or the AP hostname, but I have no idea if this is possible.

I created a Feature Request:

A post was split to a new topic: Alias with device trackers