Good to see some other Aussies and especially Perth people on these forums! hope you are enjoying the rain
I have the same gas meter at my house, I tried the reed switch a while ago but found it somewhat unreliable, not wanting to hijack your thread but thought you may find some of this helpful
due to miss reads with the reed switch I ended up changing to a hall sensor. I had issues with pulses being missed and a couple of times the wheel stopping right on the edge and causing many reads throughout the day even though no gas was used. this is the one I used https://www.jaycar.com.au/arduino-compatible-hall-effect-sensor-module/p/XC4434
Instead of a battery powered unit I’m using an esp8266 from jaycar and just powering it from a usb adaptor. WiFi Mini ESP8266 Main Board | Jaycar Electronics
as my power meter is directly above the gas meter I also have a photodiode to count the flashes Infrared Phototransistor | Jaycar Electronics the only other item needed was a 10k resistor for the photo transistor.
I ended up an old USB cable to remote mount the sensors, both are about a meter from the ESP and seem very reliable. both the photo transistor and the hall sensor are held in place using blutac
for the gas meter - the hall sensor is connected to 5v, GND and GPIO5/D1
the photo transistor is connected to 3v3 and the other terminal to GPIO4/D2
the 10k resistor between GPIO4/D2 and GND
the ESP is flashed with a custom build of Tasmota with Smart Meter Interface - Tasmota
the script to load into tasmota
>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 2
+1,5,c,1,-10,GAS
+2,4,c,1,-10,Power
1,1-0:1.8.0*255(@100,Gas,m3,Count,3
2,1-0:1.8.0*255(@1000,Power,kWh,Count,3
2,=d 2 10 @1,Current Power,W,Power,0
#
this basically gives 3 readings to home assistant, im not even sure how the values are pulled in… its just magic! gas count, power count, instantaneous power
i then use these into utility meters to be able to graph etc
utility_meter:
quatrerhour_electricity:
source: sensor.utility_meter_power_count
cycle: quarter-hourly
tariffs:
- peak
daily_electricity:
source: sensor.utility_meter_power_count
cycle: daily
tariffs:
- peak
monthly_electricity:
source: sensor.utility_meter_power_count
tariffs:
- peak
quaterhour_gas:
source: sensor.utility_meter_gas_count
cycle: quarter-hourly
tariffs:
- peak
daily_gas:
source: sensor.utility_meter_gas_count
cycle: daily
tariffs:
- peak
monthly_gas:
source: sensor.utility_meter_gas_count
tariffs:
- peak
here are some templates I use that you may also find useful, values should be spot on for Perth’s only power provider, for others the 0.266612 is the unit cost for power, and the 0.955818 is the daily supply charge.
template:
- sensor:
- name: Today Energy Total Cost
device_class: monetary
state_class: measurement
unit_of_measurement: AUD
state: >
{{ (states('sensor.daily_electricity_peak') | float * 0.266612 + 0.955818) | round(2) }}
- sensor:
- name: Yesterday Energy Total Cost
device_class: monetary
unit_of_measurement: AUD
state: >
{{ (state_attr('sensor.daily_electricity_peak','last_period') | float * 0.266612 + 0.955818) | round(2) }}
- sensor:
- name: Next Bill Estimate
device_class: monetary
state_class: measurement
unit_of_measurement: AUD
state: >
{{ (states('sensor.monthly_electricity_peak') | float * 0.266612 + (0.955818 * ((now() | as_timestamp | int - state_attr('sensor.monthly_electricity_peak','last_reset') | as_timestamp | int) / 86400 ) | int )) | round(2) }}
I use an input helper to adjust my billing cycle. its almost automatic with this automation and I just correct it manually if it starts getting out of sync with my bills
alias: Power Bill Reset
description: ''
trigger:
- platform: time
at: input_datetime.power_bill_reset
condition: []
action:
- service: utility_meter.reset
target:
entity_id: utility_meter.monthly_electricity
data: {}
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.power_bill_reset
data:
datetime: >-
{{ (state_attr('input_datetime.power_bill_reset', 'timestamp') + (61 *
24 * 60 * 60) ) | timestamp_custom ('%Y-%m-%d %H:%M:%S') }}
mode: single