core
core copied to clipboard
New GJ gas consumption source does not allow selecting the correct sensor
The problem
I've found a few issues with the new implementation of gas energy sensors that provide energy in gigajoules. First of all the Kampstrup integration sensor I use (golles/ha-kamstrup_403) does not show up in the drop-down list when adding a 'gas consumption source'. In fact, the drop-down list is not up-to-date as it holds many entities/sensors that have been deleted. This is how the Kampstrup energy sensor has been defined by the 403 integration:
attribution: Data provided by Kamstrup 403 meter
integration: kamstrup_403
unit_of_measurement: GJ
device_class: energy
icon: mdi:radiator
friendly_name: Kamstrup 403 Heat Energy (E1)
It is missing the state_class. So I created a new template sensor like this:
template:
- sensor:
- name: heating_gj
state: >-
{{ states('sensor.kamstrup_403_heat_energy_e1')
| float }}
icon: mdi:fire
unique_id: heating_gj
device_class: 'energy'
unit_of_measurement: 'GJ'
state_class: 'total'
This template sensor does not show up in the drop-down list. Only if I change the device_class of this template sensor to 'gas', the sensor shows up, but on pressing 'save' it shows an error indicating that GJ is invalid unit for gas sensor.
While still selected as gas consumption source, i change back the device_class to energy and reload the template sensors. The error is disappeared, but when I look at the energy dashboard, the unit now shows kWh instead of GJ.
Finally, the documentation still requires an update.
What version of Home Assistant Core has the issue?
Home Assistant 2022.11.1 Supervisor 2022.10.2 Operating System 9.3 Frontend 20221102.1 - latest
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
energy dashboard
Link to integration documentation on our website
https://www.home-assistant.io/docs/energy/gas/
Diagnostics information
No response
Example YAML snippet
template:
- sensor:
- name: heating_gj
state: >-
{{ states('sensor.kamstrup_403_heat_energy_e1')
| float }}
icon: mdi:fire
unique_id: heating_gj
device_class: 'energy'
unit_of_measurement: 'GJ'
state_class: 'total'
Anything in the logs that might be useful for us?
Logger: homeassistant.components.template.config Source: components/template/config.py:94 Integration: Template (documentation, issues) First occurred: 08:20:49 (1 occurrences) Last logged: 08:20:49
The entity definition format under template: differs from the platform configuration format. See https://www.home-assistant.io/integrations/template#configuration-for-trigger-based-template-sensors
Additional information
The developer page also requires an update as the unit for energy sensors does not yet include GJ: https://developers.home-assistant.io/docs/core/entity/sensor/?fbclid=IwAR3dDoe5kg-xJ5jnHbmyCfXDQ3FUDaZHZ8ewe3_kdoBoL-rm_BTe73ml708#available-device-classes
Duplicate of https://github.com/home-assistant/core/issues/81496