I put this in my configuration.yaml, the Raspberry Pi at “ip” runs a separate mysql db from which I want to read data. I’ve checked standalone connection over (local) network with these parameters works.
After modifying mysql configuration to let connections outside localhost, after installing pymysql into HA virtual environment, I get no errors at startup (checked with debug logging enabled for “homeassistant.components.sensor”), but I don’t see any SQL sensor in the states page of HA.
What is wrong?
2020-09-20 00:54:05 INFO (SyncWorker_0) [homeassistant.loader] Loaded sql from homeassistant.components.sql
2020-09-20 00:54:06 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sql
I was wondering if perhaps someone else as this issue. I also have and I cannot figure why. This is my sensor, and looks totally legit to me:
- platform: sql
db_url: !secret mariadb_url
queries:
- name: qidi_tech_x_smart_3_last_layer_change
query: "select from_unixtime(last_updated_ts) as last_updated_ts from states where metadata_id = (SELECT metadata_id FROM states_meta where entity_id = 'sensor.qidi_tech_x_smart_3_current_layer') order by state_id desc limit 1"
column: "last_updated_ts"
icon: mdi:clock-time-eleven-outline
- name: qidi_tech_x_smart_3_previous_layer_change
query: "select from_unixtime(last_updated_ts) as last_updated_ts from (SELECT * FROM states where metadata_id = (SELECT metadata_id FROM states_meta where entity_id = 'sensor.qidi_tech_x_smart_3_current_layer') ORDER BY state_id DESC LIMIT 2) two_states order by state_id asc limit 1"
column: "last_updated_ts"
icon: mdi:clock-time-eleven-outline
but nothing shows up, neither an error entry in the logs…