Building a better ESPresense. Question about sensor templates [SOLVED]

Solved it with the solution here. Took a couple more hours, but I found it.

Edit: This was edited… SEVERAL HOURS and gallons of fuel later to make sure the tracker was set to not_home as the dev tools set state option gets overridden extremely fast.

Solution:

- sensor:
  - name: "Osiris Room"
    state: >-
      {% if states.device_tracker.osiris_tile.state != 'home' and states.sensor.osiris_collar.state == 'not_home' %}
        Possibly Loose
      {% else %}
        {% if states.sensor.osiris_collar.state == 'not_home' %}
          {{ states.sensor.osiris_room.state }}
        {% else %}
          {% if states.sensor.osiris_collar.state == 'media_room' %}
            Media Room
          {% elif states.sensor.osiris_collar.state == 'living_room' %}
            Living Room
          {% elif states.sensor.osiris_collar.state == 'bedroom' %}
            Bedroom
          {% elif states.sensor.osiris_collar.state == 'laundry_room' %}
            Laundry Room
          {% elif states.sensor.osiris_collar.state == 'gateroom' %}
            Gateroom
          {% elif states.sensor.osiris_collar.state == 'kitchen' %}
            Kitchen
          {% elif states.sensor.osiris_collar.state == 'dining_room' %}
            Dining Room
          {% elif states.sensor.osiris_collar.state == 'sun_room' %}
            Sun Room
          {% elif states.sensor.osiris_collar.state == 'office' %}
            Office
          {% elif states.sensor.osiris_collar.state == 'not_home' %}
            {{ states.sensor.osiris_room.state }}
          {% endif %}
        {% endif %}
      {% endif %}

The and condition speeds up the sensor’s detection of arrival, as the bt is faster than the tile.

I used this to get to the solution:

If anyone else tries out my solution for ESPresense, let me know and let me know if it works for you.