Template sensor value_template confusing

Hi,
I’m so confused on how this works as so many documented differences and ways to do this, i’m struggling to get it to work or understand how.
I want to add a simple template sensor. I’ve modified configuration.yaml to include:
template: !include template.yaml
Which appears the correct way now? (Home Assistant 2023.7.3).
In template.yaml I have:


#templates go here
  - sensor:
      - name: "Mowing Status"
        value_template: "{{ states('sensor.robomower_rssi') | int < -69 }}"

As I have a sensor from ESPhome called “sensor.robomower_rssi” that returns the rssi BLE value typically this is -79 but at times it will change to -71 or -68 which is what I want to monitor for. This is what my template sensor is supposed to do.
However, after getting syntax correct as above, I look in entities and cannot find “Mowing Status” or any ID that I can then display/add to my dashboard. How do I get a template sensor as an entitity I can actually use, or am I going about this totally wrong?
e.g. how do I specify an entity_id as this appears to have been removed, but would create an entity I can track?
Thanks.

I think you need to use state instead of value_template

1 Like

Aha, yes, changing it to:

#templates go here
  - sensor:
      - name: "Mowing Status"
        state: "{{ states('sensor.robomower_rssi') | int < -69 }}"

Has solved that problem. Thank you

As this is returning true or false you should use a binary sensor, as well as specifying a default value in case the source sensor is unavailable.

  - binary_sensor:
      - name: "Mowing Status"
        state: "{{ states('sensor.robomower_rssi') | int(-70) < -69 }}"
        device_class: connectivity

The device class will make it look pretty.

1 Like

Nice little extra that, thanks Tom.