From 88d890aa465c89e4771432abf92f7579f99895d8 Mon Sep 17 00:00:00 2001 From: Nicholas Amadori Date: Mon, 12 Feb 2018 08:46:34 +0100 Subject: [PATCH] Update Postgresql example (#4642) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The query with pg_size_pretty returns the value as a string, that way you can’t have a nice chart or make value comparison. Inserted new query to return value as number. --- source/_components/sensor.sql.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/_components/sensor.sql.md b/source/_components/sensor.sql.md index a1a0c40fc14..28ec3797881 100644 --- a/source/_components/sensor.sql.md +++ b/source/_components/sensor.sql.md @@ -90,6 +90,12 @@ SELECT * FROM states WHERE entity_id='binary_sensor.xyz789' GROUP BY state ORDER ### {% linkable_title Database size in Postgres %} -```sql -SELECT pg_size_pretty(pg_database_size('Database Name')); +```yaml +- platform: sql + db_url: postgresql://user:password@host/dbname + queries: + - name: db_size + query: "SELECT (pg_database_size('dsmrreader')/1024/1024) as db_size;" + column: "db_size" + unit_of_measurement: MB ```