Sensor configuration

Hi,

I am using MQTTCarPresence to sense the car, it’s used to automatically switch on the outside light and it works fine.

I would like to add a icon to the dashboard to say if the car is ‘home’ or ‘away’. As CarPresence only gives a signal when the ignition is on (d1 mini wired to the ignition) I need to configure HA to toggle between states ie Signal = Car Home…Signal = Car Away… Signal = Car Home.

I have tried googling but I am not sure what to google to find an answer, can anyone help?

Regards
James

Check out binary sensor with device class “presence”

I have looked at binary sensors, but I can’t find an answer to how you configure the value_template to toggle the sensor

binary_sensor:

  • platform: template
    sensors:
    car home:
    friendly_name: “Car home”
    value_template: Value = Connected -> Car Home, Value = Connected -> Not at home

Regards
James

Here’s an example that maybe will help. I’ve created a new binary sensor based on a calculation from two other entites:

  - platform: template
    sensors:
      milli_needs_emptied:
        friendly_name: "Milli Full After Sunset"
        device_class: problem
        value_template: >-
          {{ is_state('sun.sun', 'below_horizon')
             and is_state('binary_sensor.milli_bin_full', 'on') }}