snarky-snark / home-assistant-variables

A custom Home Assistant component for declaring and setting generic variable entities dynamically.
Apache License 2.0
274 stars 16 forks source link

Textual SQL expression error #96

Closed frankie-boy-hgv closed 4 months ago

frankie-boy-hgv commented 1 year ago

Hi,

After installing the new update I get errors running my sql-queries:

2023-03-02 19:05:00.310 ERROR (SyncWorker_13) [custom_components.var] Error executing query SELECT state FROM statistics WHERE metadata_id = (SELECT id FROM statistics_meta WHERE statistic_id = 'sensor.solaredge_lifetime_energy') AND DATETIME(created_ts, 'unixepoch') BETWEEN DATETIME('now', '-1 year') AND DATETIME(DATETIME('now', '4 hours'), '-1 year') ORDER BY DATETIME(created_ts, 'unixepoch') ASC LIMIT 1: Textual SQL expression 'SELECT state FROM statist...' should be explicitly declared as text('SELECT state FROM statist...')

Any idea what could be wrong?

Regards,

Frank

50494554524F commented 1 year ago

i just upgraded ha after few months and this error now prevent sql feature working...

snarky-snark commented 5 months ago

Home Assistant must have released an update that broke the recorder (database) API. Can you wrap your query in text() and see if that fixes it?