How to create a sensor that shows a state based on a condition

Hi,

for my Garage card I would like to add a sensor that shows if the car is charging or not.
End of charging is defined by "if sensor.lynkco01_power < 50 watts for longer than 30 s" in my notification automation.

How can I use this condition to create a new sensor that shows an indicator if the car is charging or not?

Have a look here: Template - Home Assistant (home-assistant.io)
You would need the ‘delay_on’ for 30s then

I skipped the delay_on part and ended up with this:

  - sensor:
      - name: "Lynk&Co 01 Ladevorgang"
        unique_id: lynkco01_charging
        state: >-
          {% if states('sensor.lynkco01_power') | float > 100 %}
          aktiv
          {% else %}
          beendet
          {% endif %}

Just for elegance, this should probably be a binary_sensor. Written in the new format:

template:
  - binary_sensor:
      - name: "Lynk&Co 01 Ladevorgang"
        unique_id: lynkco01_charging
        device_class: battery_charging
        state: "{{ states('sensor.lynkco01_power')|float(0) > 100 }}"
1 Like

What a beauty :heart_eyes: … I’ll update it.

Hi, possibly out of topic and surely quite late in time :smiley:
Can I ask you how are you measuring the power grabbed by your Lynk en co 01?
I have the same car and am looking for a way to integrate it to home assistant but I don’t see an official integration nor one on HACS.

thanks!