Gas meter from Xiaomi/Aqara door sensor (ZigBee)

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.

I have added a fictive ID. Now there is no mistake in the configuration.

grafik

Now it counts when I approach a magnet.

Have you first fixed the mounting on the gas counter and then selected the energy dashboard or should I do it vice versa?

Can I just correct the real state of the gas meter like this?
This is the real number that is on the gas meter.

You have to use, services → counter: configure, select new value, and use the number with no decimals, you are modifying the counter not the sensor.

Here you can see my tests. From 8:45 PM on it works and is isntalled. Now I have to check if the counting is correct.

What happens when I modify the sensor as I did?

Hi Marius,

I set a new value in the counter. I saw that also the sensor automatically updated.

I have 11861,683 m³ on my gas counter in reality.

Is that correct like this? Any disadvantage when I set the big number as value?

grafik