Gas meter sensor

Great idea! I had the same idea, just 7 months later :wink:
I’ve just started using HA so i like to learn of other users

@GobblerGuy how did you set up the other sensors (gas counter device, gasmeter)? Did you use node-RED, HA helpers or something else?

Thanks for sharing your project!

I use a helper for the counter.gas_meter:

then a HA automation for the update of the counter.gas_meter:

note that my tradfri switch is connected via Zigbee2mqtt so I see the switch presses as actions. I’ve got no idea if the same switch connected via some other method will appear the same. Note that I’ve used the brightness_move_up action as the switch is ‘pressed’ quite slowly. I’m not sure if you will see the same behaviour if you have a different method of integrating zigbee with you HA system. You might need to use a different switch press action.

Hey Chris,
I’m trying to set this up as you’ve described. I have compiled firmware with platformio and loaded script into tasmota, changed wifi and mqtt settings in tasmota and nothing else on an ESP8266.
While i love you say magic pulls values into home assistant, my magic appears not to work. :frowning:
I only need it to detect the gas meter reading and have the hall effect sensor wired only, not sure what I am missing?
Any chance you can help, or post your compiled firmware? Or anything?
Thanks

to compile i just used gitpod, just log in, change the one file “user_config_override.h” as per the smart meter interface doc on tasmota (linked above).

what do you see when you log into the web interface of the tasmota? does it show the meter values? is the script enabled? can you see messages in the console?

If you load up node red can you see the messages coming in? add a mqtt in node to a message node… this will show all mqtt messages… you may need to add a filter depending on how many mqtt things you have.

as for the script you could clean it up to just one meter

>D
>B
->sensor53 r
;disable publishing at MQTT teleperiod, on boot
smlj=0
>S
;re-enable publishing at MQTT teleperiod, after 10 seconds of uptime
if upsecs>20
then
smlj=1
endif
;recalc descriptor math
smld(2)
>M 1
+1,5,c,1,-10,GAS
1,1-0:1.8.0*255(@100,Gas,m3,Count,3
#

now days I would probably go the esphome route… but because this one is all setup and working so well i’m really hesitant to change anything

Thank you so much Chris,
I’ve spent hours at work this morning trying to find how to easily set up esphome for the sensor.
Reflashed the D1Mini, learnt to use gitpod, screen grabbed my settings for you, read through your message a few more times, and noticed the critical line “Is the script enabled?” :open_mouth:
Going back into tasmota to find the small check box I had never noticed or used before. “Script enable”
I now have a reading to play with when I get home from work tomorrow.
Any idea how to set the base value to the actual meter reading?
Much appreciated
Brett

i couldnt figure out how to set the base reading… but i also dont need it, its more interesting looking at it day by day… telling the wife off when she has a 30min shower haha. i did track for a while to make sure i had the calibration set correctly

the other meter reader i have is jomjol ai on the edge, thats pretty easy to set a base value and does a good job of monitoring the water and i also save the screenshots so i can troubleshoot later.

I’ve tried to do this a few times with various reed switches, however none of them seemed to work. I watched the meter, and it looks like the magnet is missing on the last dial. Is anyone able to take a photo / video of the meter to see where the magnet should be?

Thanks,
Stuart

Not sure if it the magnet or not but in this photo of my meter you can see a metal line between the 9 and the zero that is not present between other digits.

I’ve also used the metal detector lite app (on iPhone). It seems to respond to a higher degree at the point where the magnet would be than it would for other ferrous metals, but it is a bit hit and miss.

1 Like

@chris.huitema Any chance you could share more details on your water meter solution at the old house?
I have an identical meter and keen to use a reed switch for measuring usage, but no idea where to get a one that fits…

I just used a miniature glass reed switch, available at most electronics stores. one of the leads I carefully bent 180 degrees using a small pair of needle nose pliers so it didn’t crack the glass, then soldered some cable to it, then I put some heat shrink over the tube to protect it. It wasn’t anything too fancy!

As for the electronics I was using a Bluz to count the pulse and send the count to the particle cloud. I haven’t been keeping an eye on particle lately, Home assistant has taken up most of my spare time lately

Im sure a ESP connecting to home assistant would work well, but you will probably want to look at some power saving options if its going to be battery powered.

https://www.jaycar.com.au/miniature-glass-reed-switch/p/SM1002

2 Likes

Hi,
Anyone use this one?

D105 G2 User Manual1rqilp7_gaMTQwMzE5NzEyOS4xNjc3NDM2ODg1_ga_9MTRSJQGXV*MTY3NzQ1MTQ1Mi4yLjAuMTY3NzQ1MTQ1Mi42MC4wLjA

Hi,
I use an esp8266 to count the pulses of my gas meter. Then it gets transferred over mqtt to my influxdb database. In homeassistant the mqtt part is used to create a sensor.
My problem is, that my data is not a total value, but only the pulses every 15mins.
I cant use total_increasing, can I ? Also reconfiguring all the devices to total count would be a problem, because I already have 3 years of data (pulses/15mins).
I use grafana to display the data, but would also like to insert the data into the energy section of home assistant. Is there any way to integrate pulses/15mins data ? Or will i have to add the values and use a total variable ?

I tried :
template:

  • sensor:
    • name: “Gas Meter”
      device_class: gas
      state: “{{ states (‘sensor.gz’) | float }}”
      unit_of_measurement: “kWh”
      icon: "mdi:gas

mqtt:
sensor:
- state_topic: “GZ/Differenz”
name: “GZ”
value_template: “{{ value | float * 1.14 }}”
unit_of_measurement: ‘kWh’
device_class: gas

The energy board says sensor unavailable.

anyone happen to get this working on a pico w through esp home? hoping I could steal your code if you have!!

I have the gas meter read part working ok, but still trying to get flow rate working properly.

This is my esphome yaml code. It works well. You also set the updated value of the gas sensor entity through states under Developer. This is needed now and again if you miss some pulses due to power being off or other reason

esphome:
  name: gas-usage
  friendly_name: gas-usage
  min_version: 2024.6.0
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:

api:
  encryption:
    key: "your key"
  services:
    - service: update_counter_pulses
      variables:
        counter_pulses: int
      then:
        - globals.set:
            id: pulses_sum
            value: !lambda 'return counter_pulses;'


ota:
  - platform: esphome
    password: "your password"

wifi:
  networks:
    - ssid: Your SSID
      password: Your Password
      priority: 1

  ap:
    ssid: "Gas-Usage Fallback Hotspot"
    password: "whatever is yours"

captive_portal:



globals:
  - id: pulses_sum
    type: int
    restore_value: yes
    initial_value: '1460546'  # here we can intialize the value to the value we have read from the gas meter.

binary_sensor:
  - platform: gpio
    id: internal_pulse_counter
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: true
    name: "Live-Impuls"
    filters:
      - delayed_on: 10ms
    on_press:
      then:
        - lambda: id(pulses_sum) += 1;

sensor:
  - platform: template
    name: "Gas meter"
    device_class: gas
    unit_of_measurement: "m³"
    state_class: "total_increasing"
    icon: "mdi:fire"
    accuracy_decimals: 2
    lambda: |-
      return id(pulses_sum) * 0.01;
    update_interval: 1s

Received a $950 gas bill for 2 months.
Help help!
I want to start monitoring my gas usage. Is there anything easy to install for Melbourne? I’m with origin. Thank you.

Well. Depends on your definition of ‘easy’. :wink:

I am also in Melbourne, and have just managed to do it. I needed to get a QMC5883L/HMC5883L magnetometer sensor off Aliexpress plus an esp8266, and via esphome can now track the number of times the diaphragm inside the meter goes in/out and with that calculate the amount of gas being used.

So in short - assuming your meter is similar to mine - it needs a sensor, an esp8286/esp32, esphome, probably a weatherproof box and irrigation cable assuming the meter is outside, and some spare time to futz around comparing actual usage with what the sensor is tracking to calibrate the readings. If you are interested in the end2end process of doing that, then I’m happy to put together a more detailed run through of it. Cheers.

@d_tech , can I please check with you how this piece of code to update the value of the gas sensor is meant to work.

  encryption:
    key: "your key"
  services:
    - service: update_counter_pulses
      variables:
        counter_pulses: int
      then:
        - globals.set:
            id: pulses_sum
            value: !lambda 'return counter_pulses;'

The definition of the service/action: update_counter_pulses, creates a NEW action called “update_counter_pulses”. If I now went to Developer Tools → Actions, I should be able to call up “update_counter_pulses” as an action, enter a new meter value, which then updates the pulses_sum entity with the new meter value.

I had a look at the ESPHome doco which has similar code for the action, but with a different action name.

This made me think that whatever name you define against services/action, is how you call this action in developer tools.

Is this understanding correct? Thanks very much for your help!

thanks, there is no way i can pull this off, need a finished device. thank you though