I’ve had a SQL sensor for a while now to determine a historical value of another sensor. Worked fine, until… it didn’t. Suddenly it stopped updating/working and I’m at a complete loss on why.
/config/sensors/Weather.yaml:
# Buienradar weather data
# https://www.home-assistant.io/integrations/sensor.buienradar/
- platform: buienradar
monitored_conditions:
- stationname
- conditioncode
- conditioncode_1d
- condition
- condition_1d
- conditiondetailed
- conditiondetailed_1d
- conditionexact
- temperature
- temperature_1d
- mintemp_1d
- mintemp_3d
- feeltemperature
- humidity
- precipitation_forecast_average
- rainchance_1d
- rain_1d
- windspeed
- irradiance
# Determine max forecasted temperature for 'today'
- platform: sql
db_url: !secret mariadb_url
queries:
- name: max_temp_fcst_today
query: >
SELECT date(date_add(last_updated, INTERVAL 1 DAY)) AS date, MAX(state) AS max_temp
FROM home_assistant.states
WHERE entity_id = 'sensor.br_temperature_1d'
AND last_updated BETWEEN DATE_ADD(CURDATE(), INTERVAL -1 DAY) AND CURDATE();
column: max_temp
unit_of_measurement: °C
Where
!secret mariadb_url = mariadb_url: ‘mysql://usr:[email protected]:3307/home_assistant?charset=utf8’`
And Weather.yaml
is included in configuration.yaml
through:
sensor: !include_dir_merge_list sensors/
The SQL works fine on its own, when used directly at DB level.