Coder Social home page Coder Social logo

watermeter's Introduction

Read a water meter and returns value

Reads analog water meters and provides a web service that returns the read value as decimal. The needles of the analog gauges currently have to be red.

Turns Watermeter into 820.5745 so it can become Grafana Screenshot.

CI Docker Hub Pulls

Getting Started

This is only a quick introduction to setting up and configuring watermeter. A more extensive documentation can be found in the howto.

Installation

Using Docker Compose (recommended)

version: "3.5"
services:
  watermeter:
    image: nohn/watermeter:latest
    container_name: watermeter
    volumes:
      - ./watermeter/config:/usr/src/watermeter/src/config
    restart: always
    ports:
      - "3000:3000"

Configuration

You can access the configuration tool http://watermeter:3000/configure.php. The interface should be self explanatory. Source Image can be either in local filesystem or any HTTP(S) resource.

Configuration GUI Screenshot

After configuration is done, you can access the current value at

http://watermeter:3000/

or

http://watermeter:3000/?json

or see debug information at

http://watermeter:3000/?debug

How to contribute

You can contribute to this project by:

  • Opening an Issue if you found a bug or wish to propose a new feature
  • Placing a Pull Request with bugfixes, new features etc.

You like this?

Consider a gift.

License

analogmeterreader is released under the GNU Affero General Public License.

watermeter's People

Contributors

nohn avatar dependabot[bot] avatar

Stargazers

 avatar Michael Bykovski avatar 王滋阳 avatar  avatar  avatar Matt Peterson avatar  avatar  avatar Zachary Hazell avatar  avatar  avatar  avatar Manfred Linzner-Scherf avatar Richard Wu avatar Sergio E avatar Paolo Gabrielli avatar Jérémie Zarca avatar GSchenck avatar Mariete avatar  avatar  avatar Dennis Rohlfing avatar  avatar Lukasz Liniewicz avatar  avatar Ionut Zaharia avatar Lennart avatar Benjamin Wade avatar  avatar Tom vd Werf avatar Paweł Słowik avatar Saud bin Mohammed avatar  avatar yinglively avatar  avatar Said BENLYAZID avatar  avatar aleixcox avatar Sergey avatar  avatar Greg Miller avatar Diver86er avatar Dark1106 avatar  avatar  avatar  avatar Petr Zahradník avatar Dmitry Kaukov avatar Simon "epo" Müller avatar Silver avatar Mina Nabil Sami avatar dscao avatar  avatar  avatar Peter Heilbo Ratgen avatar Arto Tuomi avatar  avatar Juha Lehtiranta avatar SBN avatar Green Dragon's Pixel avatar Peter avatar  avatar Jani Luoti avatar Scampi_ml avatar Jean-Marc Ulrich avatar Johan Åberg avatar  avatar  avatar Niccolò Quadrelli avatar  avatar Pyry-Samuli Lahti avatar Robert Nyholm avatar Erik OShaughnessy avatar Stephan avatar  avatar Dominik Ritter avatar Juho Vepsäläinen avatar Vincent Mazoyer avatar Filipe Gonsalves avatar Vasylkov Gennadiy avatar Thies Gerken avatar RLe avatar  avatar  avatar Alaattin Gökmen  avatar  avatar  avatar Vitor Fonseca avatar jonsmith1982 avatar  avatar Patryk avatar  avatar felix schwenzel avatar Ionut Scutaru avatar nanosonde avatar  avatar Stephan Telahr avatar Walid Shouman avatar  avatar  avatar

Watchers

 avatar James Cloos avatar Jani Luoti avatar felix schwenzel avatar dscao avatar  avatar  avatar  avatar

watermeter's Issues

Support for offsets

It should be possible to define offsets (positive and negative):

  • From time to time, water meters have to be changed as they tend to decalibrate (in Germany by law all 6 years).
  • People may want to start with 0 when they move into a new flat or may want to continue with their "liftime" value

Image cropping not taking into account start X/Y

Hi Sebastian,

with the version I loaded 26th and 27th Dec the cropping starting positions for X and Y are not taken into account (tested on Opera-browser). In the example below positions should start at (515,280) but seems they remain at (0,0).

Sample of input, output and config.php enclosed

image
config.php.txt
meters_20221227-130000

Thanks,
Hans

Warning: exec(): Unable to fork ["tesseract" --version 2>&1]

Describe the bug
I have downloaded and started the Docker image following the instructions the the best of my ability. When I open the application for the first time, I get the error messages below.

To Reproduce
Use the browser to open IP:3001

Expected behavior
Get the start page.

Screenshots
image

Additional context
I am running Docker on a machine with Ubuntu. I have the latest version of Tesseract in the repo (version 4.1.1). The only change I did that I am aware of, is changing the external port from 3000 to 3001 because I have used 3000 for something else.

Any help is appreciated. Thanks!

Warning: exec(): Unable to fork ["tesseract" --version 2>&1] in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 62

Warning: Undefined array key 0 in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 63

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 63

Warning: Undefined array key 1 in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 64

Warning: Trying to access array offset on value of type null in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php on line 87

Deprecated: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php on line 90

Warning: exec(): Unable to fork ["tesseract" --version 2>&1] in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 62

Warning: Undefined array key 0 in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 63

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 63

Warning: Undefined array key 1 in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/Command.php on line 64

'Add a digit' results in error

Hi!

In the configure user interface, when I press 'Add a Digit' or 'Add a Gauge', I get the error message:
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /usr/src/watermeter/src/configure.php:111 Stack trace: #0 {main} thrown in /usr/src/watermeter/src/configure.php on line 111

See attached images.

Pressing 'back' in the browser and then 'preview', 'save' takes me out of the error state but I cannot add Digits och Gauges which is rather limiting.

A workaround for me is to update config.php manually with more Digits.

bild
bild

Fatal error: Uncaught DivisionByZeroError

Get this error ...

Raw OCR:
Clean OCR: Digital Preview
Choosing last value 0
Digital: 0

Fatal error: Uncaught DivisionByZeroError: Division by zero in /usr/src/watermeter/vendor/nohn/analogmeterreader/src/AnalogMeter.php:173 Stack trace: #0 /usr/src/watermeter/vendor/nohn/analogmeterreader/src/AnalogMeter.php(69): nohn\AnalogMeterReader\AnalogMeter->processImage(false) #1 /usr/src/watermeter/classes/Reader.php(131): nohn\AnalogMeterReader\AnalogMeter->getValue() #2 /usr/src/watermeter/classes/Reader.php(46): nohn\Watermeter\Reader->readGauges() #3 /usr/src/watermeter/public/configure.php(202): nohn\Watermeter\Reader->getReadout() #4 {main} thrown in /usr/src/watermeter/vendor/nohn/analogmeterreader/src/AnalogMeter.php on line 173

Decimal numbers errors

I recently started using this on my watermeter, but there are a few minor issues with the decimal numbers.
Below is a pre-processed image from my camera (inverted half of the picture).
screen
Playing with the settings i get the following result:
settings
This momentarily does not present any errors. The errors occur with the decimal numbers when the first decimal is 0, for example the meter reads 611,0320. OCR will give the following number: 611,32. It deletes the leading and trailing zero's from the decimals.
This will cause an error because the delta is too big.
The script should not remove leading zero's (trailing zero's in the decimal is not a big problem).

Secondly when the OCR fails on the decimals it will revert to the last known value, which the script will take 611, so the result is 611,611.
Perhaps the decimals should be stored as a different last known value?

url to toggle led before getting snapshot

Thanks a lot for making this. Works really well.
I'm using a ESP32-CAM to take the snapshot and I would like to use the device builtin LED to toggle the "flash". Easiest way to do this is by URL, http://deviceIP/cm?&cmnd=Power%20Toggle, so I'm asking if its possible to add this in the configuration? Like a precondition URL that is loaded before and after the snapshot?

Thanks
/Johan

RAM usage is extreme during configuration processes and being not released

Until till now I used the v1.2.22 release, all was fine.
Few days ago I switched to 1.3.0.

My setup runs on the Synology DS220+.
OS: DSM 7.2.1-69057 Update 4
I use Container Manager (see screenshot for detailed version).

Instantly after starting setting the new release from zero I noticed that the webpage "http://watermeter:3000/configure.php.", after pushing "preview" button, loads very slow, like never before.
This brought me to check the RAM consumption.
So each time I push the preview button the RAM usage grows extremely.
What is also weird to me, the usage does not get released, it stays continuously on the high level.
I must stop and start again the watermeter container to get the RAM released.

I am not very aware about such topics, so maybe this is a normal behaviour?

Here screenshots:
image

image

image

image

After restarting the watermeter container:
image

Analog Only Gas Meter

I have a gas meter that has 4 analog gauges on it (no digital digits). I am trying out the nohn/watermeter to see if I can get it to work for my gasmeter. My first attempt didn't work so well, so looking for some help.

Since the watermeter expects at least one digital digit, I found a "0" that is printed on the gasmeter itself that I used to mimic a digital digit. Otherwise I have setup 4 analog gauges. The actual meter I am testing is not the real one, it is a used one I purchased separately so that I could play with it as part of my test setup (for example, I can turn a knob in the back of the meter to change the gauge dials). It came with all the analog gauges set to 0 and that's what I started my testing with. I set the initial value to 0. Attached is a partial snapshot of the debug output, and none of the gauges were interpreted correctly (however the "0" digital digit seems be recognized properly).
MeterDebug

hasErrors: 1
array(7) {
  [76]=>
  string(46) "Could not interpret . Using last known value 0"
  [149]=>
  bool(true)
  [150]=>
  bool(true)
  [151]=>
  array(1) {
    [0]=>
    bool(true)
  }
  [152]=>
  array(1) {
    [0]=>
    string(6) "0.5839"
  }
  [153]=>
  array(1) {
    [0]=>
    string(4) "0000"
  }
  [154]=>
  array(1) {
    [0]=>
    float(0.5839)
  }
}
lastValue: 0000
value: 0.5839
0000

There are some other quirks with this meter, as some of the gauges are the usual 0 to 9 clockwise, but others are 9 to 0 clockwise.
Looking for some ideas, but for starters, looking for advice on how to get the 0 to 9 clockwise gauges to be recognized properly. BTW, thanks for your work on this :)

Feature request: validate detected digits

Since the rightmost digital value consists of a rotating cylinder it's value is not always centered in the OCR detection rectangle.

It would be great if watermeter could identify that the number of OCR rectangles does not correspond to the number of OCR detected digits and in that case not update the Home Assistant sensor.

Basically, if the detection of one digit is unsuccessful, the number is not reported to the sensor.

bild

Tesseract fatal error: The command did not produce any output

After installation the configure.php loads correctly, showing the demo image and the OCR interpreted digits. If I change the source image to my own image, I get the following error and the image is not displayed.

Fatal error: Uncaught thiagoalessio\TesseractOCR\UnsuccessfulCommandException: Error! The command did not produce any output. Generated command: "tesseract" - "/tmp/ocrfj40Dw" -c "tessedit_char_whitelist=0123456789" Returned message: in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php:66 Stack trace: #0 /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/TesseractOCR.php(39): thiagoalessio\TesseractOCR\FriendlyErrors::checkCommandExecution(Object(thiagoalessio\TesseractOCR\Command), '', '') #1 /usr/src/watermeter/classes/Reader.php(114): thiagoalessio\TesseractOCR\TesseractOCR->run() #2 /usr/src/watermeter/classes/Reader.php(50): nohn\Watermeter\Reader->readDigits() #3 /usr/src/watermeter/public/configure.php(240): nohn\Watermeter\Reader->getReadout() #4 {main} thrown in /usr/src/watermeter/vendor/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php on line 66

To my understanding this due to the OCR not being able to recognize any characters in the image. But without the picture being shown, rotating and positioning the digits/gauges is not possible. At least earlier (my previous installation was about a year ago), the picture was displayed, even if the OCR was not able to recognize characters, so that the settings could be adjusted until the characters were recognized. Same error occurs also if the the demo image is kept as a source, and the source image rotation is changed (for example -3 to 0), so this would suggest it is not related to the picture it self.

(Installation is still using the default config.php.)
watermeter

Value from water-meter to Home Assistant

Introduction of my topic - I installed water-metter to ESP-CAM (works OK). I checked MQTT setting and filled full IP address of broker (mqtt://192.....:1883). I opened Home Assistant (runs on Raspberry Pi 4, Zigbee USB module) and I tried to add integration of MQTT - but when I added IP address of broker of water-meter, the Home Assistant didn't find it.

Question: what have I to do for transfer of value from water-mteer to Home Assistant using MQTT? I'm little bit lost n MQTT area.

Thank you

Add support for ARM32/ARM64

Hi I have been trying to get this working for a while on my Raspberry Pi 4 but keep getting this error.

standard_init_linux.go:228: exec user process caused: exec format error

Does watermeter support arm 32bit or 64 bit? I have tried both

Add possibility to execute command before and after fetching image

I am about to test this project next week, by using a ESP-CAM and ESPHome. But I am at the moment struggling with a nice way to turn the camera light on and off. ESPHome doesn't seem to have support for automation on accessing the camera.

So one way to solve this would be if I could curl before and after the picture is taken.

Fatal error: Uncaught DivisionByZeroError

Got this Error.
Reads 4 Pre Decimal Digital Digits just fine! :)
Guess it has something to do with analog digits, cant remove "remove gauge" ( pops back when deleting in the web-gui )!?

Raw OCR: 1835
Clean OCR: 1835
Digital: 1835

Fatal error: Uncaught DivisionByZeroError: Division by zero in /usr/src/watermeter/vendor/nohn/analogmeterreader/src/AnalogMeter.php:173 Stack trace: #0 /usr/src/watermeter/vendor/nohn/analogmeterreader/src/AnalogMeter.php(69): nohn\AnalogMeterReader\AnalogMeter->processImage(false) #1 /usr/src/watermeter/classes/Reader.php(149): nohn\AnalogMeterReader\AnalogMeter->getValue() #2 /usr/src/watermeter/classes/Reader.php(49): nohn\Watermeter\Reader->readGauges() #3 /usr/src/watermeter/public/configure.php(227): nohn\Watermeter\Reader->getReadout() #4 {main} thrown in /usr/src/watermeter/vendor/nohn/analogmeterreader/src/AnalogMeter.php on line 173

Include option that allows decreasing values for usage with solar panels

I have watermeter running to capture my electricity usage.
When my solar panels are generating power my electricity meters count backward, however watermeter does not take into account these (reduced) updated values (as they are lower than the last value and throw an error).

Requesting an option is added that would allow for decreasing values (within boundaries of max. threshold). So rather than checking "is new value larger than old value with threshold" it would be "is new value larger or smaller than old value with threshold.
This option should be configurable with the normal interface (config.php)

image_2023-01-07_125505182

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.