Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Adam Mateusz Brożyński
Adam Mateusz Brożyński

Posted on

     

Zdalny odczyt licznika AMIplus z HANplus (m-bus)

Poniższe instrukcje pozwalają na pobieranie odczytów licznika AMIplus w Ubuntu za pomocą wireless m-bus (HANplus) w czasie rzeczywistym.

Do zdalnych odczytówpotrzebujemy dekodera DVB-T (wystarczy USB) z anteną, opartego naRTL2832U,RTL2838 i innych kompatybilnych.

1. Instalujemy potrzebne pakiety:

$sudoaptinstallrtl-sdr libncurses-dev librtlsdr-dev mosquitto-clients mosquitto
Enter fullscreen modeExit fullscreen mode

2. Pobieramy i instalujemy pakiety i repozytorium GIT:

$cd /tmp$git clone https://github.com/xaelsouth/rtl-wmbus.git$cdrtl-wmbus$make$sudo cpbuild/rtl_wmbus /usr/bin/rtl_wmbus$cd /tmp
Enter fullscreen modeExit fullscreen mode
$git clone https://github.com/weetmuts/wmbusmeters.git$cdwmbusmeters$./configure$make$sudomakeinstall$sudosystemctl daemon-reload$sudoudevadm control--reload-rules$sudoudevadm trigger
Enter fullscreen modeExit fullscreen mode

3. Edytujemy/etc/wmbusmeters.conf:

device=rtlwmbus:868.9Mlogtelegrams=falseformat=jsonmeterfiles=/var/log/wmbusmeters/meter_readingsmeterfilesaction=overwritelogfile=/var/log/wmbusmeters/wmbusmeters.logshell=/usr/local/bin/wmbus-mqtt
Enter fullscreen modeExit fullscreen mode

4. Tworzymy katalogi dlawmbusmeters:

$sudo mkdir-p /var/log/wmbusmeters/meter_readings
Enter fullscreen modeExit fullscreen mode

5. Wpisujemy dane licznika do pliku/etc/wmbusmeters.d/amiplusNUMERLICZNIKA:

name=amiplusNUMERLICZNIKAtype=amiplusid=ADRES_PORTU_KOMUNIKACYJNEGO_Z_APLIKACJI_ELICZNIKkey=KLUCZ_Z_APLIKACJI_ELICZNIK
Enter fullscreen modeExit fullscreen mode

6. Tworzymy skrypt/usr/local/bin/wmbus-mqtt:

#!/bin/sh/usr/bin/mosquitto_pub-h localhost-t home/tauron/state-m"$METER_JSON"
Enter fullscreen modeExit fullscreen mode

7. Uruchamiamy serwer MQTT:

$sudosystemctlenablemosquitto$sudosystemctl start mosquitto
Enter fullscreen modeExit fullscreen mode

8. Uruchamiamy odczyty i sprawdzamy, czy nie ma żadnych błędów:

$sudosystemctl restart wmbusmeters$sudosystemctl status wmbusmeters
Enter fullscreen modeExit fullscreen mode

W Debianie są problemy z uruchomieniem nasłuchu jeśli w plikulib/systemd/system/wmbusmeters.service jest wpisany użytkownik i grupawmbusmeters. W takim przypadku komentujemy poniższe linijki:

#User=wmbusmeters#Group=wmbusmeters#ExecStartPre=/bin/chown -R wmbusmeters:wmbusmeters /var/log/wmbusmeters#ExecStartPre=/bin/chown -R wmbusmeters:wmbusmeters /run/wmbusmeters
Enter fullscreen modeExit fullscreen mode

9. Możemy się połączyć przez MQTT, aby sprawdzić odczyty:

$mosquitto_sub-h localhost-F"%J"--pretty-t'home/tauron/state
Enter fullscreen modeExit fullscreen mode

10. Jeśli chcemy dodać licznik do Home Assistanta, musimy zainstalować integrację MQTT, połączyć się zlocalhost i utworzyć odpowiednie sensory wconfiguration.yaml, które później będzie można dodać do kokpitu:

mqtt:sensor:-name:"Energycountername"state_topic:"home/tauron/state"value_template:"{{value_json.name}}"-name:"Energycounterid"state_topic:"home/tauron/state"value_template:"{{value_json.id}}"-name:"Energytotalconsumption"state_topic:"home/tauron/state"value_template:"{{value_json.total_energy_consumption_kwh}}"unit_of_measurement:"kWh"-name:"Energytotalproduction"state_topic:"home/tauron/state"value_template:"{{value_json.total_energy_production_kwh}}"unit_of_measurement:"kWh"-name:"Energycurrentconsumption"state_topic:"home/tauron/state"value_template:"{{value_json.current_power_consumption_kw}}"unit_of_measurement:"kW"-name:"Energycurrentproduction"state_topic:"home/tauron/state"value_template:"{{value_json.current_power_production_kw}}"unit_of_measurement:"kW"
Enter fullscreen modeExit fullscreen mode

10. Po zapisaniu konfiguracji w HA należy ją sprawdzić wNarzędziach developerskich i uruchomić ponownie.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
niebochod profile image
niebochod
  • Joined

Bardzo fajny opis! Z powodzeniem wykorzystałem dla openHAB-a na openhabian z modyfikacjami w punkcie 10 i 11. Dzięki!!

W "6. Tworzymy skrypt /usr/local/bin/wmbus-mqtt" można też dodać:

sudo chown a+x /usr/local/bin/wmbus-mqtt`
Enter fullscreen modeExit fullscreen mode

i w punkcie "9. Możemy się połączyć przez MQTT, aby sprawdzić odczyty:" dodać ` na końcu polecenia.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

.
  • Location
    Częstochowa, Poland
  • Work
    Full stack developer at Ordigital
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp