Hi there, im trying to get a entity wich gets me the chargingpower of my Tesla. I have voltage and current via mqtt in HA and need a new entity wich simply multiplies these two entities.
i tried to implement a template sensor but it’s not showing up in HA after restart. The configuration check in Dev Tools is ok.
This is my template_sensor.yaml wich is included in configuration.yaml
- sensor:
- name: "Tesla Ladeleistung"
unit_of_measurement: "W"
state_class: power
state: >
{% set voltage = states('sensor.tesla_charger_voltage') | float %}
{% set current = states('sensor.tesla_charger_current') | float %}
{{ (voltage * current) | round(2) }}
What i have to do to get this entity to show up in HA? This is my first integration with the “Template” Sensor.
That looks pretty good. You just need to add some default values for your float filters and adding an availability template is a good idea too. Oh and you got state class mixed up with device class:
- sensor:
- name: "Tesla Ladeleistung"
unit_of_measurement: "W"
device_class: power
state_class: measurement
state: >
{% set voltage = states('sensor.tesla_charger_voltage') | float(0) %}
{% set current = states('sensor.tesla_charger_current') | float(0) %}
{{ (voltage * current) | round(2) }}
availability: >
{{ states('sensor.tesla_charger_voltage') | is_number and
states('sensor.tesla_charger_current') | is_number }}
Now it’s showing up and i can test it when the car is sharging next time. How often does the value gets updated? When one of the input sensors get updated?