Water meter

Good Evening all,

I am creating a water meter as per this link:
https://www.pieterbrinkman.com/2022/02/02/build-a-cheap-water-usage-sensor-using-esphome-home-assistant-and-a-proximity-sensor

I have copied the code and

sensor:
- platform: pulse_counter
    pin: GPIO12
    update_interval : 6s
    name: "water pulse"
    id: water_pulse

- platform: pulse_meter
    pin: GPIO12
    name: "Water Pulse Meter"
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Total"
      unit_of_measurement: "liter"

  - platform: template
    name: "Water Usage Liter"
    id: water_flow_rate
    accuracy_decimals: 1
    unit_of_measurement: "l/min"
    icon: "mdi:water"
    lambda: return (id(water_pulse).state * 10);
    update_interval: 6s

ESP doesn’t seem to like the code and giving me the following error:

ERROR Error while reading config: Invalid YAML syntax:

mapping values are not allowed here
  in "/config/esphome/water-meter.yaml", line 27, column 8:
        pin: GPIO12
           ^

Does anyone have any ideas where I am going wrong?

Kindly appreciated

I think your indentation is wrong

whats that? / What do you mean?

It should be like this

sensor:
  - platform: pulse_counter
    pin: GPIO12
    update_interval : 6s
    name: "water pulse"
    id: water_pulse
1 Like

Thats worked thank you :slight_smile:

i’m have the same problem , and the solution supposed here , creates new errors

what is the solution of this cascade of errors?
SEE image with my error below

image

#https://www.pieterbrinkman.com/2022/02/02/build-a-cheap-water-usage-sensor-using-esphome-home-assistant-and-a-proximity-sensor/
sensor:
- platform: pulse_counter
  pin: GPIO12
  update_interval : 6s
  name: "water pulse"
  id: water_pulse

- platform: pulse_meter
    pin: 6
    name: "Water Pulse Meter"
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Total"
      unit_of_measurement: "liter"

  - platform: template
    name: "Water Usage Liter"
    id: water_flow_rate
    accuracy_decimals: 1
    unit_of_measurement: "l/min"
    icon: "mdi:water"
    lambda: return (id(water_pulse).state * 10);
    update_interval: 6s

found a working solution in this topic

and i used this code a user replied

sensor:
- platform: pulse_counter
  pin:
    number: GPIO4
    mode:
      input: true
      pullup: true
  update_interval : 5s
  name: "water pulse"
  id: water_pulse

- platform: pulse_meter
  pin: 
    number: GPIO4
    mode:
      input: true
      pullup: true
  name: "Water Pulse Meter"
  unit_of_measurement: "liter/min"
  icon: "mdi:water"
 
- platform: pulse_meter
  pin: 
    number: GPIO4
    mode:
      input: true
      pullup: true
  name: "Water Liter Meter"
  unit_of_measurement: "liter/min"
  icon: "mdi:water"
  total:
    name: "Water Meter Total" 
    unit_of_measurement: "m³"
    id: water_meter_total_esp
    accuracy_decimals: 3
    device_class: water
    state_class: total_increasing
    filters:
      - multiply: 0.001

- platform: template
  name: "Water Usage Total"
  id: water_usage_total_esp
  accuracy_decimals: 0
  unit_of_measurement: "liter"
  icon: "mdi:water"
  device_class: water
  state_class: total_increasing
  lambda: return (id(water_meter_total_esp).state * 1000);
  update_interval: 10s

There are several issues with the instruction provided by Pieter. At least in my case. The indentation is incorrect. ESPhome does not allow to use Pins several times, anymore. On my NodeMCUv3 there is 3V on VIN but I could get 5V from VU. Anyhow, the sensor requires 6V minimum and does not work on 5V. I am now waiting for some step-up modules
Below the code I could at least flash:

sensor:
- platform: pulse_counter
  pin: 
    number: GPIO12
    allow_other_uses: true
    mode:
      input: true
      pullup: true
  update_interval : 6s
  name: "water pulse"
  id: water_pulse

- platform: pulse_meter
  pin: 
    number: GPIO12
    allow_other_uses: true
    mode:
      input: true
      pullup: true
  name: "Water Pulse Meter"
  unit_of_measurement: "liter/min"
  icon: "mdi:water"
  total:
    name: "Water Total"
    unit_of_measurement: "liter"

- platform: pulse_meter
  pin: 
    number: GPIO12
    allow_other_uses: true
    mode:
      input: true
      pullup: true
  name: "Water Pulse Meter"
  unit_of_measurement: "liter/min"
  icon: "mdi:water"
  total:
    name: "Water Meter Total"
    unit_of_measurement: "m³"
    id: water_meter_total
    accuracy_decimals: 3
    device_class: water
    state_class: total_increasing
    filters:
      - multiply: 0.001

- platform: template
  name: "Water Usage Liter"
  id: water_flow_rate
  accuracy_decimals: 1
  unit_of_measurement: "l/min"
  icon: "mdi:water"
  lambda: return (id(water_pulse).state * 10);
  update_interval: 6s

It works.
This is what I get in Home assistant:
Screenshot 2024-02-17 161420
The folowing sensors are not working:
-water pulse
-Water Total
-Water Usage Liter