I want to show the mean temperature for the current day with the SQL syntax.
When I am on the SQL DB Browser, I can execute this code and it’s work :
SELECT AVG (state) FROM states WHERE entity_id = 'sensor.out_temp' AND last_updated > datetime(datetime('now','localtime'),'start of day','utc');
But, when I want to format it for HA, this code don’t work
sensor:
- platform: sql
queries:
- name: Mean Out
query: SELECT AVG (state) FROM states WHERE entity_id = 'sensor.out_temp' AND last_updated > datetime(datetime('now','localtime'),'start of day','utc');
column: 'state'
With this error message :
2019-07-29 17:39:03 ERROR (SyncWorker_3) [homeassistant.components.sql.sensor] Error executing query SELECT AVG (state) FROM states WHERE entity_id = 'sensor.out_temp' AND last_updated > datetime(datetime('now','localtime'),'start of day','utc') LIMIT 1;: "Could not locate column in row for column 'state'"