Add state_class to the Rest sensor

Many sensors would benefit from the Statistics Graph card but need the state_class to be set, which is currently impossible in the rest sensor.

https://www.home-assistant.io/integrations/rest/

# Example configuration.yaml entry
rest:
  - authentication: basic
    username: "admin"
    password: "password"
    scan_interval: 60
    resource: http://192.168.1.12/status.xml
    sensor:
      - name: "Adult Pool Data System"
        state_class: "measurement"

<snipped other settings>

Use customize.yaml.

sensor.adult_pool_data_system:
  state_class: "measurement"
2 Likes

Mmmm, it was not listed as an option in the https://www.home-assistant.io/docs/configuration/customizing-devices but it is even possible to add it from the UI.

Thanks for the tip!

Well unfortunately the attribute is removed on loading the new data into the sensor although it is in customize.yaml. We still need this to be added to the rest sensor.

Read Home Energy Management in 2021.8
and also State-based template sensors