From 0b684012e2d04698721f302f40fab6ca64241394 Mon Sep 17 00:00:00 2001 From: Marat Levit Date: Sat, 12 Jan 2019 07:04:25 +1100 Subject: [PATCH] Corrected indentation and standardized examples (#8130) --- source/_components/sensor.sql.markdown | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/source/_components/sensor.sql.markdown b/source/_components/sensor.sql.markdown index 612df43f726..fd5b806b0ca 100644 --- a/source/_components/sensor.sql.markdown +++ b/source/_components/sensor.sql.markdown @@ -107,7 +107,7 @@ Note that the SQL sensor state corresponds to the last row of the SQL result set This example only works with *binary_sensors*: ```sql -SELECT * FROM states WHERE entity_id='binary_sensor.xyz789' GROUP BY state ORDER BY last_changed DESC LIMIT 1; +SELECT * FROM states WHERE entity_id = 'binary_sensor.xyz789' GROUP BY state ORDER BY last_changed DESC LIMIT 1; ``` ### {% linkable_title Database size %} @@ -116,7 +116,8 @@ SELECT * FROM states WHERE entity_id='binary_sensor.xyz789' GROUP BY state ORDER {% raw %} ```yaml -- platform: sql +sensor: + - platform: sql db_url: postgresql://user:password@host/dbname queries: - name: DB size @@ -131,12 +132,12 @@ SELECT * FROM states WHERE entity_id='binary_sensor.xyz789' GROUP BY state ORDER {% raw %} ```yaml sensor: -- platform: sql - db_url: mysql://user:password@localhost/hass - queries: - - name: DB size - query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="hass" GROUP BY table_schema;' - column: 'value' - unit_of_measurement: kB + - platform: sql + db_url: mysql://user:password@localhost/hass + queries: + - name: DB size + query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="hass" GROUP BY table_schema;' + column: 'value' + unit_of_measurement: kB ``` {% endraw %}