Probably so simple you will laugh … sorry in advance but I’m searching for hours without success.
My Solaredge photovoltaic inverter gives me energy and power sensors in Wh and W, I want them in kWh and kW.
Here, the Solaredge entity unique ID is solaredge_energie_totale and I want to create an emtity called solaredge_energie_totale_kWh, (divided by 1000 from previous) with friendly name Solaredge energie totale [kWh], so I went to templates and tried this in the template dev tool :
sensor:
- name: "Solaredge energie totale [kWh]"
unique_id: solaredge_energie_totale_kWh
unit_of_measurement: 'kWh'
state > {{ states('solaredge_energie_totale') | int * 0.001 }}
witch returns this error :
ValueError: Template error: int got invalid input ‘unknown’ when rendering template ‘sensor: - name: “Solaredge energie totale [kWh]” unique_id: solaredge_energie_totale_kWh unit_of_measurement: ‘kWh’ state > {{ states(‘solaredge_energie_totale’) | int * 0.001 }}’ but no default was specified
Do I need to declare the new sensor entity somewhere ?
You really should add the availability template if you ever plan to use the sensor in an energy dashboard or utility meter. Otherwise you get weird spikes in your statistics.
The energy dashboard won’t accept the sensor if you do not set the state_class also.
Last but not least, the indenting is broken in your example. Check the indenting to match the documentation exactly. It matters. the last three lines should match up exactly with name.
If you’re only going to display this new value, then you don’t need an unnecessary sensor. You can change the unit prefix and precision on the UI: Click on the entity and go to its settings.
Not listed where? Where are you looking for this sensor?
BTW the indentation of your code in the first post is totally off.
Did you add this to your configuration.yaml or another YAML file, or are you creating a template sensor under Helpers?