#Can you access historical data in templates?
1 messages · Page 1 of 1 (latest)
Or depending on your use case, use a trigger-based template sensor to store the value when it happens.
For example if you want to know what the value of a sensor was last Monday at midnight, you can either:
Create an sql sensor to look up that value in the recorder database
Or
Create a template sensor that triggers every Monday at midnight and sets its state to that value.
Does this require installing e.g. mysql?
I want to do similar to create a derivative sensor for the water level in my sump pit.
I'd need to get the last few timestamp/value pairs
I am trying to match the states table on entity_id of my sensor but nothing in that table seems to have an entity id
you get entity id by looking up metadata_id <-> entity_id in states_meta
dare i ask why there's a an entity_id column?
i don't suppose you can tell me how to write a join?
i haven't done much sql for a while
not off top of my head
select state, count(*) from states left join states_meta on (states_meta.metadata_id = states.metadata_id) where states_meta.entity_id = ... seems to work