Convert sensor to a device tracker?

Hello

Does anyone have an example of how to convert a sensor into a device tracker or into home/not_home please?
i.e. my sensor returns a value from 0-100 and I want it to be not home if it is zero and home above zero.

Any idea please?

Cheers
Mark

create a template sensor. Something like:

sensor:
  platform: template
    some_name:
      friendly_name: Some Name
      entity_id: sensor.your_sensor
      value_template: >
        {% if states.sensor.your_sensor.state | int = 0  %}
          Not Home
        {% else %}
          Home
        {% endif %}
1 Like

Perfect thank you!! god why didn’t I think of that!

Cheers!

1 Like

my working sensor if anyone searches in the future :slight_smile:

  - platform: template
    sensors:
      mark_bt:
        friendly_name: 'Mark Bluetooth'
        entity_id: sensor.mark_downstairs
        value_template: >
          {% if states.sensor.mark_downstairs.state | int == 0  %}
            Not Home
          {% else %}
            Home
          {% endif %}

The only problem with this is it creates a template sensor,

It does not show when asked to select “device trackers”.

For example, using the mushroom person card, I cannot select the template sensor to track, as it only allows me to select a “person” entity.

I also cannot assign this template sensor to the persons list of device trackers.

Any idea how to get around this?

Thanks

      dean_location:
        value_template: >-
          {% if states('sensor.deans_iphone_ssid') == "wifinetwork" %}
            Home
          {% else %}
            Away
          {% endif %}
        friendly_name: 'Dean WiFi Location'

Use the Mushroom Template Card. It is highly customizable.

Yea only problem is mushroom documentation sucks!

Start here

and post questions here.

type: custom:mushroom-template-card
primary: Dean
secondary: |-
  {% if states('sensor.deans_iphone_ssid') == "wifinetwork" %}
              Home
            {% else %}
              Away
            {% endif %}
         
icon: mdi:account
icon_color: |-
  {% if states('sensor.deans_iphone_ssid') == "wifinetwork" %}
             green
            {% else %}
              red
            {% endif %}