Hello together,
i have many ESPHome Devices in Home Assistant for Temp and Humi measurement.
These devices are available in the long-term statistics.
Some devices are located at a distance and send the data via MQTT.
These devices are not available in the long-term statistics.
I tried this in the ESPHome YAML, but it does not work.
sensor:
- platform: ina226
address: 0x40
shunt_resistance: 0.002 ohm
current:
icon: mdi:flash-auto
name: "${sensorname1} Strom"
filters:
- lambda: |-
float MIN_VALUE = 0;
float MAX_VALUE = 30.0;
if (MIN_VALUE <= x && x <= MAX_VALUE) return x;
else return {0};
power:
icon: mdi:solar-panel-large
name: "${sensorname1} Leistung"
device_class: "energy"
state_class: "measurement"
bus_voltage:
icon: mdi:flash
name: "${sensorname1} Bus Spannung"
device_class: "voltage"
state_class: "measurement"
shunt_voltage:
icon: mdi:flash
name: "${sensorname1} Shunt Spannung"
device_class: "voltage"
state_class: "measurement"
max_current: 20.0A
update_interval: 10s
Under Developer Tools the attribute state_class is not shown:
I made this change for all temperature and humidity sensors that send their data via MQTT:
customize_glob:
sensor.temperatur_*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: temperature
state_class: measurement
sensor.luftfeuchtigkeit_*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: humidity
state_class: measurement
It is now possible to display the devices in the long-term statistics. But is that the right way?