Little input to this sensor please

This is what I’m trying to get work but for some reason it just keeps telling me ‘unavailable’…so apparently I’m not doing something right… can anyone see anything obvious I’m missing here…

Thank you!

- platform: template
  sensors:
    john_presence:
      friendly_name: John presence
      value_template: >-
        {% set home_state = device_tracker.sm_f926u1.state  %}
        {% if home_state == 'home' %}
          John is in
        {% else %}
          John is out
        {% endif %}
      icon_template: >-
        {% if is_state('device_tracker.sm_f926u1', 'home') %}
          mdi:human-male
        {% else %}
          mdi:human-cane
        {% endif %}

Ok well after a little tinkering I figured it out… LOL

- platform: template
  sensors:
    john_presence:
      friendly_name: John presence
      unique_id: john-home
      value_template: >-
        {% if is_state('device_tracker.sm_f926u1', 'home') %}
          John is in
        {% else %}
          John is out
        {% endif %}
      icon_template: >-
        {% if is_state('device_tracker.sm_f926u1', 'home') %}
          mdi:human-male
        {% else %}
          mdi:human-cane
        {% endif %}

This is working :slight_smile: