OEG zonneboiler monitoren met Domoticz

Setup

Mijn huidige zonneboiler systeem heeft 4 zonnecollectoren, een set van 2 gekoppelde collectoren op het westen en een set van 2 gekoppelde collectoren op het oosten.
Een door relais R3 op de OEG-KS2W  solar controller aangestuurde 3-weg klep schakelt het solarvloeistofcircuit tussen het solarpompstation en de oost- en west collectorsets, al naar gelang welke op dat moment het heetst is.
In beide sets collectoren bevindt zich een temperatuursensor, gekoppeld aan resp. aansluiting T1 en T3 van de solar controller. 
Een 3e temperatuursensor bevindt zich onderin het boilervat en is gekoppeld aan aansluiting T2 van de solar controller. 
De solarpomp die de solarvloistof van de geselecteerde collector naar de warmtewisselaatr in het boilervat stuurt wordt aangestuurd door relais R3 van de solar controller. 

Doel

Voornaamste doel is om de temperaturen van de collectoren én het boilervat te meten, te registreren en te loggen in mijn Domoticz monitoring / home automation systeem
Verder leek het me leuk om ook de pompsnelheid en de actieve collector set te kunnen zien. 
OEG verkoopt zelf ook software om de KS2W en KMSD controllers mee uit te lezen (en te programmeren). maar dit draait op Windows. Ik heb geen zin om voor het monitoren dag en nacht een Windows computer te laten draaien.
Aangezien ik nog wel een energiezuinige Raspberry Pi over had, heb ik gezocht naar een oplossing dat daarop werkt.

Geraadpleegde bronnen

Benodigdheden

  • Een zonneboilerset met een OEG-KMSD compatible zonneboiler controller.
  • Een werkend Domoticz monitoring / home automation systeem, onder Linux, bijvoorbeeld op een Raspberry Pi (RPI).
  • 3 virtuele sensors in Domoticz t.b.v. de weergave van de temperatuur collectoren en boiler, type Temp, subtype LaCrosse TX3
  • 1 virtuele sensor in Domoticz t.b.v. de weergave van de pompsnelheid, type General, subtype LaCrosse TX3
  • 1 virtuele sensor in Domoticz t.b.v. de weergave van de actieve collectorset, Type Light/Switch, subtype Switch (niet van toepassing als je geen switchover hebt)
  • Een 2e RPI om de controller mee te “scannen”. Dit kan ook dezelfde RPI zijn als die waar Domoticz op draait, wanneer deze in de buurt van de OEG controller is te plaatsen.
  • Een “gewone” USB kabel USB A naar mini-USB, tussen de OEG controller en de (scanning) RPI.
  • LAN of Wifi verbindingen met je thuis netwerk op de monitoring RPI en op de RPI met Domoticz (als dit niet dezelfde RPI is)
  • Python3-pip en de modules pyserial en minimalmodbus plus alle dependencies op de scanning RPI
    in mijn geval stond er aanvankelijk zelfs nog helemaal geen Python3 op, maar die werd dus automatisch meegeïnstaleerd bij het installeren van pip 
  • een python script dat de OEG controler gaat uitlezen en de waardes in Domoticz zet.

installatie procedure

installatie pip, pyserial, minimalmodbus (en dependencies) op debian 11 buster:

pi@pgit-rpi02:~ $ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
javascript-common libexpat1-dev libjs-jquery libjs-sphinxdoc libjs-underscore libpython3-dev libpython3.9-dev python-pip-whl python3-dev
python3-distutils python3-lib2to3 python3-setuptools python3-wheel python3.9-dev
Suggested packages:
apache2 | lighttpd | httpd python-setuptools-doc
The following NEW packages will be installed:
javascript-common libexpat1-dev libjs-jquery libjs-sphinxdoc libjs-underscore libpython3-dev libpython3.9-dev python-pip-whl python3-dev
python3-distutils python3-lib2to3 python3-pip python3-setuptools python3-wheel python3.9-dev
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/7,224 kB of archives.
After this operation, 23.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
pi@pgit-rpi02:~ $ sudo pip3 install pyserial
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyserial
Downloading https://www.piwheels.org/simple/pyserial/pyserial-3.5-py2.py3-none-any.whl (90 kB)
|████████████████████████████████| 90 kB 12 kB/s
Installing collected packages: pyserial
Successfully installed pyserial-3.5

root@pgit-rpi02:/home/pi/scripts# sudo pip3 install minimalmodbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting minimalmodbus
Downloading https://www.piwheels.org/simple/minimalmodbus/minimalmodbus-2.1.1-py3-none-any.whl (32 kB)
Requirement already satisfied: pyserial>=3.0 in /usr/local/lib/python3.9/dist-packages (from minimalmodbus) (3.5)
Installing collected packages: minimalmodbus
Successfully installed minimalmodbus-2.1.1

installatie pipx, pyserial, minimalmodbus (en dependencies) op debian 12 bookworm:

pi@oegmon:~ $ sudo apt install pipx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
blt fonts-font-awesome fonts-lato ghp-import libblas3 libgfortran5 libjs-bootstrap4 libjs-highlight.js libjs-lunr
libjs-modernizr libjs-popper.js libjs-sizzle liblapack3 libtcl8.6 libtk8.6 libxft2 libxrender1 libxss1 mkdocs node-jquery
python-babel-localedata python3-argcomplete python3-attr python3-babel python3-click python3-colorama python3-dateutil
python3-iniconfig python3-jinja2 python3-joblib python3-livereload python3-lunr python3-markdown python3-markupsafe
python3-mergedeep python3-more-itertools python3-nltk python3-numpy python3-packaging python3-pluggy python3-psutil
python3-py python3-pygments python3-pyinotify python3-pytest python3-pyyaml-env-tag python3-regex python3-simplejson
python3-tk python3-tornado python3-tqdm python3-tz python3-userpath python3-watchdog python3-yaml sphinx-rtd-theme-common
tk8.6-blt2.5 x11-common
Suggested packages:
blt-demo libjs-es5-shim tcl8.6 tk8.6 mkdocs-doc nodejs python-attr-doc python-jinja2-doc coffeescript node-less
node-uglify python-livereload-doc python3-django python3-flask python3-slimmer python-lunr-doc python-markdown-doc
gfortran python-psutil-doc subversion python-pygments-doc ttf-bitstream-vera python-pyinotify-doc tix python3-tk-dbg
python3-pycurl python-tornado-doc python3-twisted
Recommended packages:
prover9
The following NEW packages will be installed:
blt fonts-font-awesome fonts-lato ghp-import libblas3 libgfortran5 libjs-bootstrap4 libjs-highlight.js libjs-lunr
libjs-modernizr libjs-popper.js libjs-sizzle liblapack3 libtcl8.6 libtk8.6 libxft2 libxrender1 libxss1 mkdocs node-jquery
pipx python-babel-localedata python3-argcomplete python3-attr python3-babel python3-click python3-colorama
python3-dateutil python3-iniconfig python3-jinja2 python3-joblib python3-livereload python3-lunr python3-markdown
python3-markupsafe python3-mergedeep python3-more-itertools python3-nltk python3-numpy python3-packaging python3-pluggy
python3-psutil python3-py python3-pygments python3-pyinotify python3-pytest python3-pyyaml-env-tag python3-regex
python3-simplejson python3-tk python3-tornado python3-tqdm python3-tz python3-userpath python3-watchdog python3-yaml
sphinx-rtd-theme-common tk8.6-blt2.5 x11-common
0 upgraded, 59 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.7 MB of archives.
After this operation, 125 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian bookworm/main arm64 fonts-lato all 2.0-2.1 [2,696 kB]
Get:2 http://deb.debian.org/debian bookworm/main arm64 libtcl8.6 arm64 8.6.13+dfsg-2 [973 kB]
Get:3 http://deb.debian.org/debian bookworm/main arm64 libxrender1 arm64 1:0.9.10-1.1 [32.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main arm64 libxft2 arm64 2.3.6-1 [58.7 kB]
Get:5 http://deb.debian.org/debian bookworm/main arm64 x11-common all 1:7.7+23 [252 kB]
Get:6 http://deb.debian.org/debian bookworm/main arm64 libxss1 arm64 1:1.2.3-1 [17.8 kB]
Get:7 http://deb.debian.org/debian bookworm/main arm64 libtk8.6 arm64 8.6.13-2 [729 kB]
Get:8 http://deb.debian.org/debian bookworm/main arm64 tk8.6-blt2.5 arm64 2.5.3+dfsg-4.1 [540 kB]
Get:9 http://deb.debian.org/debian bookworm/main arm64 blt arm64 2.5.3+dfsg-4.1 [14.9 kB]
Get:10 http://deb.debian.org/debian bookworm/main arm64 fonts-font-awesome all 5.0.10+really4.7.0~dfsg-4.1 [517 kB]
Get:11 http://deb.debian.org/debian bookworm/main arm64 python3-dateutil all 2.8.2-2 [78.3 kB]
Get:12 http://deb.debian.org/debian bookworm/main arm64 ghp-import all 2.1.0-3 [12.3 kB]
Get:13 http://deb.debian.org/debian bookworm/main arm64 libblas3 arm64 3.11.0-2 [91.4 kB]
Get:14 http://deb.debian.org/debian bookworm/main arm64 libgfortran5 arm64 12.2.0-14 [340 kB]
Get:15 http://deb.debian.org/debian bookworm/main arm64 libjs-popper.js all 1.16.1+ds-6 [52.4 kB]
Get:16 http://deb.debian.org/debian bookworm/main arm64 libjs-bootstrap4 all 4.6.1+dfsg1-4 [517 kB]
Get:17 http://deb.debian.org/debian bookworm/main arm64 libjs-highlight.js all 9.18.5+dfsg1-2 [397 kB]
Get:18 http://deb.debian.org/debian bookworm/main arm64 libjs-lunr all 2.3.9~dfsg-2 [76.6 kB]
Get:19 http://deb.debian.org/debian bookworm/main arm64 libjs-modernizr all 2.6.2+ds1-5 [47.1 kB]
Get:20 http://deb.debian.org/debian bookworm/main arm64 libjs-sizzle all 2.3.6+ds+~2.3.3-2 [31.6 kB]
Get:21 http://deb.debian.org/debian bookworm/main arm64 liblapack3 arm64 3.11.0-2 [1,664 kB]
Get:22 http://deb.debian.org/debian bookworm/main arm64 python3-tornado arm64 6.2.0-3 [337 kB]
Get:23 http://deb.debian.org/debian bookworm/main arm64 python3-livereload all 2.6.3-2 [26.4 kB]
Get:24 http://deb.debian.org/debian bookworm/main arm64 python3-colorama all 0.4.6-2 [36.8 kB]
Get:25 http://deb.debian.org/debian bookworm/main arm64 python3-click all 8.1.3-2 [92.2 kB]
Get:26 http://deb.debian.org/debian bookworm/main arm64 python3-joblib all 1.2.0-4 [211 kB]
Get:27 http://deb.debian.org/debian bookworm/main arm64 python3-regex arm64 0.1.20221031-1+b1 [251 kB]
Get:28 http://deb.debian.org/debian bookworm/main arm64 python3-tqdm all 4.64.1-1 [97.7 kB]
Get:29 http://deb.debian.org/debian bookworm/main arm64 python3-nltk all 3.8-1 [1,004 kB]
Get:30 http://deb.debian.org/debian bookworm/main arm64 python3-lunr all 0.6.2-2 [29.1 kB]
Get:31 http://deb.debian.org/debian bookworm/main arm64 sphinx-rtd-theme-common all 1.2.0+dfsg-1 [997 kB]
Get:32 http://deb.debian.org/debian bookworm/main arm64 python3-markupsafe arm64 2.1.2-1+b1 [13.3 kB]
Get:33 http://deb.debian.org/debian bookworm/main arm64 python3-jinja2 all 3.1.2-1 [119 kB]
Get:34 http://deb.debian.org/debian bookworm/main arm64 python3-markdown all 3.4.1-2 [64.7 kB]
Get:35 http://deb.debian.org/debian bookworm/main arm64 python3-mergedeep all 1.3.4-3 [6,556 B]
Get:36 http://deb.debian.org/debian bookworm/main arm64 python3-packaging all 23.0-1 [32.5 kB]
Get:37 http://deb.debian.org/debian bookworm/main arm64 python3-yaml arm64 6.0-3+b2 [108 kB]
Get:38 http://deb.debian.org/debian bookworm/main arm64 python3-pyyaml-env-tag all 0.1-3 [5,252 B]
Get:39 http://deb.debian.org/debian bookworm/main arm64 python3-watchdog all 2.2.1-1 [124 kB]
Get:40 http://deb.debian.org/debian bookworm/main arm64 mkdocs all 1.4.2+dfsg-2 [2,252 kB]
Get:41 http://deb.debian.org/debian bookworm/main arm64 node-jquery all 3.6.1+dfsg+~3.5.14-1 [160 kB]
Get:42 http://deb.debian.org/debian bookworm/main arm64 python3-argcomplete all 2.0.0-1 [34.7 kB]
Get:43 http://deb.debian.org/debian bookworm/main arm64 python3-userpath all 1.8.0-1 [10.6 kB]
Get:44 http://deb.debian.org/debian bookworm/main arm64 pipx all 1.1.0-1 [393 kB]
Get:45 http://deb.debian.org/debian bookworm/main arm64 python-babel-localedata all 2.10.3-1 [5,615 kB]
Get:46 http://deb.debian.org/debian bookworm/main arm64 python3-attr all 22.2.0-1 [65.4 kB]
Get:47 http://deb.debian.org/debian bookworm/main arm64 python3-tz all 2022.7.1-4 [30.1 kB]
Get:48 http://deb.debian.org/debian bookworm/main arm64 python3-babel all 2.10.3-1 [103 kB]
Get:49 http://deb.debian.org/debian bookworm/main arm64 python3-iniconfig all 1.1.1-2 [6,396 B]
Get:50 http://deb.debian.org/debian bookworm/main arm64 python3-more-itertools all 8.10.0-2 [53.0 kB]
Get:51 http://deb.debian.org/debian bookworm/main arm64 python3-numpy arm64 1:1.24.2-1 [4,751 kB]
Get:52 http://deb.debian.org/debian bookworm/main arm64 python3-pluggy all 1.0.0+repack-1 [19.7 kB]
Get:53 http://deb.debian.org/debian bookworm/main arm64 python3-psutil arm64 5.9.4-1+b1 [189 kB]
Get:54 http://deb.debian.org/debian bookworm/main arm64 python3-py all 1.11.0-1 [89.2 kB]
Get:55 http://deb.debian.org/debian bookworm/main arm64 python3-pygments all 2.14.0+dfsg-1 [783 kB]
Get:56 http://deb.debian.org/debian bookworm/main arm64 python3-pyinotify all 0.9.6-2 [27.4 kB]
Get:57 http://deb.debian.org/debian bookworm/main arm64 python3-pytest all 7.2.1-2 [236 kB]
Get:58 http://deb.debian.org/debian bookworm/main arm64 python3-simplejson arm64 3.18.3-1 [58.4 kB]
Get:59 http://deb.debian.org/debian bookworm/main arm64 python3-tk arm64 3.11.2-3 [97.7 kB]
Fetched 27.7 MB in 3min 20s (138 kB/s)
Extracting templates from packages: 100%
Selecting previously unselected package fonts-lato.
(Reading database ... 57400 files and directories currently installed.)
Preparing to unpack .../00-fonts-lato_2.0-2.1_all.deb ...
Unpacking fonts-lato (2.0-2.1) ...
Selecting previously unselected package libtcl8.6:arm64.
Preparing to unpack .../01-libtcl8.6_8.6.13+dfsg-2_arm64.deb ...
Unpacking libtcl8.6:arm64 (8.6.13+dfsg-2) ...
Selecting previously unselected package libxrender1:arm64.
Preparing to unpack .../02-libxrender1_1%3a0.9.10-1.1_arm64.deb ...
Unpacking libxrender1:arm64 (1:0.9.10-1.1) ...
Selecting previously unselected package libxft2:arm64.
Preparing to unpack .../03-libxft2_2.3.6-1_arm64.deb ...
Unpacking libxft2:arm64 (2.3.6-1) ...
Selecting previously unselected package x11-common.
Preparing to unpack .../04-x11-common_1%3a7.7+23_all.deb ...
Unpacking x11-common (1:7.7+23) ...
Selecting previously unselected package libxss1:arm64.
Preparing to unpack .../05-libxss1_1%3a1.2.3-1_arm64.deb ...
Unpacking libxss1:arm64 (1:1.2.3-1) ...
Selecting previously unselected package libtk8.6:arm64.
Preparing to unpack .../06-libtk8.6_8.6.13-2_arm64.deb ...
Unpacking libtk8.6:arm64 (8.6.13-2) ...
Selecting previously unselected package tk8.6-blt2.5.
Preparing to unpack .../07-tk8.6-blt2.5_2.5.3+dfsg-4.1_arm64.deb ...
Unpacking tk8.6-blt2.5 (2.5.3+dfsg-4.1) ...
Selecting previously unselected package blt.
Preparing to unpack .../08-blt_2.5.3+dfsg-4.1_arm64.deb ...
Unpacking blt (2.5.3+dfsg-4.1) ...
Selecting previously unselected package fonts-font-awesome.
Preparing to unpack .../09-fonts-font-awesome_5.0.10+really4.7.0~dfsg-4.1_all.deb ...
Unpacking fonts-font-awesome (5.0.10+really4.7.0~dfsg-4.1) ...
Selecting previously unselected package python3-dateutil.
Preparing to unpack .../10-python3-dateutil_2.8.2-2_all.deb ...
Unpacking python3-dateutil (2.8.2-2) ...
Selecting previously unselected package ghp-import.
Preparing to unpack .../11-ghp-import_2.1.0-3_all.deb ...
Unpacking ghp-import (2.1.0-3) ...
Selecting previously unselected package libblas3:arm64.
Preparing to unpack .../12-libblas3_3.11.0-2_arm64.deb ...
Unpacking libblas3:arm64 (3.11.0-2) ...
Selecting previously unselected package libgfortran5:arm64.
Preparing to unpack .../13-libgfortran5_12.2.0-14_arm64.deb ...
Unpacking libgfortran5:arm64 (12.2.0-14) ...
Selecting previously unselected package libjs-popper.js.
Preparing to unpack .../14-libjs-popper.js_1.16.1+ds-6_all.deb ...
Unpacking libjs-popper.js (1.16.1+ds-6) ...
Selecting previously unselected package libjs-bootstrap4.
Preparing to unpack .../15-libjs-bootstrap4_4.6.1+dfsg1-4_all.deb ...
Unpacking libjs-bootstrap4 (4.6.1+dfsg1-4) ...
Selecting previously unselected package libjs-highlight.js.
Preparing to unpack .../16-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ...
Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ...
Selecting previously unselected package libjs-lunr.
Preparing to unpack .../17-libjs-lunr_2.3.9~dfsg-2_all.deb ...
Unpacking libjs-lunr (2.3.9~dfsg-2) ...
Selecting previously unselected package libjs-modernizr.
Preparing to unpack .../18-libjs-modernizr_2.6.2+ds1-5_all.deb ...
Unpacking libjs-modernizr (2.6.2+ds1-5) ...
Selecting previously unselected package libjs-sizzle.
Preparing to unpack .../19-libjs-sizzle_2.3.6+ds+~2.3.3-2_all.deb ...
Unpacking libjs-sizzle (2.3.6+ds+~2.3.3-2) ...
Selecting previously unselected package liblapack3:arm64.
Preparing to unpack .../20-liblapack3_3.11.0-2_arm64.deb ...
Unpacking liblapack3:arm64 (3.11.0-2) ...
Selecting previously unselected package python3-tornado.
Preparing to unpack .../21-python3-tornado_6.2.0-3_arm64.deb ...
Unpacking python3-tornado (6.2.0-3) ...
Selecting previously unselected package python3-livereload.
Preparing to unpack .../22-python3-livereload_2.6.3-2_all.deb ...
Unpacking python3-livereload (2.6.3-2) ...
Selecting previously unselected package python3-colorama.
Preparing to unpack .../23-python3-colorama_0.4.6-2_all.deb ...
Unpacking python3-colorama (0.4.6-2) ...
Selecting previously unselected package python3-click.
Preparing to unpack .../24-python3-click_8.1.3-2_all.deb ...
Unpacking python3-click (8.1.3-2) ...
Selecting previously unselected package python3-joblib.
Preparing to unpack .../25-python3-joblib_1.2.0-4_all.deb ...
Unpacking python3-joblib (1.2.0-4) ...
Selecting previously unselected package python3-regex.
Preparing to unpack .../26-python3-regex_0.1.20221031-1+b1_arm64.deb ...
Unpacking python3-regex (0.1.20221031-1+b1) ...
Selecting previously unselected package python3-tqdm.
Preparing to unpack .../27-python3-tqdm_4.64.1-1_all.deb ...
Unpacking python3-tqdm (4.64.1-1) ...
Selecting previously unselected package python3-nltk.
Preparing to unpack .../28-python3-nltk_3.8-1_all.deb ...
Unpacking python3-nltk (3.8-1) ...
Selecting previously unselected package python3-lunr.
Preparing to unpack .../29-python3-lunr_0.6.2-2_all.deb ...
Unpacking python3-lunr (0.6.2-2) ...
Selecting previously unselected package sphinx-rtd-theme-common.
Preparing to unpack .../30-sphinx-rtd-theme-common_1.2.0+dfsg-1_all.deb ...
Unpacking sphinx-rtd-theme-common (1.2.0+dfsg-1) ...
Selecting previously unselected package python3-markupsafe.
Preparing to unpack .../31-python3-markupsafe_2.1.2-1+b1_arm64.deb ...
Unpacking python3-markupsafe (2.1.2-1+b1) ...
Selecting previously unselected package python3-jinja2.
Preparing to unpack .../32-python3-jinja2_3.1.2-1_all.deb ...
Unpacking python3-jinja2 (3.1.2-1) ...
Selecting previously unselected package python3-markdown.
Preparing to unpack .../33-python3-markdown_3.4.1-2_all.deb ...
Unpacking python3-markdown (3.4.1-2) ...
Selecting previously unselected package python3-mergedeep.
Preparing to unpack .../34-python3-mergedeep_1.3.4-3_all.deb ...
Unpacking python3-mergedeep (1.3.4-3) ...
Selecting previously unselected package python3-packaging.
Preparing to unpack .../35-python3-packaging_23.0-1_all.deb ...
Unpacking python3-packaging (23.0-1) ...
Selecting previously unselected package python3-yaml.
Preparing to unpack .../36-python3-yaml_6.0-3+b2_arm64.deb ...
Unpacking python3-yaml (6.0-3+b2) ...
Selecting previously unselected package python3-pyyaml-env-tag.
Preparing to unpack .../37-python3-pyyaml-env-tag_0.1-3_all.deb ...
Unpacking python3-pyyaml-env-tag (0.1-3) ...
Selecting previously unselected package python3-watchdog.
Preparing to unpack .../38-python3-watchdog_2.2.1-1_all.deb ...
Unpacking python3-watchdog (2.2.1-1) ...
Selecting previously unselected package mkdocs.
Preparing to unpack .../39-mkdocs_1.4.2+dfsg-2_all.deb ...
Unpacking mkdocs (1.4.2+dfsg-2) ...
Selecting previously unselected package node-jquery.
Preparing to unpack .../40-node-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ...
Unpacking node-jquery (3.6.1+dfsg+~3.5.14-1) ...
Selecting previously unselected package python3-argcomplete.
Preparing to unpack .../41-python3-argcomplete_2.0.0-1_all.deb ...
Unpacking python3-argcomplete (2.0.0-1) ...
Selecting previously unselected package python3-userpath.
Preparing to unpack .../42-python3-userpath_1.8.0-1_all.deb ...
Unpacking python3-userpath (1.8.0-1) ...
Selecting previously unselected package pipx.
Preparing to unpack .../43-pipx_1.1.0-1_all.deb ...
Unpacking pipx (1.1.0-1) ...
Selecting previously unselected package python-babel-localedata.
Preparing to unpack .../44-python-babel-localedata_2.10.3-1_all.deb ...
Unpacking python-babel-localedata (2.10.3-1) ...
Selecting previously unselected package python3-attr.
Preparing to unpack .../45-python3-attr_22.2.0-1_all.deb ...
Unpacking python3-attr (22.2.0-1) ...
Selecting previously unselected package python3-tz.
Preparing to unpack .../46-python3-tz_2022.7.1-4_all.deb ...
Unpacking python3-tz (2022.7.1-4) ...
Selecting previously unselected package python3-babel.
Preparing to unpack .../47-python3-babel_2.10.3-1_all.deb ...
Unpacking python3-babel (2.10.3-1) ...
Selecting previously unselected package python3-iniconfig.
Preparing to unpack .../48-python3-iniconfig_1.1.1-2_all.deb ...
Unpacking python3-iniconfig (1.1.1-2) ...
Selecting previously unselected package python3-more-itertools.
Preparing to unpack .../49-python3-more-itertools_8.10.0-2_all.deb ...
Unpacking python3-more-itertools (8.10.0-2) ...
Selecting previously unselected package python3-numpy.
Preparing to unpack .../50-python3-numpy_1%3a1.24.2-1_arm64.deb ...
Unpacking python3-numpy (1:1.24.2-1) ...
Selecting previously unselected package python3-pluggy.
Preparing to unpack .../51-python3-pluggy_1.0.0+repack-1_all.deb ...
Unpacking python3-pluggy (1.0.0+repack-1) ...
Selecting previously unselected package python3-psutil.
Preparing to unpack .../52-python3-psutil_5.9.4-1+b1_arm64.deb ...
Unpacking python3-psutil (5.9.4-1+b1) ...
Selecting previously unselected package python3-py.
Preparing to unpack .../53-python3-py_1.11.0-1_all.deb ...
Unpacking python3-py (1.11.0-1) ...
Selecting previously unselected package python3-pygments.
Preparing to unpack .../54-python3-pygments_2.14.0+dfsg-1_all.deb ...
Unpacking python3-pygments (2.14.0+dfsg-1) ...
Selecting previously unselected package python3-pyinotify.
Preparing to unpack .../55-python3-pyinotify_0.9.6-2_all.deb ...
Unpacking python3-pyinotify (0.9.6-2) ...
Selecting previously unselected package python3-pytest.
Preparing to unpack .../56-python3-pytest_7.2.1-2_all.deb ...
Unpacking python3-pytest (7.2.1-2) ...
Selecting previously unselected package python3-simplejson.
Preparing to unpack .../57-python3-simplejson_3.18.3-1_arm64.deb ...
Unpacking python3-simplejson (3.18.3-1) ...
Selecting previously unselected package python3-tk:arm64.
Preparing to unpack .../58-python3-tk_3.11.2-3_arm64.deb ...
Unpacking python3-tk:arm64 (3.11.2-3) ...
Setting up python3-more-itertools (8.10.0-2) ...
Setting up python3-iniconfig (1.1.1-2) ...
Setting up python3-attr (22.2.0-1) ...
Setting up python3-tornado (6.2.0-3) ...
Setting up fonts-lato (2.0-2.1) ...
Setting up libxrender1:arm64 (1:0.9.10-1.1) ...
Setting up python3-py (1.11.0-1) ...
Setting up python3-joblib (1.2.0-4) ...
Setting up libjs-popper.js (1.16.1+ds-6) ...
Setting up python3-colorama (0.4.6-2) ...
Setting up libjs-lunr (2.3.9~dfsg-2) ...
Setting up python3-pyinotify (0.9.6-2) ...
Setting up python3-tqdm (4.64.1-1) ...
Setting up x11-common (1:7.7+23) ...
Setting up python3-yaml (6.0-3+b2) ...
Setting up python3-click (8.1.3-2) ...
Setting up libjs-sizzle (2.3.6+ds+~2.3.3-2) ...
Setting up python3-markupsafe (2.1.2-1+b1) ...
Setting up libjs-modernizr (2.6.2+ds1-5) ...
Setting up python3-psutil (5.9.4-1+b1) ...
Setting up python3-tz (2022.7.1-4) ...
Setting up python-babel-localedata (2.10.3-1) ...
Setting up python3-pyyaml-env-tag (0.1-3) ...
Setting up python3-simplejson (3.18.3-1) ...
Setting up python3-jinja2 (3.1.2-1) ...
Setting up python3-pygments (2.14.0+dfsg-1) ...
Setting up libblas3:arm64 (3.11.0-2) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/aarch64-linux-gnu/libblas.so.3 (libblas.so.3-aarch64-linux-gnu) in auto mode
Setting up python3-packaging (23.0-1) ...
Setting up python3-markdown (3.4.1-2) ...
Setting up libtcl8.6:arm64 (8.6.13+dfsg-2) ...
Setting up python3-mergedeep (1.3.4-3) ...
Setting up python3-regex (0.1.20221031-1+b1) ...
Setting up libgfortran5:arm64 (12.2.0-14) ...
Setting up python3-pluggy (1.0.0+repack-1) ...
Setting up libjs-highlight.js (9.18.5+dfsg1-2) ...
Setting up python3-livereload (2.6.3-2) ...
Setting up python3-dateutil (2.8.2-2) ...
Setting up libxss1:arm64 (1:1.2.3-1) ...
Setting up libjs-bootstrap4 (4.6.1+dfsg1-4) ...
Setting up python3-argcomplete (2.0.0-1) ...
Setting up python3-nltk (3.8-1) ...
Setting up fonts-font-awesome (5.0.10+really4.7.0~dfsg-4.1) ...
Setting up sphinx-rtd-theme-common (1.2.0+dfsg-1) ...
Setting up node-jquery (3.6.1+dfsg+~3.5.14-1) ...
Setting up python3-userpath (1.8.0-1) ...
Setting up python3-lunr (0.6.2-2) ...
Setting up liblapack3:arm64 (3.11.0-2) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/aarch64-linux-gnu/liblapack.so.3 (liblapack.so.3-aarch64-linux-gnu) in auto mode
Setting up libxft2:arm64 (2.3.6-1) ...
Setting up python3-babel (2.10.3-1) ...
update-alternatives: using /usr/bin/pybabel-python3 to provide /usr/bin/pybabel (pybabel) in auto mode
Setting up python3-pytest (7.2.1-2) ...
Setting up python3-watchdog (2.2.1-1) ...
Setting up libtk8.6:arm64 (8.6.13-2) ...
Setting up pipx (1.1.0-1) ...
Setting up python3-numpy (1:1.24.2-1) ...
Setting up ghp-import (2.1.0-3) ...
Setting up mkdocs (1.4.2+dfsg-2) ...
Setting up tk8.6-blt2.5 (2.5.3+dfsg-4.1) ...
Setting up blt (2.5.3+dfsg-4.1) ...
Setting up python3-tk:arm64 (3.11.2-3) ...
Processing triggers for libc-bin (2.36-9+rpt2+deb12u7) ...
Processing triggers for man-db (2.11.2-2) ...

pi@oegmon:~ $ pipx ensurepath
Success! Added /home/pi/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for instructions.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨
pi@oegmon:~ $ pipx install minimalmodbus --include-deps
⚠️ Note: pyserial-miniterm was already on your PATH at /usr/bin/pyserial-miniterm
⚠️ Note: pyserial-ports was already on your PATH at /usr/bin/pyserial-ports
installed package minimalmodbus 2.1.1, installed using Python 3.11.2
These apps are now globally available
- pyserial-miniterm
- pyserial-ports
⚠️ Note: '/home/pi/.local/bin' is not on your PATH environment variable. These apps will not be globally accessible until
your PATH is updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in your shell's config
file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨

pi@oegmon:~ $ pipx ensurepath
/home/pi/.local/bin has been been added to PATH, but you need to open a new terminal or re-login for this PATH change to
take effect.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨

Het Script

Ik heb onderstaand Python script  aangemaakt / bewerkt met de nano editor en het OEG_scan.py genoemd.
Tip: Nano verlaten en de wijzigingen daarbij (al dan niet) opslaan doe je met Control+X (^X

Een aantal regels, met name die de opdracht print bevatten, waren alleen bedoeld om mee te testen en zijn hier (met #) gecommentarieerd en daarmee uitgeschakeld. 

pi@pgit-rpi02:~ $ mkdir scripts
pi@pgit-rpi02:~ $ nano /home/pi/scripts/oeg_scan.py
#!/usr/bin/python3
#

#https://github.com/ced2git/oeg_kmsd
#Register 35 R1 R2 R3
#0 OFF OFF OFF
#1 ON OFF OFF
#2 OFF ON OFF
#3 ON ON OFF
#4 OFF OFF ON
#5 ON OFF ON
#6 OFF ON ON
#7 ON ON ON


oeg_dict = {

35:"", #R1/R2/R3 status On/Off
38:"", #T1 temperatuur collector oost
39:"", #T2 temperatuur boiler onderin
40:"", #T3 temperatuur collector west
58:"", #R2 pomp modulatie 0-100%
}

import serial
import minimalmodbus
import os
import time
import datetime
import urllib.request, urllib.error, urllib.parse
import json

instrument = minimalmodbus.Instrument('/dev/ttyACM0', 128, minimalmodbus.MODE_ASCII) # port name, slave address (in decimal)
#Change the COM port above to the OEG Usb comport or USB address on Linux.
instrument.serial.baudrate = 9600 # Baud
instrument.serial.parity = serial.PARITY_EVEN
instrument.serial.bytesize = 7
instrument.serial.stopbits = 1
instrument.serial.timeout = 0.05 # seconds

delay = 5
T1 = str(instrument.read_register(38,1,3,signed=True))
#print(T1)
T2 = str(instrument.read_register(39,1,3,signed=True))
#print(T2)
T3 = str(instrument.read_register(40,1,3,signed=True))
#print(T3)
R2 = str(10*(instrument.read_register(58,1,3,signed=True)))
#print(R2)
if (10*(instrument.read_register(35,1,3,signed=True))) >= 4:
R3 = '0'
else:
R3 = '10'
#print(R3)
#time.sleep(delay)

idxT1 = '119'
idxT2 = '120'
idxT3 = '121'
idxR2 = '122'
idxR3 = '198'
domoticzPort ="8080"
domoticzIP = "192.168.178.30"
linkName = 'wlan0'

domoticz = domoticzIP + ":" + domoticzPort
#print(domoticz)

def log(message):
print (message)

def domoticzrequest (url):
request = urllib.request.Request(url)
response = urllib.request.urlopen(request)

domoticzSetT1 = "http://" + domoticz + "/json.htm?type=command&param=udevice&idx=" + idxT1 + "&nvalue=0&svalue=" + T1
#print(domoticzSetT1)
domoticzrequest(domoticzSetT1)

domoticzSetT2 = "http://" + domoticz + "/json.htm?type=command&param=udevice&idx=" + idxT2 + "&nvalue=0&svalue=" + T2
#print(domoticzSetT2)
domoticzrequest(domoticzSetT2)

domoticzSetT3 = "http://" + domoticz + "/json.htm?type=command&param=udevice&idx=" + idxT3 + "&nvalue=0&svalue=" + T3
#print(domoticzSetT3)
domoticzrequest(domoticzSetT3)

domoticzSetR2 = "http://" + domoticz + "/json.htm?type=command&param=udevice&idx=" + idxR2 + "&nvalue=0&svalue=" + R2
#print(domoticzSetR2)
domoticzrequest(domoticzSetR2)

domoticzSetR3 = "http://" + domoticz + "/json.htm?type=command&param=switchlight&idx=" + idxR3 + "&switchcmd=Set%20Level&level=" +R3
#print(domoticzSetR3)
domoticzrequest(domoticzSetR3)
#time.sleep(delay)

Het script uitvoerbaar maken

pi@oegmon:~ $ chmod +x /home/pi/scripts/oeg_scan.py

 

Het script schedulen in cron

Ik laat het script elke 10 minuten draaien, zodat de waardes elke 10 minuten in Domoticz worden bijgewerkt.
N.B. De eerste keer dat je crontab -e (van edit) start krijg je een vraag welke editor je daar (voortaan) voor wil gebruiken. Ik heb voor nano gekozen, omdat ik die het makkelijkst vind.

pi@pgit-rpi02:~ $ crontab -e
GNU nano 5.4 /tmp/crontab.MM2qzu/crontab
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
*/10 * * * * python /home/pi/scripts/oeg_scan.py >dev0

Dit vind je misschien ook leuk...

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.