Using the config from this topic I am trying to configure my gas meter so it shows up in the energy page. I could add my energy (peak and offpeak) usage to the new energy page, but gas consumption configuration is reporing ‘no matching statistics found’.
I am having problems adding the device_class
and state_class
attributes to the mqtt sensor.
File configuration.yaml
contains:
sensor: !include_dir_merge_list sensors/
File sensors/DSMR-actueel.yaml
contains:
- platform: mqtt
name: "Gas Delivered"
state_topic: "DSMR-WS/JSON/gas_delivered"
unit_of_measurement: m³
value_template: "{{ value_json.gas_delivered[0].value | round(2) }}"
This mqtt sensor was configured sometime ago and is reporting the total gas delivered correctly. The value_template
with gas_delivered[0]
seems redundant but the MQTT is reporting on this topic as following: DSMR-WS/JSON/gas_delivered {"gas_delivered":119.69,"unit":"m3"}
.
When I change the above sensor to:
- platform: mqtt
name: "Gas Delivered"
state_topic: "DSMR-WS/JSON/gas_delivered"
unit_of_measurement: m³
value_template: "{{ value_json.gas_delivered[0].value | round(2) }}"
device_class: gas
state_class: total_increasing
The config is being edited via the Visual Studio Code add-on. I am getting configuration errors on the last two attributes:
-
state_class
: Property state class is not allowed -
device_class
: Value is not accepted. Valid values: “battery”, “current”, “energy”, “humidity”, “illuminance”, “power”, “power_factor”, “pressure”, “signal_strength”, “temperature”, “timestamp”, “voltage”
I checked the docs: Sensor Entity | Home Assistant Developer Docs but I could not find a suggestion to properly set the new attributes. Is there something wrong with the configured sensor entity, or could it be this configuration error is related to Visual Studio Code (because the config is checked via the editor)?
My versions: Home Assistant OS 6.3 on core-2021.9.6, Visual Studio Code is on version 3.6.2.