Gas meter from Xiaomi/Aqara door sensor (ZigBee)

Thanks a lot for these very helpful explanations. I setup everything successfully but struggled in the last step of editing HA → Configuration → Customizations. I searched long and hard, but I did not find this option in my HA configuration. When I try to add the info into configuration.yaml directly, I get the following error 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 ?).

Is there another way to change these attributes? Any help greatly appreciated!

Hello, you can add the information to customize.yaml in the main HA folder but that will require you to install file editor.

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

but is way simpler just to use the customize menu, do not know how can you miss it, I think is the last menu in Configuration

I don’t have the ‘Customizations’ Option in my HA (I think it is because I updated to a newer version of HA), but the trick with editing the customization.yaml file worked like a charm. Thanks a lot!
Merry Christmas!

Great article and idea! Minor tweak to this… there isn’t even a need to rewire the sensor etc. You can just put it in the whole foreseen on these gas meters as depicted in the picture… Th cool thing of this sensor is that it has a small “hook/edge” on the board which allows it to lock into place.

This is the “hook/edge” that I’m talking about…

Screenshot 2021-12-31 at 11.04.05

This makes it easy to install! Just remove the plastic shell et voila!

2 Likes

This is nice and easy but it will not last in time.

  1. If the meter is exposed to the elements the sensor will stop working at the first day with 80% humidity.
  2. For some of us the meter is enclosed in a metal box that will stop the ZigBee signal.
  3. Standard battery will not last long under this usage.

I have tested this in my first 2 weeks and this is a good solution for testing but for long term you have to fix all 3 points above.

3 Likes

In my case (I think it’s the same for you) the enclosure is in plastic so point 2 is indeed a non issue on this one. I do not see however how the humidity plays a role on this one compared to the external wire? (Maybe I’m missing something?). The only way to fix this would be indeed to raise the sensitivity of the sensor. I’ll do my testing with this setup first before bringing out my soldering wire again. :smiley:

Can tell (and show) me which batteries you use now?

Thanks again for your tutorial as well as input @mpetcu!

If you read my posts form the beginning you will understand that in my case and everybody in my country has the same 3 points to resolve. My take on how to fix the issues are in the posts including the battery type.

I didn’t really find the “case” in your post for holding these batteries (AA)… did you also buy those on tme.eu?

The battery is an AA size LiFePO4 battery it has 3.2 nominal voltage, normal litium battery will not do as it is 4.2 nominal.
You can use 2x1,5v battery to get the 3v needed for the sensor.
Holder and battery was ordered from AliExpress for other projects. Search for Soshine 3.2V LiFePO4
As I specified there, I wanted a rechargable solution and LiFePO4 battery’s tend to work better at low temperatures, my sensor is outside and in the winter the temperature will go -15 sometimes (that is Celsius)

If you want to try the original battery is rated for 1 year in the sensor for sure it will last at least 3-4 months in this situation if the temperature is above 10.

1 Like

Hi, I had a same error. Solution was that change the ‘’ to ‘’ at last_reset
image

Hi,
I configured the “Gasmeter” linke above. I Can´t configure the energy the gas consumption (in the right screenshot).
Or is there a mistake in the configuration?

Hi,
you missed to create the counter under configuration–>Automations&Scenes–>Helpers. If it’s done, you need to add this entity to your automation.

Thanks, @balagev79
I added the counter, but I can´t see any entity in the line “Gasverbrauch (ft, m, Wh,…)”.
image

It´s also counting…

you are missing the attributes, since the 2021.12 you have to add them to customization.yaml manually, no interface anymore.
customization.yaml

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

the sensor needs to look like this to be selectable in Energy under Gas.

Hi,
as @mpetcu mentioned, you need to put these attributes into customize.yaml…and restart HA!

Thanks! I did so. The mistake: the customize.yaml has to be uncluded :confounded:

homeassistant:
  customize: !include customize.yaml
1 Like

In my case, if I configure counter value to be the same as gas meter, it is not working correctly, because it adds 1 m3 per each count. And then each count is multiplied by 0.01 in the sensor template. To make it a “real” counter, I could change steps to 0.01 m3 and remove template from the sensor config, but counter is not accepting 0.01 steps? Anyone has a working counter config to share, which is adding incremental values in the same way as gas meter? :slight_smile:

Read first post, all the info is there, the counter increments only 1 but you create a template sensor from that with correct value, then you can sync the counter with the meter by adding to the counter two decimals that are on the meter.

OK, got it - needed to add 2 decimal numbers at the end of the meter value to get it correct for the sensor.

Abslolutelly cool! Great job Marius!
Based on this info, I have managed to to use a Lidl Zigbee Magnetic conntact to read the water meter, for sure with an external reed, which I still need to fix permanentlly in place.

I have only 2 question:

  1. How do I reset all the collected data? I did a lot of testing and for sure it’s not accurate anymore.
  2. I’m using node red to increase the counter, and I would like to create a leakeage warning, if impulses are constanttly detected for more than 30minutes, means that there could be a leakeage and I want to be notified. Since I’m a beginner in Node Red, need some help where to start.

Thanks again for the great article!