Hi guys my last project with is working flawlessly for 1 week now (some issues in the beginning first 2 weeks, issues: sensor position and not weatherproofing the sensor case)
I wanted a cheep and easy way to read my Gas meter (in the current context that price increased 5x in my country) Most of the gas meters have built in magnet that sends an impulse every 0.01 m3 (I have the BK-G4MT, is popular in Europe)
The gas meter in my country is located in front of the propriety on the street and no way you easy add power there, so a low power solution like ZigBee is the best in my case.
I used a Aqara door sensor witch I disassembled and added an size AA 3.2V Feo4 rechargeable battery (this is optional as I do not know how much the built in battery will last in this usage) and replaced the internal reed contact with a smaller one, 5-20AT sensibility.(works with the built in sensor I think, I managed to broke it, is very sensible)
Position of the sensor is very important and the best place I found showed in the picture. Home assistant has an automation that counts data to a sensor.
Hardware
ideal location for the reed sensor in my case
Software
HA → Configuration → helpers and create a counter
Automation
alias: Gas Counting
description: ''
trigger:
- platform: state
entity_id: binary_sensor.0x158d000708a09f_contact
from: 'off'
to: 'on'
condition: []
action:
- service: counter.increment
target:
entity_id: counter.gas_counter
mode: single
configuration.yaml
homeassistant:
customize: !include customize.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
in customize.yaml you ned to add
sensor.gas_meter:
state_class: measurement
state_class: total_increasing
last_reset: '2021-08-20T06:43:36.740703+00:00'
you can add it too energy and then you can get stressed that you consumed to much gas with heating
Tests and explications
The meter has one small magnet in the mechanism and once every 0.01m of gas you get a impulse. in the specific area, if the meter is stopped in the 0.XX9 the impulse is constant.
- Start by having the reed sensor on the wire connected to the PCB and working (test with original magnet)
- have someone use something that consumes gas in the house and try to stop the meter exactly in the 0.XX9-0 range (last digit must between 9 and 0 so that the 0.XX digit is somehow between two numbers)
- once the meter in that range the magnetic field is constant from the meter so you just check the positioning of the sensor (must be closed once you get the correct position) - use tape to fix the sensor, HA must report that sensor is “closed”
- once you start consuming gas again the sensor will go to “open” in HA once the 0.XX digit of gas meter will move to a number.
You can see in the picture that my meter was stopped at the constant impulse position XXX.7 2-3 9-0
If your meter has the marking in the picture then is 100% that you have the impulse coming from it.