Gas meter from Xiaomi/Aqara door sensor (ZigBee)

Hi,

I’ve tried to install aqara reel sensor to my gas meter, but i do not get any signal. Anyone knows if this gas meter sent some pulses? Thanks.

Cool project. I have a spare aqara sensor. Will give this a go. My only issue if I get this to work is the gas meter lady who comes once a month to read the display & prints out the bill. Wonder if she will say something with an unknown probe taped to the meter?

image

Hey guys,

i spend hours in changing configuration, id´s and customizing, but i don´t see anything in my Energy-Dashboard.

Do you have an indea?

configuation.yaml

homeassistant:
  customize: !include customize.yaml

# Sensor für den Gaszähler
sensor:
  - platform: template
    sensors:
      gasmeter:
        friendly_name: Gasmeter
        value_template: "{{ states ('counter.gaszahler') | float * 0.01}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:gas-burner"
        device_class: gas


customize.yaml

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

thanks for help

can this work with any meter that has a pulse?

This will work with any meter that have a pulse on a specific quantity, the calculations need to be modified to that but the idea will work. Gas, water, energy, wind speed, what ever thing you can think of.

Maybe this can solve your issue:

Is it possible to also get instantaneous usage value out of it somehow? Like for example how majority of electricity meters make it possible. It would be nice to plot some nice graph out of it on my dashboard.

i want to try this…

    value_template: "{{ states ('counter.gas_counter') | float * 0.01}}"

is that what defines it?

ProTofik - can be calculated but you need to add a time component, like how many meters of gas/minute. The gas meter is not sending the impulse fast to calculate /second. You can see anyway in HA Energy how much gas you consumed /hour so it dos not make sense for me to create an sensor like this.

david1David - the template only calculates the real value on your gas meter in m3, basically the automation increase “helper counter” and the template makes the real number on your gas meter. I done this so I can sync the meter reading outside with the one in HA. In my country you need to read the meter monthly and report it to the gas company, this way you can send the reading directly form HA, no need to get to the meter and check the numbers there.

Hello,

I’m a new greenhorn in HA, but since I’m sick at home 2 Weeks, I worked hard the last days to understand it.

I integrated the gas counter without problems 3 days ago. Ok, finding the right position for contact was really difficult.

It worked fine for 2 days, but yesterday it doesn’t count any more in the energie dashboard and the sensor.gas_meter says problems. The gas counter works fine, but in the statistics of sensor.gas_meter there are no updates.

So I checked the customize.yaml and it says failure because “state_Class” is doubled in line…

So I removed the “state_Class: total_increasing” Now it said ok.

But in statistics, the sensor doesn’t worked. So I added the state_Class: total_increasing again. But it also doesn’t worked.

OK, then I removed the Sensor long therm statistics and the sensor and hoped, that it will now create a new one with restart from HA.

It created, but there wasn’t a button for the sensor.gas_meter to edit and see the statistic data anymore. It Also didn’t count in the energie dashboard again, but it seems to count in the detail view of the sensor itself.

Ok, it seems I totally messed it up.

So, I now set it up complete new with changed sensor names in all yaml’s to sensor.gas_meter2 to create a complete new sensor to start from blank.

After restart, the sensor appeared and seems to count in history, but again, there is no edit button and no counting in energie dashboard. But it says no issue.

Then I remembered I installed node red addon and integration, maybe this caused Problems.

So I removed it, but nothing changed. And yes, I didn’t made a backup before installing node red, wasn’t clever.

So, here I am. Maybe some of you has an idea. When I have to set up HA complete new, it would be annoying for 3 day work, but tough luck!

Here is my customize.yaml

sensor.gas_meter2:
  state_class: measurement
  state_Class: total_increasing
  last_reset: ‘2021-08-20T06:43:36.740703+00:00’

Counter Part from automations.yaml

- id: '1665776988103'
  alias: Gaszähler
  description: ''
  trigger:
  - type: not_opened
    platform: device
    device_id: 578a59cedd92754eb53baae541a21deb
    entity_id: binary_sensor.shellydw2_6f2c13_door
    domain: binary_sensor
  condition: []
  action:
  - service: counter.increment
    data: {}
    target:
      entity_id: counter.gas2
  mode: single

and configuration.yaml

# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

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


http:
    ssl_certificate: /ssl/fullchain.pem
    ssl_key: /ssl/privkey.pem
    cors_allowed_origins:
        - https://google.com
        - https://www.home-assistant.io
    ip_ban_enabled: true
    login_attempts_threshold: 5
    
    
homeassistant:    
    customize: !include customize.yaml
sensor:
  - platform: template
    sensors:
### Gas meter template from counter
      gas_meter2:
        friendly_name: Gas Meter2
        value_template: "{{ states ('counter.gas2') | float * 0.1}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas
        
        
      # Example configuration.yaml entry with all entry types (delete/comment out as necessar
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /config
      - type: disk_use
      - type: disk_free
      - type: memory_use_percent
      - type: memory_use
      - type: memory_free
      - type: swap_use_percent
      - type: swap_use
      - type: swap_free

      - type: processor_use
      - type: processor_temperature
      - type: last_boot

Many thanks

Timo

And here the actual screen shot

Oh,

I had an mistake in writing with the state_class: total_increasing I wrote it with upper C

So now, there are no attributes at Gas Meter2, but here is the failure I said before, with the duplicated state_class
it says duplicated mapping key

Screenshot 2022-10-21 141126

Edit:

It seems I solved it. It was the upper C

Now i created a third meter witch worked, then I deleted all added code, restart, now adding the original code, restart…

Now the previous sensor.gas_meter has it’s edit button back. Only the previous data is gone… so far.

The only thing now, it seems that there is no graph in the energie dashboard. Just the numbers in the circle and in the calculation under the graph

Edit 2

OK,

it seems to work fine now.

Sorry, if someone had already work with it.

Regards

Timo

Hi, another new comer here and I can promise you I’ve read all of the above posts and still I can’t get the Gas meter into my Energy Dashboard.
A slight change in my setup is that I have used Shelly Plus i4 to get the signal from my gas meter which is a U6P Diaphragm Gas Meter which was installed in 2015.
image
It has a Pulse Module & Lead for Gas Meter P/N 21423 which was installed with the meter:

I have wired up the Shelly i4 to use channel 2 as a switch for the pulse signal from the Pulse module and I can see that in the Shelly app I am getting signals

Using the Shelly integration I have integrated the i4 and have enabled the Binary Input Sensor and also see that I am getting a signal for each pulse
image

Using the code from above with the suggested recent modifications I have created the helper

I have added the automation

- id: '1667311475048'
  alias: Gas pulse counter
  description: Count gas meter pulses
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.shellyplusi4_a8032ab0eb98_input_2
    from: 'off'
    to: 'on'
  - platform: state
    entity_id:
    - binary_sensor.shellyplusi4_a8032ab0eb98_input_2
    from: 'on'
    to: 'off'
  condition: []
  action:
  - service: counter.increment
    data: {}
    target:
      entity_id: counter.gas_counter
  mode: single

I have added the configuration.yaml components:

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

and have entered the customize.yaml requirements

sensor.gas_meter:
  state_class: total_increasing

I can see that stats m3in Developers tools

I have checked the config in developers tools and restarted the HA server but still I don’t see the sensor in the Energy dashboard:
image

Any assistance would be greatly appreciated.

You are missing some attributes in customize.yaml

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

Hi @mpetcu when I add those lines to my customize.yaml I get the below error:
image

And going by previous replies to this thread it was suggested that last_reset was no longer required.

And after adding those lines I still get no sensor in the Energy Dashboard:
image

This may be one of the issues - HA may be filtering by the measurement units above that entity selector for the gas consumption. It may literally need to be m³ and not m3. I’d clear the measurement and stats history for the entity too after changing it as I’ve found in the past that the old history with mixed units can keep it from cleanly switching over.

Hi Beatle,
Thank you for posting all this information here. While you’re looking for solutions to your step of the problem, you may have helped me with mine, sort of…

This page:

has this:

Suffix P indicates a meter with a pulse facility; a pulse module and lead is not supplied with this meter.

Which is quite significant for me, as my gas meter here in Australia which looks identical to yours is conspicuously labeled U8. It took my mind back to the email from the Aussie meter supplier EDMI who said that they hadn’t supplied meters with pulse capability because there wasn’t enough demand for them from the gas companies here. And I was confused at the time, because I said I could see the little magnet going around on the cog. But now I’m wondering if it’s just a piece of metal or plastic to keep the mass of the cog within specs. And if so, it’s no wonder I’m having such trouble detecting it with a reed switch - there’s no blooming magnet!!

In any case, I’ve since tried just the guts of the aqara door sensor, without success, and my next attempt is going to be a hall effect sensor + esp32. If it isn’t a magnet attached to that cog, I can only hope its ferrous metal so I have a chance of picking up a wiggle…

@teleksterling you beauty, that fixed it for me but I had to go on a big learning curve to get this working as I had to clear the stats from the SQLite3 DB which doesn’t seem to be well documented, so I might just do that myself.
Now I have a Gas meter sensor:
image
And in the stats it’s showing properly too:


Now just to wait for the Energy dashboard to start reflecting the Gas consumption with pricing and I’m all sorted

1 Like

Hi all. Any Aussies have an itron branded meter? Could be a European brand too by the look of it?

I can’t detect anything with my aqara sensor so far.

I’ve tried sensing the last wheel which has a silver reflective section on the 0 position and also the dial that spins below the meter numbers. The clear plastic housing might be stopping me getting close enough.

I have all the code working, just triggering the sensor manually with a magnet for testing.

Check my initial post and stop the meter in the constant impuls state and try to find the position of the sensor, your meter has the marking 1 imp / 10dm3, witch means the second red number is the one that is sending the impulse.