Skip to content

Commit

Permalink
Merge pull request #38 from martijnvwezel/develop
Browse files Browse the repository at this point in the history
Improve update statement
  • Loading branch information
martijnvwezel authored Mar 16, 2024
2 parents 5888abf + 067f36e commit 013d8b0
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 27 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,42 @@ The Muino Smart Water Meter is a **single-board** device that measures water con

# Where to buy?
* If you would like the watermeter go to: [webshop](https://www.tindie.com/products/muino/smart-water-meter-reader/)
* For big orders please make a request: [[email protected]](mailto:[email protected])
* You want a sensor to play with the DIY version go to: [webshop](https://www.tindie.com/products/muino/3-phase-muino-light-sensor-encoder/)
* For big orders please make a request: [email](mail:[email protected])
* My webshop is located at [muino.nl](https://muino.nl). However, using Tindie for purchases results in marketing elements being displayed on my website. Consequently, I haven't dedicated time to enhancing the visual appeal of my site.

### Comfirmed supported devices
* KiWa V200 (Designed for)
* Honeywell v200 (Designed for)
* KiWa R400 (Look to Sensus 620)
* Sensus 620 (needs slight enlarging of two holes, and placement looks maybe less nice)
* Elster Honeywell (some)
* Itron Actaris Schlumberger
* You can always donate to let my create a watermeter compatibility..

# First time user
Thank you for buying the Muino Water Meter Reader :). So here I tried to explain the steps what to do for your installation!

## What do you need

* USB-C cable that can power de water-meter
* Some device with WiFi for adopting it your network
* Access to your Home-assistant

## Installation steps

1. Place the Muino Water-Meter Reader to your water-meter, I and others use M2.5/M4 screws/bolts to attach. It will be firm in the PCB as attended. For some meters there are no holes and those people use tie-wraps or just tape..
2. Connect the USB-C power
3. Go to your phone/wifi-device and connect to the water-meter WiFi (if you need a password: `12345678`)
4. Go in Home assistant to your devices and adopt the Watermeter

## Water Sensor Update Protocol

1. **After restart**: Upon restart, a zero value is sent to inform the home assistant that the sensor has been reset.
2. **Calibration**: The sensor calibrates during the first 2 liters of water usage.
3. **Sending Updates**: After calibration, the sensor sends updates to the home assistant system. It waits until it detects 2 liters of water usage and then pauses for 1 minute before sending the update. This prevents interruptions during activities like showering.

#### Don't forget to Add Muino Water-Meter Reader, to your HA Energy-dashboard

# Development
``` bash
Expand Down
95 changes: 71 additions & 24 deletions muino-water-meter-esp32.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


# These substitutions allow the end user to override certain values
substitutions:
name: "muino-water-meter"
Expand Down Expand Up @@ -25,25 +27,41 @@ esp32:
interval:
- interval: 100ms
then:
- component.update: report_liters
- component.update: report_liters_rounded
# - component.update: report_liters
# - component.update: report_liters_rounded
- output.turn_on: sensor_power
- component.update: light_sensor_a_dark
- component.update: light_sensor_a_dark
- lambda: |-
if ((millis() - id(last_water_flow)) >= 60000) { // 300,000 ms = 5 minutes
// Update 'report_liters' and 'report_liters_rounded'
id(last_reported_liters__mili) = (int)(1000*(id(liters)+id(phase)/6.0));
id(last_reported_liters) = id(liters);
id(last_water_flow) = millis();
}
- interval: 1s
then:
- component.update: report_liters
- component.update: report_liters_rounded
- logger.log:
level: INFO
tag: max_average
format: "a:%d b:%d c:%d"
args: [ 'id(max_a)', 'id(max_b)' , 'id(max_c)']
- logger.log:
level: INFO
tag: min_average
format: "a:%d b:%d c:%d"
args: [ 'id(min_a)', 'id(min_b)' , 'id(min_c)']
# - interval: 10s # Check every 10 seconds to reduce load, adjust as needed
# then:
# - lambda: |-

# - interval: 1s
# then:
# # - component.update: report_liters
# # - component.update: report_liters_rounded
# - logger.log:
# level: INFO
# tag: time
# format: "o:%d"
# args: [ 'id(last_water_flow)']
# # - logger.log:
# level: INFO
# tag: max_average
# format: "a:%d b:%d c:%d"
# args: [ 'id(max_a)', 'id(max_b)' , 'id(max_c)']
# - logger.log:
# level: INFO
# tag: min_average
# format: "a:%d b:%d c:%d"
# args: [ 'id(min_a)', 'id(min_b)' , 'id(min_c)']

# Toggle switch
switch:
Expand Down Expand Up @@ -139,10 +157,13 @@ sensor:
- output.turn_off: led
#- output.turn_off: sensor_power
- component.update: phase_coarse
# keep track last time updated

# dark sensor values
- platform: template
name: "sensa_dark"
force_update: false
internal: true
id: ad
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
Expand All @@ -153,6 +174,8 @@ sensor:
- platform: template
name: "sensb_dark"
id: bd
force_update: false
internal: true
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
accuracy_decimals: 0
Expand All @@ -161,6 +184,8 @@ sensor:
- platform: template
name: "sensc_dark"
force_update: false
internal: true
id: cd
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
Expand All @@ -171,6 +196,8 @@ sensor:
# sensor values
- platform: template
name: "sensa"
force_update: false
internal: true
id: al
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
Expand All @@ -180,6 +207,8 @@ sensor:
- platform: template
name: "sensb"
force_update: false
internal: true
id: bl
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
Expand All @@ -189,19 +218,22 @@ sensor:
- platform: template
name: "sensc"
force_update: false
internal: true
id: cl
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
accuracy_decimals: 0
lambda: |-
return id(light_sensor_c_light).state;
# substracted values
- platform: template
name: "sensa_sub"
id: as
force_update: false
internal: true
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
accuracy_decimals: 0
Expand All @@ -211,6 +243,8 @@ sensor:
- platform: template
name: "sensb_sub"
force_update: false
internal: true
id: bs
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
Expand All @@ -220,6 +254,8 @@ sensor:
- platform: template
name: "sensc_sub"
force_update: false
internal: true
id: cs
device_class: "ILLUMINANCE"
unit_of_measurement: "lx"
Expand All @@ -231,6 +267,7 @@ sensor:
- platform: template
name: "water_liter_sensor"
id: report_liters
force_update: false
device_class: "water"
unit_of_measurement: "mL"
accuracy_decimals: 0
Expand All @@ -239,20 +276,21 @@ sensor:
if (id(liters) < 2){
return 0;
}
return (int)(1000*(id(liters)+id(phase)/6.0));
return id(last_reported_liters__mili);
- platform: template
name: "liters"
id: report_liters_rounded
force_update: false
device_class: "water"
unit_of_measurement: "L"
accuracy_decimals: 0
state_class: total_increasing
lambda: |-
if (id(liters) < 2){
if (id(last_reported_liters) < 2){
return 0;
}
return id(liters);
return id(last_reported_liters);
- platform: template
id: phase_coarse
Expand Down Expand Up @@ -328,7 +366,6 @@ sensor:
if ((x - 5) >= y && y < 2500) {
return x;
} else {
return (int)((1 - alpha_cor) * (float)x + alpha_cor * (float)y);
}
};
Expand All @@ -354,6 +391,7 @@ sensor:
short i = id(phase) > 2 ? id(phase) - 3 : id(phase);
if (pn[i + 2] < pn[i + 1] && pn[i + 2] < pn[i]){
id(last_water_flow) = millis();
if (pn[i + 1] > pn[i])
id(phase)++;
else
Expand All @@ -368,6 +406,15 @@ sensor:
globals:
- id: last_reported_liters
type: int
initial_value: '0'
- id: last_reported_liters__mili
type: int
initial_value: '0'
- id: last_water_flow
type: uint32_t
initial_value: '0'
- id: phase
type: int
initial_value: "0"
Expand Down Expand Up @@ -396,11 +443,11 @@ globals:
- id: min_c
type: int
- id: upper_bound
initial_value: "1000"
initial_value: "1500"
type: int
- id: lower_bound
type: int
initial_value: "10"
initial_value: "5"

# Make sure logging is correct for solving platform IO bugs
logger:
Expand Down
Binary file modified static/img/muino_with_case.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,24 @@ The Muino Smart Water Meter is a **single-board** device that measures water con
# First time user
Thank you for buying the Muino Water Meter Reader :). So here I tried to explain the steps what to do for your installation!

### What do you need
## What do you need

* USB-C cable that can power de water-meter
* Some device with WiFi for adopting it your network
* Access to your Home-assistant

### Installation steps
## Installation steps

1. Place the Muino Water-Meter Reader to your water-meter, I and others use M2.5/M4 screws/bolts to attach. It will be firm in the PCB as attended. For some meters there are no holes and those people use tie-wraps or just tape..
2. Connect the USB-C power
3. Go to your phone/wifi-device and connect to the water-meter WiFi (if you need a password: `12345678`)
4. Go in Home assistant to your devices and adopt the Watermeter

## Water Sensor Update Protocol

1. **After restart**: Upon restart, a zero value is sent to inform the home assistant that the sensor has been reset.
2. **Calibration**: The sensor calibrates during the first 2 liters of water usage.
3. **Sending Updates**: After calibration, the sensor sends updates to the home assistant system. It waits until it detects 2 liters of water usage and then pauses for 1 minute before sending the update. This prevents interruptions during activities like showering.

#### Don't forget to Add Muino Water-Meter Reader, to your HA Energy-dashboard

Expand Down

0 comments on commit 013d8b0

Please sign in to comment.