Stop recording sun states when you don't need the elevation info

Most of the history database is sun state changes, if you use sun and recorder.
Actually, it’s not state changes, but sun’s elevation changes, one per minute.

I have many temperature sensors to generate data, and about 4000 state changes per day. Sun.sun-object generates one state change per minute, so there will be daily 1440 rows from sun.sun. Is this really necessary? Yearly it will be half a million rows.

How not to see sun.sun-rows:

  • some kind of black list to recorder?
  • in sun.sun-object switch to record only real state changes (above/below), record elevation only if really used/needed.

Later, if I have roller motor for my shades controlled by elevation of sun, there will be even more recorded rows, because controlling the shades will also generate state changes. I don’t know if that will be important data to record.

It would be nice if we could purge per recorder type: I personally don’t care about all the details of the sun state or my CPU, but there’s other stuf I do like to persist.

Just a quick look of the content of my DB, most entries of the type ‘state changed’ I don’t care about anymore.

event_type          | Count(*)
-------------------------------
call_service        | 64
component_loaded    | 860
homeassistant_start | 48
homeassistant_stop  | 40
logbook_entry       | 14
platform_discovered | 60
service_executed    | 47
service_registered  | 1302
state_changed       | 252867

I can simply create sql statement that purges the records I don’t need, but it was a surprise to me that sun.sun generates so much rows.

I like the idea of being able to stop recording specfic devices. My database grows at an alarming pace and I have no need to record everything.

I don’t neccesarily need to completely stop, but a configurable purge period per recorder type would certainly be nice.

I’m currently in the process of developing a HASS plugin that will read my smart energy meter and I would like to report over months/years in the end.
With the current data model that seems a challenge at it is.

2 Likes