Understanding longterm statistics of RESTful sensors

Hi there,

I am pretty new to HA. I have some integrations which work but would like to learn/understand more about HA’s details, especially the properties of sensors/entities and how they affect data storage/other behaviors.

I have a local weather station which exposes a web-interface. For this interface I added a rest-based sensor (configuration see below) which works fine.

- resource: "http://192.168.178.27:1234"
  scan_interval: 30
  method: GET
  params:
       lng: de
  sensor:
   - name: "Bresser.AussenLuftFeuchtigkeit"
        value_template: "{{ value_json['current'].humidity }}"
        device_class: humidity
        unit_of_measurement: "%"
        state_class: measurement

After some time I recognized, that HA will purge all that data after 10 days. After reading the docs the best way for me was to add a “state_class” of “measurement” to every entity of that sensor (already part of the config above).

The next lesson I had to learn was, the data from the past 10 days could not be saved by that change since the switch to long term statistics affects only newly fetched data(found as answer here in the forum). Okay, I had to accept that.

However, the graphs for the changed entity did not show me any “historic” or “longtermstatistics” tags for the data being fetched after the change so I felt still unsafe about it.

To make sure my data will not get lost, I just duplicated my existing REST sensor / started data collection from scratch (with the state_class measurement) including all entities to see if it works as expected. Config for the same entity (outdoor humidity):

- resource: "http://192.168.178.27:1234"
  scan_interval: 30
  method: GET
  params:.longterm
       lng: de
  sensor:
   - name: "Bresser.AussenLuftFeuchtigkeit"
        unique_id: "Bresser.AussenLuftFeuchtigkeit.longterm"
        value_template: "{{ value_json['current'].humidity }}"
        device_class: humidity
        unit_of_measurement: "%"
        state_class: measurement

The newly added sensor and its entities seemed to work fine. When hovering the graph, the most recent data were tagged as “Historie” and I guess data older than 10 days will be tagged as “longtermstatistics” (or similar) as it is the case for other sensors I have (e.g. power).

So I think am fine with my config. There is also a min,max and avg, so I am finally convinced.
However, I still have questions:

  • why is the existing sensor graph not showing “history” as source for new data (when hovering the graph), although I changed the state_class to “measurement”
  • is the only way to verify if an entity logs to long term stats, to check its state_class(measurement, total, total_increasing)?
  • in the settings/entities: my duplicated entity (the one ending with .longterm) is displayed as “RESTful” sensor and the older one is just a “sensor” - why is this?

If somebody could shed some light into my questions or give me some pointers (docs) I would be very grateful!

Dan