Fix "Previous state of an entity" YAML example (#21268)

This commit is contained in:
nordeep 2022-01-21 11:46:23 +03:00 committed by GitHub
parent b98748ce11
commit 4b8ea3ed53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,7 +108,7 @@ Note that the SQL sensor state corresponds to the last row of the SQL result set
Based on previous example with temperature, the query to get the former state is :
```sql
SELECT * FROM (SELECT * FROM states WHERE entity_id = 'sensor.temperature_in' ORDER BY state_id DESC LIMIT 2) two_entity ORDER BY state_id ASC LIMIT 1;
SELECT * FROM (SELECT * FROM states WHERE entity_id = 'sensor.temperature_in' ORDER BY state_id DESC LIMIT 2) two_entity ORDER BY state_id ASC LIMIT 1;
```
Thus in yaml
```yaml
@ -117,7 +117,7 @@ sensor:
- platform: sql
queries:
- name: Former_Temperature_In
query: "SELECT * FROM (SELECT state FROM states WHERE entity_id = 'sensor.temperature_in' ORDER BY state_id DESC LIMIT 2) two_entity ORDER BY state_id ASC LIMIT 1;"
query: "SELECT * FROM (SELECT state, state_id FROM states WHERE entity_id = 'sensor.temperature_in' ORDER BY state_id DESC LIMIT 2) two_entity ORDER BY state_id ASC LIMIT 1;"
column: "state"
```