Gas meter from Xiaomi/Aqara door sensor (ZigBee)

Thanks! I did so. The mistake: the customize.yaml has to be uncluded :confounded:

homeassistant:
  customize: !include customize.yaml
1 Like

In my case, if I configure counter value to be the same as gas meter, it is not working correctly, because it adds 1 m3 per each count. And then each count is multiplied by 0.01 in the sensor template. To make it a “real” counter, I could change steps to 0.01 m3 and remove template from the sensor config, but counter is not accepting 0.01 steps? Anyone has a working counter config to share, which is adding incremental values in the same way as gas meter? :slight_smile:

Read first post, all the info is there, the counter increments only 1 but you create a template sensor from that with correct value, then you can sync the counter with the meter by adding to the counter two decimals that are on the meter.

OK, got it - needed to add 2 decimal numbers at the end of the meter value to get it correct for the sensor.

Abslolutelly cool! Great job Marius!
Based on this info, I have managed to to use a Lidl Zigbee Magnetic conntact to read the water meter, for sure with an external reed, which I still need to fix permanentlly in place.

I have only 2 question:

  1. How do I reset all the collected data? I did a lot of testing and for sure it’s not accurate anymore.
  2. I’m using node red to increase the counter, and I would like to create a leakeage warning, if impulses are constanttly detected for more than 30minutes, means that there could be a leakeage and I want to be notified. Since I’m a beginner in Node Red, need some help where to start.

Thanks again for the great article!

Hello Bernard
I will like more info on the water meter setup, I do not know if all water meters have the impulse. (some pictures will be useful here, I’m interested myself)

  1. The collected data like history in sensors I do not know how to reset. The counter can be reset from Developer Tools → Services → Counter: Configure
  2. I do not use Node Red, I never like it (don’t know why) but you can create an automation in HA. You can start here

Thank you. Merci domnule!

The counter I did manage to reset, but I still have a 1m³ peak from day I did approach magnet to the sensor 100 times, just to check that I don’t miss any readings. Silly, I know. But was fun !

Regarding node-red, it’s great for rookies who never programed anything in their life and are to old and to busy to learn :slight_smile: Thanks for the Link, it’s a good staring point!

Once again, great topic!

Hi Folks - Thank you for this information! for our Australian folks:

I can confirm the aqara zigbee sensor (no need to change the reed sensor) works really well with the SPAusnet Meter : LANDIS + GYR Model 750 gas meter.

The Zigbee Sensor tucks under (with no shell) and can be blue-tacked in place. If you have access to a 3d printer probably could make a nice adaptor for it. I will report back how quickly the standard battery depletes.

1 Like

I have found the solution to detect continous flow over a specific time. It was much easier than I thought.
The key is to use a message speed node, node-red-contrib-msg-speed. Now I’m getting a notification if the watter runs at a specific rate, above 5 minutes. Works surpringsly well, with the current setting is detecting only the shower usage, no washing machine consumption is detected. Will increase the time after the test phase.

Hi All,

I think something must have changed in HA in recent updates again because I read every post in this thread and I fail at last step, creating meter in configuration.yaml.

So if I put the below into my configuration.yaml, configuration file is valid and sensor.gas_meter appears in development tools and counts as I touch the aqara sensor with magnet.

#sensors
sensor:
  - platform: template
    sensors:
### Gas meter template from counter
      gas_meter:
        friendly_name: Gas Meter
        value_template: "{{ states ('counter.gas_counter') | float * 0.01}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas

It however won’t appear on the list of devices available devices in energy dashboard. If I understand correctly that is because I need state_class: measurement. If I however add it as new line under device class, config check fails with his message:

Invalid config for [sensor.template]: [state_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->gas_meter->state_class. (See ?, line ?).

What am I doing wrong?

The answer is just above from maryjam01MG
in configuration.yaml you need to add:

homeassistant:
  customize: !include customize.yaml

in customize.yaml you ned to add

sensor.gas_meter:
  state_class: measurement
  last_reset: '2021-08-20T06:43:36.740703+00:00'

Ah I get it. It works now, thanks.

Hi Marius. Great project. Was struggling with using an esp-01 where the Aqara is in your project. Failed miserably! I’ve followed your instructions and other snippets in this blog to the letter and although I’m getting the open/closed status from the Aqara and I’m able to insert the counter into the Energy dashboard, I don’t seem to be getting any increments when I know I’m using gas. I too am using the Zigbee Dongle and getting a linkquality of about 10. I’m also getting messages in Node-Red but I can’t seem to filter out the ‘closed’ status to use the data elsewhere. I’ve gone over the instructions numerous times but still unable to make it fully work. Any advice?

Hello, my take is to dich all RedNode staff and just follow my automation for incrementing the counter.
Is just a simple automation can be created in the visual editor. If you get the open Open/Closed status you may need to replace it in the automation. My is based to on/off status.

Hi. You’re right regards Node-RED. I need to get the counter incrementing first! When I select Automations via Configuration there doesn’t seem to be one. So what’s the Counter created in Helper doing? Also I have cleared all references to the project in Config, customization and automation yaml’s and started again. In your Automation yaml you show line entity_id 0x158d000etc. Is the hex address unique to you as my door sensor has a slightly different 08a09f_contact. Is this relevant? Thanks for your advice, very welcome.

Hey guys, awesome project.

I’m kinda stuck though. My added “Gas Counter” counts +1 every revelation, but it doesnt appear in the “Gas Meter” statistic.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

homeassistant:
  customize: !include customize.yaml

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: template
    sensors:
      ### Gas meter template from counter
      gas_meter:
        friendly_name: Gas Meter
        value_template: "{{ states ('counter.gas_counter') | float * 0.01}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas

So the counted number isn’t added to the Gas Meter. I can see in the Logs that the automation is working fine.

Thanks for your help.

Found the Error. The underscore in counter.gas_counter is not allowed. Changed everything to counter.gas and it started working.

It’s counting but I don’t know if it is all set and done yet.

Is there a way to add my total m3 gas used (number from my analog gas meter) in a sensor and add the counter to that sensor too to see my total gas used on the go?

Eventually got this working. Binned Node_RED. Good call!. I have a request from any member of the forum: how can I create a counter in Lovelace which mimics the actual gas meter reading, example 23456.021? I understand that floats and counters per say don’t do decimals, so is my plan even possible? Anyone tried?

Hi all,

I have received today my aqara door sensor, but I have problems to get the counter correct into HA.

I have added the following into my configuration.yaml:

  - platform: template
    sensors:
### Gas meter template from counter
      gas_meter:
        friendly_name: Gas Meter
        value_template: "{{ states ('counter.gaszaehler') | float * 0.01}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas

When I check my configuration under server control everything is ok until here.

In my customize.yaml I added the following:

sensor.gas_meter:
  state_class: measurement
  last_reset: '2021-08-20T06:43:36.740703+00:00'

When I now add the following into my automations.yaml I get an error:

alias: Gas Counting
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_magnet
    from: 'off'
    to: 'on'
condition: []
action:
  - service: counter.increment
    target:
      entity_id: counter.gaszaehler
mode: single

I have following helper added:

And the entity id of the sensor should me binary_sensor.lumi_magnet

Is there someone who can help me? I am trying this since 2 hours.

Thanks.

Hello, if all is ok until the automation just add the automation using the visual editor.