Hi,
just starting from a own (scripts based) solution to openHAB.
At first I add weather and a door contact in myopenHAB “house”.
In my house I allready have installed a electrical consumption counter which send 2000 signals per kWh and a water counter with 20 signales per liter. They are connected to two GPIO ports from my Raspberry 3+.
With my old script solution on Linux I “stop” the time betwen electrical signals to measure actuall electrical consumption, and for total consumption I count the signals for electricity and water.
Maybe there is a binding or action I can use for these consumption counters I have, but I had not found them for openHAB. Maybe I search wrong or in wrong places or with wrong keywords.
Can you give me hint how to add these in openHAB (with actuall consumption, total daily consumption, total weekly consumption) ?
Yes, counting-parts was in Python.
(the (big) main part (calculate graphs, create html, …) was in Shell-Script, only the counting part from these two counters was in Python!)
But I’m not a Python programer, I get the “code” to run but understand the code not completely
Was with using interupts to see the short signal correct (before I try with a simple loop)
…
GPIO.add_event_detect(9, GPIO.FALLING, callback=my_callback, bouncetime=300)
…
OK, if you think so …
I thought, maybe there is a “correct” and standart way to use these counters into openHAB …
What do you mean with “REST api” ?
Actuall my Python script starts a shell script which uses the measues the Python (including using interrupts) has measured and calculated, see:
…
subprocess.call("/var/log/wbin/menergy.sh %.3f %.3f %.3f %.3f %1.0f" % (KwhAct, KwhMinAvg, KwhActPrev, KwhMinAvgPrev, NewMinute), shell=True)
Where or how should the data send to openHAB?
Or can I write these data into a file and openHAB is montioring this file if it changed?
The menergy.sh script is “big” and use the transmitted values (parameters) ("…%.3f %.3f %.3f %.3f %1.0f").
At the end the menergy.sh -script is creating (simple) html-out which can be displayed on a tablet.
You mean, to create shell script which repond these values in a line if it is called?
" { KwhAct: 251.25, KwhMinAvg: 1245.12, KwhActPrev: 32154.21, KwhMinAvgPrev: 987987.12, … }"
Shure, this is not my favourite way, but if openHAB have no bether direct “way”, Ok …
Because I thought (or bether: a dream) to say:
“openHAB; look on GPIO 23, there is the electrical consumption, 2000 signals = 1kwH. Please check GPIO freqently and use the data and provide these data …” But if I understand correctly, this is not so “easy”, correct?
You can but if you have something that works already, use it. No need to re-invent the wheel.
And not it’s won’t be so easy. I don’t know if GPIO binding will accept so may updates so quickly and then you’ll need counters…
It can have 2 signals per second, but normally only every 10s one signal.
Is 2i/sec to much?
So I need a separate script to measure (count) it and give the info periodically to openHAB. Correct?
Than, what will bet correct or better:
Only count (stupid) and provide the signals count and openHAB will calculate the actual amount (Kwh) (based on time range between the two values openHAB knows (i.E. 15s):
Previous value: 145256
Actual value: 145279
Difference: 23 signals in 15 seconds => 2.434kwh
Or should the script deliver a by script calculated actual consumption (2.434 Kwh for last 15s)) and and total count (145279).
However, the old scripts must be totally new written, also they have only few lines, n.p. !
No, sorry. the Raspi with this solution is broken, I only have some scripts saved …
But if needed I can write the values in a file (instead in html-file), thats not a problem. When this is a “good” solution, OK.
So if I understand correct, the best will be if openHAB simple get all wanted data by a foreign script.
But what about the consumption from one day? Actuall I have this not running.
For this case, it it possible to “deliver” openHAB every 24 hours (at 3 in the morning i.e.) the actuall count, and openHAB will calculate the consumption for last day (based on the difference from 24hours before)?
Or should/must be this also calculated “extern” and delivered into openHAB?