Show sensor value from 24 hours previous

Heya,

Could any one help me in displaying the state of a temp sensors value from 24 hours previous?

I have a couple of temp sensors for my pool and I’d like to show their live read plus show the value that same sensor had 24 hours previous.

I was hoping the history_stats sensor platform would do what I need but it looks like it will only work within time frames and not just the exact stat 24 hours previous.

Can anyone give me any suggestions?

Thanks!

Well after a good bit of hunting round, this got me what I was after:

- platform: sql
  queries:
    - name: Pool Temperature Yesterday
      unit_of_measurement: "°C"
      query: "SELECT * FROM states WHERE entity_id = 'sensor.pool_temperature' ORDER BY ABS(strftime('%s', created) - strftime('%s', datetime('now'), '-1 day')) LIMIT 1;"
      column: 'state'
1 Like