It turned out this works better as an add-on to mqtt so I can have better control and resources to parse digits. Please refer to https://github.com/junalmeida/homeassistant-addons
This repository is archived.
This is a custom component to allow parse of dial and digits utility meters like water, gas, and electricity to provide energy consumption information to home assistant using a regular ip camera.
This repository is under alpha stage, so expect bugs and breaking changes.
- Parse Meters
- Provide a consumption sensor of
total_increasing
state type. - Cheap IP or PoE cameras must do
- Positioning a camera and getting a good image could be difficult.
- Could be hard to setup calibration parameters, such as
zoom_factor
. - To recognize digits, I am relying on OCR services on the internet. I am open to suggestions on better local libraries to scan digits. Recognizing dials is simple and local, no internet connection or APIs are required.
- Have HACS installed, this will allow you to easily update
- Add https://github.com/junalmeida/ha-meterparser as a custom repository as Type: Integration
- Click install under "Meter Parser Integration" in the Integration tab
- Add your meter to your
configuration.yaml
file as shown below - Restart HA
- Entities will show up as
sensor.<friendly name>
, for example (sensor.water_meter
). - Setup you camera and sensor in
configuration.yaml
# Example configuration.yaml entry
sensor:
- platform: meter_parser
scan_interval: 60 # in seconds, higher intervals is better to avoid rate limits
source:
- name: Water Meter
entity_id: camera.water_meter # any camera entity
meter_type: digits # digits or dials, at this moment, digits uses internet to ocr.
ocr_space_key: "123456789" # required for digits, grab a key at https://ocr.space/ (watch for rate limits)
digits: 6 # required for digits, number of expected total digits (including decimals)
decimals: 1 # optional number of decimals
debug: True # when true it stores an image with scanned dials
device_class: water # energy, gas or water
unit_of_measurement: m³ # m³, ft³, kWh, MWh, Wh, gal, L
- platform: meter_parser
scan_interval: 15
source:
- name: Electricity Meter
entity_id: camera.electricity_meter
meter_type: dials # read out dial pointers, internet is not used.
dials: ["CCW","CW", "CCW", "CW"] # readout convention (counter clockwise, clockwise)
dial_size: 280 # minimum expected dial diameter in pixels, this could be hard to figure out, so position your camera, and access with VLC to check the diameter of each dial, then set a minimum with an error margin.
debug: True # when true it stores an image with scanned dials
device_class: energy # energy, gas or water
unit_of_measurement: kWh # m³, ft³, kWh, MWh, Wh, gal, L
- Setup your logger to print debug messages for this component by adding this to your
configuration.yaml
:logger: default: warning logs: custom_components.meter_parser: debug meter_parser: debug
- Restart HA
- Verify you're still having the issue
- File an issue in this Github Repository, add logs and if possible an image of your meter.
🎉 Dial Parser code is based on the awesome work of @mirogta, please support his work.
Footnotes
-
Icons made by Smashicons from flaticon.com ↩