Owntracks, presence, and zones

I’ve been playing with Owntracks, and getting confused. At first, I installed the program on my and my wife’s iPhones, and labeled “home” as a region in Owntracks. HA then had a device_tracker entity for each of us that displayed on the front page as “home” or “away”.

My office is in the basement of a building, so there’s no gps signal. I added an iBeacon there,created a region in Owntracks called “J Work” and associated it with that iBeacon.

Now, in HA, I seem to have 4 device_tracker items on my entities screen:

|[device_tracker.jgalak_e251REDACTED5f6](https://REDACTED.duckdns.org:8123/dev-state#)|not_home|source_type: bluetooth_le latitude: REDACTED longitude: REDACTED gps_accuracy: 65 battery: 81 friendly_name: jgalak|

|[device_tracker.jgalak_e251REDACTED5f6](https://REDACTED.duckdns.org:8123/dev-state#)|J Work|source_type: bluetooth_le latitude: REDACTED longitude: REDACTED gps_accuracy: 100 battery: 94 velocity: 5 tid: jg course: 240 friendly_name: jgalak|

|[device_tracker.lkw_881REDACTEDaad](https://REDACTED.duckdns.org:8123/dev-state#)|home|source_type: gps latitude: REDACTED longitude: REDACTEDgps_accuracy: 1414 battery: 10 friendly_name: lkw|

[device_tracker.lkw_881REDACTEDaad](https://REDACTED.duckdns.org:8123/dev-state#) not_home source_type: null friendly_name: lkw

and 4 sensor icons showing up on the first page, two for me two for her, one for each shows “home” or “away”, one for me shows “j work” or “away”, and the third for her is always “away”.

Note that the iBeacon is not set up on her phone.

Is this correct? Do I get one item for each region/person combination? Or is there a way to get it to just have one entity per person showing where the person is? That seems more useful, something that, right now, would show me as either “home”, “away”, or “j work”.

Here’s the relevant bits of configuration.yaml:

owntracks:
    max_gps_accuracy: 200
    waypoints: true
    mqtt_topic: "owntracks/#"


zone:
  - name: J Work
    latitude: REDACTED
    longitude: REDACTED

Is there a way to fix this?

You can merge them with a template sensor I have done something similar granted home/away status is performed by node-RED but the templating will help you to merge them into one entity with multiple states.

Template - So the james_bayesian is done by node-red and determines that I’m home/away and the huawei_h10 is my gps tracker which will show my location away from home.

  - platform: template
    sensors:
      james:
        friendly_name: "James"
        value_template: >-
          {% if is_state('device_tracker.james_bayesian', 'home') %}
            Home
          {% elif is_state('device_tracker.huawei_h10', 'Powertec') %}
            Powertec
          {% elif is_state('device_tracker.huawei_h10', 'Kindy') %}
            Kindy
          {% elif is_state('device_tracker.huawei_h10', 'Stocklands') %}
            Stocklands
          {% elif is_state('device_tracker.huawei_h10', 'Parlour') %}
            Parlour
          {% elif is_state('device_tracker.huawei_h10', 'Work Home Beacon 25mins') %}
            25mins Away
          {% elif is_state('device_tracker.huawei_h10', 'Work Home Beacon 15mins') %}
            15mins Away
          {% elif is_state('device_tracker.huawei_h10', 'Work Home Beacon 5mins') %}
            5mins Away
          {% elif is_state('device_tracker.huawei_h10', 'Darwin') %}
            Darwin
          {% elif is_state('device_tracker.huawei_h10', 'Brisbane') %}
            Brisbane
          {% elif is_state('device_tracker.huawei_h10', 'Sydney') %}
            Sydney
          {% elif is_state('device_tracker.huawei_h10', 'Melbourne') %}
            Melbourne
          {% elif is_state('device_tracker.huawei_h10', 'Perth') %}
            Perth
          {% elif is_state('device_tracker.huawei_h10', 'Adelaide') %}
            Adelaide
          {% elif is_state('device_tracker.huawei_h10', 'Tasmania') %}
            Tasmania
          {% elif is_state('device_tracker.huawei_h10', 'UK') %}
            UK
          {% elif is_state('device_tracker.huawei_h10', 'France') %}
            France
          {% elif is_state('device_tracker.huawei_h10', 'Netherlands') %}
            Netherlands
          {% elif is_state('device_tracker.huawei_h10', 'Switzerland') %}
            Switzerland
          {% elif is_state('device_tracker.huawei_h10', 'Italy') %}
            Italy
          {% else %}
            Away
          {% endif %}
        entity_picture_template: >-
          {% if is_state('device_tracker.james_bayesian', 'home') %}
            /local/james.jpg
          {% endif %}
        icon_template: >-
          {% if is_state('device_tracker.huawei_h10', 'Powertec') %}
            mdi:briefcase
          {% elif is_state('device_tracker.huawei_h10', 'Kindy') %}
            mdi:school
          {% elif is_state('device_tracker.huawei_h10', 'Stocklands') %}
            mdi:cart
          {% elif is_state('device_tracker.huawei_h10', 'Parlour') %}
            mdi:coffee
          {% elif is_state('device_tracker.huawei_h10', 'Work Home Beacon 25mins') %}
            mdi:car
          {% elif is_state('device_tracker.huawei_h10', 'Work Home Beacon 15mins') %}
            mdi:car
          {% elif is_state('device_tracker.huawei_h10', 'Work Home Beacon 5mins') %}
            mdi:car
          {% elif is_state('device_tracker.huawei_h10', 'Darwin') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Brisbane') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Sydney') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Melbourne') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Perth') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Adelaide') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Tasmania') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'UK') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'France') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Netherlands') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Switzerland') %}
            mdi:airplane
          {% elif is_state('device_tracker.huawei_h10', 'Italy') %}
            mdi:airplane
          {% else %}
            mdi:walk
          {% endif %}

You can see full config Here

1 Like

The template-based sensor worked great. Thanks!

1 Like