Gas meter from Xiaomi/Aqara door sensor (ZigBee)

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:

Hi All
I love this project and i do have it working,
I am having issues with the measurement, I am showing ft3 instead of m3 (little 3’s) in the energy page. I have got m3 in my sensors.yaml exactly as the 1st post. (yes I do have a sensors.yaml that is correctly referenced in Configuration.yaml which is also used for my electricity)
Any ideas.

Many thanks

Based on this post and this video I did my Proof of Concept yesterday with a $5 Tuya Zigbee window sensor.

I had to dismount the plastics so that it can be put close enough, and it only works in a very specific diagonal position:
gas meter PoC

Problems (other than the whole thing looking like that!):

  1. When the 0 goes by, it closes/opens/closes/opens, i.e. the magnet is acting twice, duplicating the messages.
  2. Sometimes it sends a flood of messages instead of 4. Not sure why.
  3. These are causing a huge, unacceptable battery hit. But I see I’m not the only one, as many are plugging bigger batteries or even a battery pack.

I was expecting a higher consumption than usually, although not this much.

So, I’m waiting on a separate Reed switch to solder to the board and hoping that it improves.
I will also see if I need to replace the battery with two AA 1.5V to make 3V.

Other than that, it’s working great! Of course with an associated Automation (0.005 instead of 0.01 since it’s duplicated) Number Helper, Template Sensor, adding it to Energy Dashboard.

The alternative was buying the official sensor (a glorified Reed switch within a box designed to fit on my gas meter) to connect it to a Zigbee emitter anyway, but it’s 44€ vs 1€ so it’s a no from me (plus no fun!).

EDIT to add:
Learnt/remembered that a metal plate can block a magnetic field, so I used a small metal plate that I had around to block the lower part of the area, therefore blocking 2 of the 4 events. Now it only works on the top side (so one close, one open) as it should.

I also replaced the battery and it’s staying 100% for now (we’ll see how long). Still waiting on the Reed switch, plus considering connecting it to any Tradfri button/remote, maybe even a Styrbar remote which is not only the same price as the Shortcut button (10€), but uses 2 AAA batteries already, so less tinkering!
I opened them and tested them (based on some videos) and a Reed switch also works there…

2 Likes

Hi and thanks to @mpetcu for the thread. It is working well for me. I just have an issue when I should restard HA or in case of HA being off for a while… All the ticks send are “lost” is there a way to solve this issue… maybe using an esphome (esp32) instead of a door sensor? Has anyone found the solution to this issue ? thx.

That’s exactly what I’ve been thinking about :thinking:

Sadly haven’t been able to find anything about it online and I don’t think a simple photo-resistor in between would do anything on its own as it wouldn’t connect the circuit.

Probably a reason no one’s done it.

Hi, I see a lot of questions about connecting a photo resistor to the Aqara door sensor, is not that hard in theory, but I did not have any application for this so personally did not have the interest.
Here how I will do it:

  • get an 3,3 Arduino module like the one in the photo
  • connect the GND, VCC directly to an 3,6V lifeo4 battery same one that I have connected the Aqara sensor in the first post
  • remove the Reed sensor from the Aqara and connect the D0 from the photoresisor board.
  • the sensitivity of the on/off signal will be ajustabile from the photoresisor board.

If is close to an light source possibly can be adjusted to count signals with the same configuration in HA.
I do not know about the power consumption of the board so battery can be an issue.
Have fun testing this :slight_smile:
Capture-1

2 Likes

I’m struggling with this project.
I’m migrating from iobroker, where i had a similar automation running to track my gas usage. Now i’d like to have it in HA, too.

Is there a working solution for the current version of HA? There are plenty of ways in here, but nothing seems to be working. also, i’m very new to HA!

configuration.yaml:

### Gas meter template from counter
      gas_meter:
        friendly_name: Gas_Meter
        unique_id: gas_meter
        value_template: "{{ states ('counter.gas_counting') | float * 0.01}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas

customize.yaml:

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

automation

alias: Gas Counter
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.sensor_gas
    from: "off"
    to: "on"
condition: []
action:
  - service: counter.increment
    data: {}
    target:
      entity_id: counter.gas_counting
mode: single

And you must add a helper as Counter

1 Like

Hi mpetcu!

I also made my own gas meter. Based on these, I also equipped the water meter with a sensor. But unfortunately it doesn’t work.

Codes: configuration.yaml

sensor:
  - platform: template
    sensors:
      gas_meter:
        friendly_name: Gáz Mérő
        value_template: "{{ states ('counter.gazora_szamolt_impulzusok') | float * 0.01 + 30}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas
        attribute_templates:
          unique_id: GM
          entity_id: GME
          state_class: total_increasing
          last_reset: "2023-01-06T16:54:36.740703+00:00"

  - platform: template
    sensors:
      water_meter:
        friendly_name: Víz Mérő
        value_template: "{{ states ('counter.vizora_szamolt_impulzusok') | float * 0.01}}"
        unit_of_measurement: "m³"
        icon_template: "mdi:water"
        device_class: water
        attribute_templates:
          unique_id: WM
          entity_id: WME
          state_class: total_increasing
          last_reset: "2023-01-06T16:54:36.740703+00:00"

The water_meter entity is unreachable according to HA.

Please help me!

Edit: Order was restored, I reset everything, restarted HA.

Thanks!
I had it all the way you’ve posted, but just noticed, that my counter was named different than my automation.

Is there a way to set my current reading of the gas-meter without messing with ne monthly statics (aka adding 800m³ to the january)

Thanks!

1 Like

Are you using the Shelly Plus i4 DC? Sounds like an interesting solution, similar to my set up.

Hi @krash! I have the same gas meter in Spain. Could you find how to measure with the aqara sensor?
In my case I don´t have those cables coming out…
Another thing, I bought some TUYA door sensor and some magnetic sensor, but I´m not able to know where to solder them… any idea?

There is a hallotron in there H1