Gas meter from Xiaomi/Aqara door sensor (ZigBee)

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

I found now out what the problem was:

No reset since the February update. and other state class.

Just use this and it will work!

sensor.gas_leser:

sensor.gas_leser:
  state_class: total_increasing

Hey everyone, great project, looking into this as well. What’s your experiences with battery life so far? Thinking about trying it with the Lidl window contact, and replacing the AAAs with AAs.

From my experience until now and my calculations if you are a “home user” and your average consumption per month is about 250m3 of gas in winter and about 10m3 in summer.
Your sensor will open/close about 800 times per day in winter for about 3-5 months the rest we can assume is normal usage for the sensor, battery of Xiaomi sensor is rated one year (cr2032) with normal usage so determined that the normal battery will last no more then 3-4 months in winter.(not taking in consideration the cold temperature that will just destroy the CR2032)
I have added an AA 3.2V Feo4 rechargeable battery and since 4 months is still at 100% but the reading of the sensor is made for the CR2032 voltage curve so I do not trust the status.
If the Lidl sensor has AAA battery’s from the start I will not bother replacing them just test and see how much it lasts.

Hi all

Great project Marius.

New user here, so I’m still on the steep learning curve.

I have an Aqara sensor that I want to use to read my Landis and Gyr 750 meter (earlier post from another Aussie said that it will work (thanks mate!))

I have created everything, when I swipe the magnet past the sensor the counter increments. The Gas symbol displays on my energy dashboard, but I’m not reading any usage. I’m trying to get the working on the bench before moving to the Gas meter cabinet (which will be fun because it’s metal).

I have:

counter.gascounter

sensor.gasmeter

So after all that preamble here’s my setup in home assistant (which runs on a PI with an external HDD).


Automations:
================================================================

- id: '1645368831245'
  alias: Gas Counting
  description: Gas Meter Consumption
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_magnet_acn001_60c22500_ias_zone
    id: Aqara Gas Meter
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: counter.increment
    target:
      entity_id: counter.gascounter
  mode: single
  
  
  
 configuration.yaml
================================================================
 
  # Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

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

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


		
		
 customize.yaml
================================================================
 sensor.gasmeter:
  state_class: total_increasing
  last_reset: '2021-08-20T06:43:36.740703+00:00'

I’m obviously doing something wrong, but I can’t figure out what.

Any ideas please

You can start troubleshooting using the “developer tools” change the state of the sensor from off to on and see if you get the counter moving.