Add SQLite db size example (fixes #13715) (#14295)

This commit is contained in:
Fabian Affolter 2020-08-23 11:23:18 +02:00 committed by GitHub
parent 3f33e14c32
commit 93312671e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ This can be used to present statistics about Home Assistant sensors if used with
To configure this sensor, you need to define the sensor connection variables and a list of queries to your `configuration.yaml` file. A sensor will be created for each query:
To enable it, add the following lines to your `configuration.yaml`:
To enable it, add the following lines to your `configuration.yaml` file:
{% raw %}
```yaml
@ -109,7 +109,7 @@ SELECT * FROM states WHERE entity_id = 'binary_sensor.xyz789' GROUP BY state ORD
### Database size
#### Database size in Postgres
#### Postgres
{% raw %}
```yaml
@ -140,3 +140,19 @@ sensor:
unit_of_measurement: kB
```
{% endraw %}
#### SQLite
If you are using the `recorder` integration then you don't need to specify the location of the database. For all other cases, add `db_url: sqlite:////path/to/database.db`.
{% raw %}
```yaml
sensor:
- platform: sql
queries:
- name: DB Size
query: 'SELECT ROUND(page_count * page_size / 1024 / 1024, 1) as size FROM pragma_page_count(), pragma_page_size();'
column: 'size'
unit_of_measurement: 'MiB'
```
{% endraw %}