Hello, Everyone. I’ve been trying to add two template sensors to my configuration.yaml file and am not having any luck with it populating. I have double-checked that the sensors it is dependent on exist, but I don’t see any other reasons why it won’t populate. For what it’s worth, the state section does work as tested in the Developer Tools section.
Any help would be appreciated
Here are the two template sensors:
# EV Incremental Diff Sensors for Driveway and Garage
template:
- sensor:
- name: "Driveway Charger Energy Increment"
unique_id: "driveway_charger_energy_increment"
unit_of_measurement: "kWh"
state: >
{% set current_energy = states('sensor.driveway_charger_energy') | float %}
{% set previous_energy = state_attr('sensor.driveway_charger_energy_increment', 'last_value') | float(0) %}
{% if current_energy >= previous_energy %}
{{ (current_energy - previous_energy) | round(2) }}
{% else %}
0
{% endif %}
attribute_templates:
last_value: "{{ states('sensor.driveway_charger_energy') | float }}"
- name: "Garage Charger Energy Increment"
unique_id: "garage_charger_energy_increment"
unit_of_measurement: "kWh"
state: >
{% set current_energy = states('sensor.garage_charger_energy_new') | float %}
{% set previous_energy = state_attr('sensor.garage_charger_energy_increment', 'last_value') | float(0) %}
{% if current_energy >= previous_energy %}
{{ (current_energy - previous_energy) | round(2) }}
{% else %}
0
{% endif %}
attribute_templates:
last_value: "{{ states('sensor.garage_charger_energy_new') | float }}"```