Skip to content

Commit

Permalink
total counter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mhendriks committed Jan 3, 2024
1 parent f20883f commit 1607a2c
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions p1-dongle-pro-h2o.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ api:
variables:
set_value: int
then:
- pulse_meter.set_total_pulses:
id: h2o_pulse
- globals.set:
id: totalWaterUsage
value: !lambda 'return set_value;'


globals:
- id: totalWaterUsage
type: int
restore_value: true # aanpassen naar no indien de nieuwe waarde onder de oude ligt
initial_value: '0'

ota:
captive_portal:
web_server:
Expand Down Expand Up @@ -87,7 +93,7 @@ switch:
red: 0%
green: 0%
blue: 100%
brightness: 30%
brightness: 40%
transition_length: 50ms
on_turn_off:
- light.turn_off:
Expand Down Expand Up @@ -151,13 +157,24 @@ sensor:
internal_filter_mode: EDGE
icon: mdi:flash-outline
accuracy_decimals: 0
total:
name: "Water Total"
id: h2o_total
state_class: total_increasing
icon: mdi:water
unit_of_measurement: L
accuracy_decimals: 0
# total:
# name: "Water Total"
# id: h2o_total
# state_class: total_increasing
# icon: mdi:water
# unit_of_measurement: L
# accuracy_decimals: 0
- platform: template
name: "Watermeter total"
state_class: "total_increasing"
device_class: "water"
icon: mdi:water
update_interval: 1s
unit_of_measurement: L
accuracy_decimals: 0
lambda: |-
if (id(h2o_pulse).state > 0) id(totalWaterUsage) += 1;
return id(totalWaterUsage);
- platform: dsmr
# energy_delivered_lux:
Expand Down Expand Up @@ -281,4 +298,4 @@ text_sensor:
name: "_Wi-Fi BSSID"
- platform: version
name: "_ESPHome Version"
hide_timestamp: true
hide_timestamp: true

0 comments on commit 1607a2c

Please sign in to comment.