esphome / esphome/feature-requests
EspHome 1.20.4 mqtt sensor send_discovery ignores `last_reset_type` and `state_class`.
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
With the recent addition in HA of `state_class` and `last_reset` being required for energy devices, it would be nice if the mqtt sensor would support doing something with the information in the send_discovery code. And preferably doing something useful with `last_reset` as well, i suupose.
**Please describe your use case for this integration and alternatives you've tried:**
When using MQTT, the esphome configued energy sensors are not showing up as such in HA. Looking further in the discovery config, `last_reset_template`, `last_reset_topic` and `state_class` are completely missing although they are set on the sensor.
**Additional context**
Examply snippet of a sensor which, when mqtt is enabled should be an energy sensor on HA's side.
```yaml
sensor:
- platform: uptime
name: "esp8266 Uptime"
update_interval: 60s
state_class: measurement
device_class: energy
last_reset_type: auto
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the MQTT sensor send_discovery code and compare its discovery output with the sensor fields shown in the issue. Check how state_class and last_reset_type are represented, then verify that the generated discovery data includes the requested state_class and last-reset information for Home Assistant energy sensors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- yaml
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100