reserve85 / HoymilesZeroExport

Zero Export Script for Hoymiles Inverters using AhoyDTU / OpenDTU and Tasmota Smart Meter inferface / Shelly 3EM / SHRDZM / Emlog / ioBroker
GNU General Public License v3.0
134 stars 31 forks source link

Service startet nicht #41

Closed costa2 closed 1 year ago

costa2 commented 1 year ago

Mein System: 2 HM-600, Ahoy und Hichi Lesekopf. Im HoymilesZeroExport.py ist scheinbar ein Fehler. Kann es daran liegen?

Apr 09 14:41:29 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Started HoymilesZeroExport Service. Apr 09 14:41:29 raspberrypi python3[7912]: File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 69 Apr 09 14:41:29 raspberrypi python3[7912]: url=f"http://{OPENDTU_IP}/api/limit/config" Apr 09 14:41:29 raspberrypi python3[7912]: ^ Apr 09 14:41:29 raspberrypi python3[7912]: SyntaxError: invalid syntax Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service: main process exited, code=exited, status=1/FAILURE Apr 09 14:41:29 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state. Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 14:41:29 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Started HoymilesZeroExport Service. Apr 09 14:41:29 raspberrypi python3[7918]: File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 69 Apr 09 14:41:29 raspberrypi python3[7918]: url=f"http://{OPENDTU_IP}/api/limit/config" Apr 09 14:41:29 raspberrypi python3[7918]: ^ Apr 09 14:41:29 raspberrypi python3[7918]: SyntaxError: invalid syntax Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service: main process exited, code=exited, status=1/FAILURE Apr 09 14:41:29 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state. Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 14:41:29 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Started HoymilesZeroExport Service. Apr 09 14:41:29 raspberrypi python3[7920]: File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 69 Apr 09 14:41:29 raspberrypi python3[7920]: url=f"http://{OPENDTU_IP}/api/limit/config" Apr 09 14:41:29 raspberrypi python3[7920]: ^ Apr 09 14:41:29 raspberrypi python3[7920]: SyntaxError: invalid syntax Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service: main process exited, code=exited, status=1/FAILURE Apr 09 14:41:29 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state. Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 14:41:29 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Started HoymilesZeroExport Service. Apr 09 14:41:29 raspberrypi python3[7923]: File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 69 Apr 09 14:41:29 raspberrypi python3[7923]: url=f"http://{OPENDTU_IP}/api/limit/config" Apr 09 14:41:29 raspberrypi python3[7923]: ^ Apr 09 14:41:29 raspberrypi python3[7923]: SyntaxError: invalid syntax Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service: main process exited, code=exited, status=1/FAILURE Apr 09 14:41:29 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state. Apr 09 14:41:29 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 14:41:29 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 14:41:29 raspberrypi systemd[1]: Started HoymilesZeroExport Service. Apr 09 14:41:30 raspberrypi python3[7925]: File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 69 Apr 09 14:41:30 raspberrypi python3[7925]: url=f"http://{OPENDTU_IP}/api/limit/config" Apr 09 14:41:30 raspberrypi python3[7925]: ^ Apr 09 14:41:30 raspberrypi python3[7925]: SyntaxError: invalid syntax Apr 09 14:41:30 raspberrypi systemd[1]: HoymilesZeroExport.service: main process exited, code=exited, status=1/FAILURE Apr 09 14:41:30 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state. Apr 09 14:41:30 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 14:41:30 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 14:41:30 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 14:41:30 raspberrypi systemd[1]: HoymilesZeroExport.service start request repeated too quickly, refusing to start. Apr 09 14:41:30 raspberrypi systemd[1]: Failed to start HoymilesZeroExport Service. Apr 09 14:41:30 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state.

reserve85 commented 1 year ago

Hallo, das kann ich irgendwie nicht wirklich nachvollziehen - bei mir funktioniert der code, unter Windows und unter Linux mit Python 3.9.2

edit: Ich vermute du hast Python 3 kleiner V3.6 installiert? Da geht das nicht: --> In Python 3.6, the f-string, formatted string literal, was introduced Dann mรผsstest du Python updaten. Schau mal mit python3 -โ€“version welche Version du installiert hast und ggf. mรผsstest du dann updaten.

costa2 commented 1 year ago

Stimmt, Python 3.4.2 Dann werde ich es mal updaten. Danke erst einmal, ich melde mich dann wieder.

costa2 commented 1 year ago

An Python lag es nicht, es ist nun 3.9.9 Muss ich das Script nun eventuell neu installieren?

Apr 09 22:21:05 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 22:21:05 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 22:21:05 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 22:21:05 raspberrypi systemd[1]: Started HoymilesZeroExport Service. Apr 09 22:21:05 raspberrypi python3[7496]: File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 69 Apr 09 22:21:05 raspberrypi python3[7496]: url=f"http://{OPENDTU_IP}/api/limit/config" Apr 09 22:21:05 raspberrypi python3[7496]: ^ Apr 09 22:21:05 raspberrypi python3[7496]: SyntaxError: invalid syntax Apr 09 22:21:05 raspberrypi systemd[1]: HoymilesZeroExport.service: main process exited, code=exited, status=1/FAILURE Apr 09 22:21:05 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state. Apr 09 22:21:05 raspberrypi systemd[1]: HoymilesZeroExport.service holdoff time over, scheduling restart. Apr 09 22:21:05 raspberrypi systemd[1]: Stopping HoymilesZeroExport Service... Apr 09 22:21:05 raspberrypi systemd[1]: Starting HoymilesZeroExport Service... Apr 09 22:21:05 raspberrypi systemd[1]: HoymilesZeroExport.service ๐’”๐’•๐’‚๐’“๐’• ๐’“๐’†๐’’๐’–๐’†๐’”๐’• ๐’“๐’†๐’‘๐’†๐’‚๐’•๐’†๐’… ๐’•๐’๐’ ๐’’๐’–๐’Š๐’„๐’Œ๐’๐’š, refusing to start. Apr 09 22:21:05 raspberrypi systemd[1]: Failed to start HoymilesZeroExport Service. Apr 09 22:21:05 raspberrypi systemd[1]: Unit HoymilesZeroExport.service entered failed state.

reserve85 commented 1 year ago

Bist du sicher, dass der Dienst auch mit der neuen Python Version ausgefรผhrt wird? Ich glaube das muss man explizit noch aktivieren. Kommt bei python3 --version jetzt 3.9.9?

edit: ah, das hier meinte ich: sudo update-alternatives --config python3 - siehe hier

edit2: gib mal /usr/bin/python3 in die shell ein, damit wird der Service das Script starten. bei mir sieht das dann so aus:

pi@RasPi4:~$ /usr/bin/python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
costa2 commented 1 year ago

pi@raspberrypi:/usr/bin $ python --version Python 3.9.9

reserve85 commented 1 year ago

was ist wenn du mit dem Befehl hier mal probierst das Script zu starten? python3.9 HoymilesZeroExport/HoymilesZeroExport.py

costa2 commented 1 year ago

pi@raspberrypi:/ $ sudo python3.9: can't open file '/home/pi/HoymilesZeroExport/HoymilesZeroExport/HoymilesZeroExport.py': [Errno 2] No such file or directory

Es ist ja Python 3.9.9, aber auch das geht nicht.

pi@raspberrypi:/ $ sudo python3.9.9 HoymilesZeroExport/HoymilesZeroExport.py sudo: python3.9.9: Kommando nicht gefunden

reserve85 commented 1 year ago

Oben ist der Pfad falsch, da findet er die Datei nicht.

python3.9 /home/pi/HoymilesZeroExport/HoymilesZeroExport.py Das mรผsste korrekt sein

costa2 commented 1 year ago

Traceback (most recent call last): File "/home/pi/HoymilesZeroExport/HoymilesZeroExport.py", line 20, in import requests ModuleNotFoundError: No module named 'requests'

reserve85 commented 1 year ago

pip3 install requests Musst du noch fรผr die neue Version machen

costa2 commented 1 year ago

Leider funktioniert es nicht, irgendwas ist mit meinem Fhem nicht i.O.. Die selbe Fehlermeldung bekomme ich auch, wenn ich ein Upgrade auf Bullseye machen mรถchte.

sudo apt-get install python3-requests Paketlisten werden gelesen... Fertig Abhรคngigkeitsbaum wird aufgebaut. Statusinformationen werden eingelesen.... Fertig E: Das Paket fhem muss neu installiert werden, es kann jedoch kein Archiv dafรผr gefunden werden.

Nun habe ich folgendes dazu gefunden:

๐—ฒ๐˜€ ๐˜€๐—ฐ๐—ต๐—ฒ๐—ถ๐—ป๐˜ ๐—ฎ๐—น๐˜€ ๐˜„รผ๐—ฟ๐—ฑ๐—ฒ ๐—ฒ๐—ถ๐—ป ๐—ฎ๐—น๐˜๐—ฒ๐˜€ ๐—ฝ๐—ฎ๐—ธ๐—ฒ๐˜ ๐—ป๐—ผ๐—ฐ๐—ต ๐˜„๐—ฎ๐˜€ ๐—ฏ๐—ฒ๐—ถ ๐—ฑ๐—ถ๐—ฟ ๐—ฏ๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ฒ๐—ฟ๐—ฒ๐—ป: ๐—ถ๐—ฐ๐—ต ๐˜„รผ๐—ฟ๐—ฑ๐—ฒ ๐—ฑ๐—ถ๐—ฟ ๐—ณรผ๐—ฟ ๐—ฎ๐—น๐—น๐—ฒ ๐—ณ๐—ฎ๐—น๐˜€๐—ฐ๐—ต๐—ฒ๐—ป ๐˜‚๐—ป๐—ฑ ๐—ป๐—ถ๐—ฐ๐—ต๐˜ ๐˜‡๐˜‚๐—บ ๐—ผ๐—ณ๐—ณ๐—ถ๐˜‡๐—ถ๐—ฒ๐—น๐—น๐—ฒ๐—ป ๐—ฑ๐—ฒ๐—ฏ๐—ถ๐—ฎ๐—ป ๐˜๐—ฟ๐—ฒ๐—ฒ ๐—ด๐—ฒ๐—ตรถ๐—ฟ๐—ฒ๐—ป๐—ฑ๐—ฒ ๐—ฝ๐—ฎ๐—ธ๐—ฒ๐˜๐—ฒ ๐—ฒ๐—บ๐—ฝ๐—ณ๐—ฒ๐—ต๐—น๐—ฒ๐—ป ๐—ฑ๐—ถ๐—ฒ๐˜€๐—ฒ ๐—บ๐—ถ๐˜ ๐—ฑ๐—ฝ๐—ธ๐—ด --๐—ฝ๐˜‚๐—ฟ๐—ด๐—ฒ --๐—ณ๐—ผ๐—ฟ๐—ฐ๐—ฒ-๐—ฎ๐—น๐—น ๐˜‡๐˜‚ ๐—นรถ๐˜€๐—ฐ๐—ต๐—ฒ๐—ป. ๐—บ๐—ถ๐˜ ๐—ฑ๐—ฒ๐—ฟ ๐—ผ๐—ฝ๐˜๐—ถ๐—ผ๐—ป --๐—ณ๐—ผ๐—ฟ๐—ฐ๐—ฒ-๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ-๐—ฟ๐—ฒ๐—ถ๐—ป๐˜€๐˜๐—ฟ๐—ฒ๐—พ ๐˜€๐—ผ๐—น๐—น๐˜๐—ฒ ๐˜€๐—ถ๐—ฐ๐—ต ๐—ฑ๐—ฎ๐˜€ ๐—ผ๐—ฏ๐—ฒ๐—ป ๐—ด๐—ฒ๐˜€๐—ฐ๐—ต๐—ถ๐—น๐—ฑ๐—ฒ๐—ฟ๐˜๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ฏ๐—น๐—ฒ๐—บ ๐—นรถ๐˜€๐—ฒ๐—ป ๐—น๐—ฎ๐˜€๐˜€๐—ฒ๐—ป.

Ich befรผrchte aber, dass ich meine Fhem Installation damit schrotte.

reserve85 commented 1 year ago

Ja irgendwas ist da total faul. Du kannst noch das hier probieren: python3.9 -m pip3 install requests Oder python3.9 -m pip install requests

ich bin leider auch kein Linux Professional, evtl kann hier noch jemand helfen? Das Problem wieso das Script nicht startet liegt aber definitiv an Python.

costa2 commented 1 year ago

Nun habe ich das Script auf einem zweiten Raspi installiert, welcher nur als Bluetooth Repeater genutzt wird, da lรคuft das Script, aaaber:

Apr 10 16:59:27 raspi2 python3[15109]: 2023-04-10 16:59:27 ERROR Exception at GetPowermeterWatts Apr 10 16:59:27 raspi2 python3[15109]: 2023-04-10 16:59:27 ERROR 'SM1'

Der Hichi hat das MQTT Topic SM1. In der ini ist es so eingestellt:

[SELECT_POWERMETER]

--- define your Powermeter (only one) ---

USE_TASMOTA = true

T[TASMOTA]

--- defines for Tasmota Smartmeter Modul---

TASMOTA_IP = 192.168.0.86

the following three constants describes how to navigate through the Tasmota-JSON

e.g. JSON_Result = {"StatusSNS":{"Time":"2023-02-28T12:49:49","SML":{"total_kwh":15011.575,"curr_w":-71}}}

TASMOTA_JSON_STATUS = StatusSNS

Prefix for Web UI and MQTT JSON payload

TASMOTA_JSON_PAYLOAD_MQTT_PREFIX = SM1

Power-MQTT label (the current power in Watt, positive (import more energy than export) or negative (export more ene$

TASMOTA_JSON_POWER_MQTT_LABEL = SM_16_7_0

if your powermeter does NOT output the current power: you need to calculate it -> Power(W) = OBIS(1.7.0) - OBIS(2.7$

TASMOTA_JSON_POWER_CALCULATE = FALSE

Power-MQTT Input label (positive active instantaneous power, e.g. OBIS Code 1.7.0)

TASMOTA_JSON_POWER_INPUT_MQTT_LABEL =

Power-MQTT output label (negative active instantaneous power, e.g. OBIS Code 2.7.0)

TASMOTA_JSON_POWER_OUTPUT_MQTT_LABEL =

reserve85 commented 1 year ago

Gib mal http://192.168.0.86/cm?cmnd=status%2010 Im Browser ein und poste mal das was zurรผck kommt

costa2 commented 1 year ago

// 20230410173233 // http://192.168.0.86/cm?cmnd=status%2010

{ "StatusSNS": { "Time": "2023-04-10T17:32:10", "SM": { "1_8_0": 143.54, "2_8_0": 35.45, "16_7_0": -53.00, "36_7_0": 27.35, "56_7_0": 179.22, "76_7_0": -259.57, "32_7_0": 225.7, "52_7_0": 227.6, "72_7_0": 228.0, "96_1_0": "1EBxxxxxxxxx" } } }

reserve85 commented 1 year ago

Dann musst du einstellen:

TASMOTA_JSON_STATUS = StatusSNS
TASMOTA_JSON_PAYLOAD_MQTT_PREFIX = SM
TASMOTA_JSON_POWER_MQTT_LABEL = 16_7_0
costa2 commented 1 year ago

Dann musst du einstellen:

TASMOTA_JSON_STATUS = StatusSNS
TASMOTA_JSON_PAYLOAD_MQTT_PREFIX = SM
TASMOTA_JSON_POWER_MQTT_LABEL = 16_7_0

Vielen Dank fรผr Deine Bemรผhungen, jetzt lรคuft es. Nun muss ich mich nur noch mit dem Feintuning beschรคftigen.

reserve85 commented 1 year ago

Super, dass es lรคuft und keine ahnung was mit dem Python auf deinem anderen Raspi los ist.

kannst auch mal hier reinschauen: https://github.com/reserve85/HoymilesZeroExport/issues/28