First thing - exclude recording of the devices. My method was to use a glob so I name devices/entity IDs specifically and they don't get recorded (in my case I used f_ as in "filtered" so devices become like "F Source Presence"), but you can add specific entities or use your own glob. In configuration.yaml I have this:
recorder:
exclude:
entities:
- sensor.excluded_entity_1
# AND/OR this (then of course rename entities as needed)
entity_globs:
# exclude all sensor entities that start with f_
- sensor.f_*
Then I created templates for my presence sensors, that just copy the state so I get history (yaml here, but can do through UI now too in the Helpers section, the import part is the template in the state key below):
template:
- binary_sensor:
- name: Real presence
unique_id: my_presence
state: >-
{{ states('binary_sensor.f_source_presence}}
availability: >-
{{
not (
states('binary_sensor.f_source_presence') == 'unknown' or
states('binary_sensor.f_source_presence') == 'unavailable'
)
}}
device_class: presence
You could also use a statistics sensor to get a moving average for numeric values and get history from them too (and reduce the noise by reducing the precision and having a larger time window). This is also available through the UI - Helpers.