I want to add Long-term Statistics to my temperature Rest sensors
in configuration.yaml i have this:
sensor: !include_dir_merge_list myconfig/sensor/
and in sensors file
- platform: rest
name: LAB Temperature
device_class: temperature
state_class: measurement # without this it works ok
json_attributes:
- temperature
- battery
resource: http://192.168.90.10/api/devices/11497/state
value_template: '{{ value_json.temperature }}'
verify_ssl: false
unit_of_measurement: '°C'
force_update: true
But I have following errors:
Invalid config for [sensor.rest]: [state_class] is an invalid option for [sensor.rest].
Check: sensor.rest->state_class. (See ?, line ?).
Have you tried adding state_class as a customization either through the UI or in configuration.yaml? I had a couple sensors that did not automatically have the state_class added, but I added it through the UI and it is working.
Hi,
I have the same problem. I managed to read out my solar panel production via REST, but now I am surprised to find that REST sensors can’t be configured with state_class, if I try, I get this:
Invalid config for [rest]: [state_class] is an invalid option for [rest].
What you get from that template sensor is a copy of the rest sensor but it will show up on the energy dashboard because this “new” template sensor will have the required attributes to be detected by the energy dashboard:
device_class: energy
state_class: measurement
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
My prayers have been heard - the 2021.11 release of HA adds support for device_class attribute for REST sensors! I have been able to successfully apply it to my solar panel REST sensors.