dontsovcmc / waterius

Передача показаний воды по Wi-Fi. Watermeter Wi-Fi transmitter.
https://waterius.ru
GNU Lesser General Public License v3.0
559 stars 110 forks source link

Home Assistant показания за месяц #149

Closed makovroman closed 3 years ago

makovroman commented 3 years ago

Подскажите как в Home Assistant добавить показания за месяц в lovelace. Пытался на основани Alex Kvazis по энергомониторингу, не выходит((. Буду благодарен.

dontsovcmc commented 3 years ago

В чате https://t.me/waterius_forum ответили:

я решил эту задачу с помощью sql sensor

- platform: sql
    db_url: !secret db
    queries:
      - name: cold_water_this_month
        query: >
          SELECT round(max(state)::numeric-min(state)::numeric,1) cold_water_this_month
          FROM states
          WHERE entity_id='sensor.waterius_cold_water' and created>date_trunc('month',now()) and state!='unavailable';
        column: cold_water_this_month
        unit_of_measurement: "м3"

      - name: hot_water_this_month
        query: >
          SELECT round(max(state)::numeric-min(state)::numeric,1) hot_water_this_month
          FROM states
          WHERE entity_id='sensor.waterius_hot_water' and created>date_trunc('month',now()) and state!='unavailable';
        column: hot_water_this_month
        unit_of_measurement: "м3"

Можно обсудить там эту задачу.