swa72 / home-assistant

13 stars 1 forks source link

SQL Sensor #75

Closed swa72 closed 2 years ago

swa72 commented 2 years ago

find the sensor , see https://community.home-assistant.io/t/how-to-fix-statistics-data-e-g-energy-data/360966 then pick the latest entry


SELECT `sum` FROM `statistics` WHERE `metadata_id`= 103 ORDER BY `id` DESC LIMIT 1
swa72 commented 2 years ago

debug me in a VM, need to restart :-/ "reloading template entities" doesn't do it.

swa72 commented 2 years ago
- platform: sql
  db_url: !secret db_url
  queries:
    - name: Entfeuchter Grand Total
      query: "SELECT * FROM statistics WHERE metadata_id=103 ORDER BY id DESC LIMIT 1;"
      column: "sum"
      unit_of_measurement: kWh