chelxxx
(ΠΠΈΠΊ Π Π°ΡΠΊΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ²)
1
Hello guys!
Ive got temperature sensors that return value every minute via MQTT
How can I return a value from history e.g. 1 hour before now?
Need somethink like that:
{{ states.sensor.temperature | (now() - timedelta( hours = 1 )) }}
The promblem looks simple, but i cant find a solution)
1 Like
chelxxx
(ΠΠΈΠΊ Π Π°ΡΠΊΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ²)
3
Thanks, Ill try to, just thought that it could be done without integrations.
jlambert121
(Justin Lambert)
4
Maybe this will be of use? history_stats
chelxxx
(ΠΠΈΠΊ Π Π°ΡΠΊΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ²)
5
I tried it, but I donβt know the syntax how to connect the sensor and history
chelxxx
(ΠΠΈΠΊ Π Π°ΡΠΊΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ²)
6
Added to configuration.yaml:
sensor:
- platform: sql
queries:
- name: sstate
query: βSELECT * FROM states WHERE entity_id = βsensor.temperatureβ ORDER BY state_id DESC LIMIT 1;β
column: βstateβ
Now I can call it by {{ states('sensor.sstate') }}
Trying to select past values via SQL
chelxxx
(ΠΠΈΠΊ Π Π°ΡΠΊΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ²)
7
If it could be done by using API (GET /api/logbook/)
so it must be internal variable to do the same.
1 Like