Hi,
I want to use my own custom template sensor in the energy dashboard.
In test, I defined following template sensors:
- name: "gasmeter_total_gas_test1"
unique_id: "sensor.gasmeter_total_gas_test1"
icon: mdi:gas-cylinder
unit_of_measurement: "m3"
device_class: energy
state_class: total_increasing
state: >
{{ states('sensor.p1_meter_total_gas') | float(default=0.0) | round(3) }}
availability: >
{{ states('sensor.p1_meter_total_gas') }}
- name: "gasmeter_total_gas_test2"
unique_id: "sensor.gasmeter_total_gas_test2"
icon: mdi:gas-cylinder
unit_of_measurement: "m3"
device_class: energy
state_class: total_increasing
state: >
{{ states('sensor.p1_meter_total_gas') | float(default=0.0) | round(3) }}
availability: >
{{ states('sensor.p1_meter_total_gas') }}
- name: "gasmeter_total_gas_test3"
unique_id: "sensor.gasmeter_total_gas_test3"
icon: mdi:gas-cylinder
unit_of_measurement: "mÂł"
device_class: energy
state_class: total_increasing
state: >
{{ states('sensor.p1_meter_total_gas') | float(default=0.0) | round(3) }}
availability: >
{{ states('sensor.p1_meter_total_gas') }}
- name: "gasmeter_total_gas_test4"
unique_id: "sensor.gasmeter_total_gas_test4"
icon: mdi:gas-cylinder
unit_of_measurement: "mÂł"
device_class: energy
state_class: total_increasing
state: >
{{ states('sensor.p1_meter_total_gas') | float(default=0.0) | round(3) }}
availability: >
{{ states('sensor.p1_meter_total_gas') }}
There seems to be something wrong with the unit_of_measurement definition:
- I can only add gasmeter_total_gas_test3 and gasmeter_total_gas_test3 to the energy dashboard
- but even with “m³” defined, I still get following error:
Unexpected unit of measurement
The following entities do not have an expected unit of measurement (either of GJ, kWh, MJ, MWh, Wh for an energy sensor or either of CCF, ftÂł, mÂł for a gas sensor):
- sensor.gasmeter_total_gas_test3 (mÂł)
My yaml config file is encoded in UTF8…
So my question: how can I define a custom template sensor with m3 to use in my energy dashboard?
kind regards,
Bart