Gas meter from Xiaomi/Aqara door sensor (ZigBee)

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.

Thankyou. I’ve tried stopping it as close as possible before and after 0 as pictured.

I’ve also tried taping the sensor in various locations and just running the gas to find anything. So far no pulses detected except with me manually using a magnet to ensure it works in the location network-wise.

Am I incorrect to assume the wheel at the bottom is what I’m meant to be detecting? Or is there actually a signal that gets transmitted only at the right time?

Edit I’m not opposed to drilling through the bottom of that’s going to work. i.e if the plastic is too thick?

As in the first post, the last number must be between 9 and 0, not exactly at 9 or 0.
The meter has an magnet so no fancy anything, if it has the impulse check meter instructions for the position of the original sensor. The magnet is closest to the original area when last digit is 9-0, that is the best time to detect his magnetic field.
Someone on the forum reported that his meter had a faulty magnet and the gas company replaced the meter with the same model and it worked after.

The manual for the meter says the pulse system is a cyble target. this is the rotating dial below the numbers. it rotates at the same rate at the last red wheel.

image
These Cyble sensors are purchasable but very expensive.

So this isnt using the meter numbers (wheels) at all. If there is a magnet on the second red wheel I’d need to cover the numbers in order to get close to it.

Edit, just saw that the target is non-magnetic so no good looking underneath near that. it’s numbers or bust

From your information the meter has a different type of registering the pulse, not using a magnet. You can use a hall sensor and ESP board to figure out a way, but will not be easy as the Aquara sensor.

1 Like

Hi again, although I have a working Gas Meter sensor that is feeding my energy dashboard it’s not calculating the cost in the dashboard. I’m not sure whether it’s an issue with the dashboard, the sensor of the rate but I have the following in HA:
IN developers templats:

daily electricity fee:  {{states('sensor.octopus_energy_electricity_current_rate') | float(0)}}
current gas rate: {{states('sensor.octopus_energy_gas_current_rate') | float(0)}}

produces the following output:
image
and in a self built dashboard I see the following using the same current_rate sensor:
image

In the energy dashboard I have specified the Gas Meter sensor created as per previous posts and the same current_rate sensor for cost:
image
But I don’t get any calculated cost in the dashboard:

Any advice most welcome or should I take this to another post with regards the Energy Dashboard?

I think I’ve just seen the issue myself, the Gas current rate is in GBP/kWh and the cost field is expecting GBP/m³ so I’ll need to resolve that.

Since the helper text already says “current price per m³”, it’s possible it may just want GBP and it’ll apply the /m³ itself.
Oh, or £!

Thanks for your help. I decided to focus on the water meter instead and have it working immediately using the same method.

I’ll look into purchasing a cyble sensor to get the gas values

So the raw value from the sensor is just a number but it is in fact £/kWh so even if it did use it, which it isn’t, it would be wrong, so I’ll either have to re-calculate it or ignore it.

I had a simialr problem. I am billed for usage in megajoules. A google search revealed 1 m3 = 37 MJ so I just multiplied my charge by 37 to convert it, and changed the units to AUD/m3

Wish there was a way to link up an aqara sensor to a photoresistor to work on my electric meters like this :frowning: