Not_home to home with mqtt and owntracks not working for me

I have a typical setup with Owntracks send mqtt message to my Cloudmqtt account. I setup a trigger with the transition from not_home to home state but it does not work. My state does change to home when I get within the assigned radius form home, but the state just before is not “not_home” but a mqtt message showing the location. Just before that mqtt message, the state is “not_home”. But since the transition is not from not_home to home the trigger never occurs. So why the state while I am still not home shows as the actual mqtt message? It should show as not_home.

Here is part of my configuration:

  - platform: owntracks
  - platform: mqtt
        qjvvyniw_phonebm: owntracks/qjvvyniw/PhoneBM

  port: HIDDEN
  client_id: qjvvyniw_phonebm
  keepalive: 60
  username: HIDDEN
  password: HIDDEN

  name: Home
  latitude: HIDDEN
  longitude: HIDDEN
  radius: 450
  icon: mdi:home

automation 3:
alias: Open garage when I arrive home
platform: state
entity_id: device_tracker.qjvvyniw_phonebm
from: ‘not_home’
to: ‘home’
- condition: time
after: ‘17:00:00’
before: ‘19:00:00’
- mon
- tue
- wed
- thu
- fri
service: shell_command.garage

This is how it looks like just before my state changed to home:

Any idea what is going on.

I’m no expert but instead of state change from “not_home” to “home” I use something like this

    - platform: zone
      entity_id: device_tracker.owntracks_MYPHONE
      zone: zone.home
      event: enter

So the platform zone instead of the platform state and this works for me

I am trying to set up the zone.home enter/leave. My owntracks setup uses iBeacons as a “-home” waypoint. I get the messages coming onto HA but the automations are not triggering using the enter/leave message. I can get them to trigger if I send a message via the cloudmqtt console with a modified GPS location ( to simulate a different location ) but thought that this should be overridden by the zone.home trigger.

Can you help guide me on how to debug this.

My automation.yaml

- alias: Leave
    platform: zone
    entity_id: device_tracker.phone_samsiphone
    zone: zone.home
    event: leave  
#    platform: state
#    entity_id: device_tracker.phone_samsiphone
#    from: 'home'
#    to: 'not_home'
#    for:
#      minutes: 4
    - service: switch.turn_off
        - group.living_room
        - group.bedroom
        - switch.study_airconditioner

- alias: Return
#    platform: state
#    entity_id: device_tracker.phone_samsiphone
#    from: 'not_home'
#    for:
#      minutes: 4
#    to: 'home'
    platform: zone
    entity_id: device_tracker.phone_samsiphone
    zone: zone.home
    event: enter
    - service: switch.turn_on
        - switch.living_room_fan
        - switch.living_room_lamp
    - service: script.turn_on
        - script.turn_on_bredroom_fan
        - script.turn_on_sound_bar

My zones.yaml

- name: home
  latitude: !secret homeassistant_latitude
  longitude: !secret homeassistant_longitude
  radius: 200
  icon: mdi:home