shaonianzhentan / node-red-contrib-ha-mqtt

在HomeAssistant中生成MQTT实体
https://github.com/shaonianzhentan/node-red-contrib-ha-mqtt
MIT License
37 stars 19 forks source link

state_class missing for energy sensor #16

Open arthurlutz opened 2 years ago

arthurlutz commented 2 years ago

Again thanks for node-red-contrib-ha-mqtt it's a great way to tinker between node-red and homeassistant and enables uses outside of "cloud polling" modules !

I am extracting energy consumption and sending it to homeassistant using your module :

Screenshot from 2022-02-22 11-45-34

Here is what the settings looks like :

Screenshot from 2022-02-22 11-45-21

But on the homeassistant side I get the following warning :

Logger: homeassistant.components.energy.sensor
Source: components/energy/sensor.py:262
Integration: Energy (documentation, issues)
First occurred: February 21, 2022, 3:14:34 PM (1 occurrences)
Last logged: February 21, 2022, 3:14:34 PM

Found unexpected state_class None for sensor.electricity_base

Reading https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes I get a sense that I should add state_class: total_increasing and have tried a few combinations in the 配置 (configure) field, but not sure it worked.

Can this be done by matter of configuration or does it need to be changed in the code ?

shaonianzhentan commented 2 years ago

Thank you for use. You can update to the latest version

The configuration field replaces the default configuration

Please refer to this document https://www.home-assistant.io/integrations/sensor.mqtt/ image image image image

arthurlutz commented 2 years ago

Great! Thanks for the documentation / explanation, it seems to be working !