[gelöst] Einbinden von ENVIRO Wetterstation in FHEM via MQTT

Begonnen von Borkk, 06 Juli 2020, 13:41:08

Vorheriges Thema - Nächstes Thema

Borkk

Also in Richtung fhem klappt alles. Ich habe mit MQTT Explorer erfolgreich Topics mit Werten abgesetzt und es wurde direkt ein MQTT2_Device angelegt und die readingList mit samt der Readings angelegt. Das ging dann doch einfacher als ich dachte.

Also muss ich mal tiefer in den ENVIRO einsteigen. Danke schon mal für die Hilfe.

Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Otto123

Was ich deinen Links so gesehen habe:
Die python Geschichte ist ja zweiteilig, also zwei Teile wo was schief laufen kann.
Aufruf, Parameter, Bibliotheken, Rechte, User, Gruppen
Also hübsch Stück für Stück manuell testen und untersuchen, der Dienst das es automatisch läuft ist zum Schluss ;)
Das stand was von UART, das ist beim Pi auch etwas speziell.

Welche der Komponenten läuft denn schon?
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

Borkk

Ich habe schon echt viel mit Pi´s von Zero bis 4er zum laufen gebracht aber das hier ist echt ne harte Nuss. (für mich) Die verschiedenen Setup Varianten legen unterschiedliche Verzeichnisstrukturen an. Manche Scripte laufen einwandfrei andere brechen mit Syntax Fehlern ab. Ich gehe jetzt mal pennen und fange morgen neu an. Leider stecke ich nicht bis auf die Tiefe eines Softwareentwicklers drin. Scheinbar setzten manche Scripte das Vorhandensein des PMS5003 Sensors vorraus.

Es wird nämlich seit einiger Zeit ein mqtt-all.py Script mit installiert wenn man es aber startet, kommt das:

python3 /home/pi/enviroplus-python/examples/mqtt-all.py --broker 192.168.23.119 --port 1883 --topic enviroplus

mqtt-all.py - Reads temperature, pressure, humidity,
    PM2.5, and PM10 from Enviro plus and sends data over mqtt.

    broker: 192.168.23.119
    port: 1883
    topic: enviroplus

    Press Ctrl+C to exit!

   
Raspberry Pi serial: 0000000093510a14
Wi-Fi: connected

MQTT broker IP: 192.168.23.119
CONNACK received with code 0
connected OK
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
PMS5003 Read Timeout: Failed to read start of frame byte
ç^CTraceback (most recent call last):
  File "/home/pi/enviroplus-python/examples/mqtt-all.py", line 212, in <module>
    main()
  File "/home/pi/enviroplus-python/examples/mqtt-all.py", line 200, in main
    values = read_values(bme280, pms5003)
  File "/home/pi/enviroplus-python/examples/mqtt-all.py", line 69, in read_values
    pm_values = pms5003.read()  # int
  File "/usr/local/lib/python3.7/dist-packages/pms5003-0.0.5-py3.7.egg/pms5003/__init__.py", line 125, in read
    sof = self._serial.read(1)
  File "/usr/local/lib/python3.7/dist-packages/pyserial-3.4-py3.7.egg/serial/serialposix.py", line 483, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
KeyboardInterrupt
 

Die Parameter von mqtt-all.py sind aber nicht dokumentiert. Scheint alles nicht ausgereift zu sein.   
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Borkk

Zitat von: Otto123 am 06 Juli 2020, 21:45:24
Was ich deinen Links so gesehen habe:
Die python Geschichte ist ja zweiteilig, also zwei Teile wo was schief laufen kann.
Aufruf, Parameter, Bibliotheken, Rechte, User, Gruppen
Also hübsch Stück für Stück manuell testen und untersuchen, der Dienst das es automatisch läuft ist zum Schluss ;)
Das stand was von UART, das ist beim Pi auch etwas speziell.

Welche der Komponenten läuft denn schon?

Also ich fasse mal zusammen:

- Installation Enviro Board auf Raspi Zero -> läuft
- MQTT Broker auf FHEM -> läuft
- Kommunikation > von PI Zero über Mosquitto Client nach FHEM -> läuft
- Light oder Weather Python Scripts mit Ausgabe an Konsole -> läuft

Der letzte Baustein wäre nun das MQTT Pyhon Script lauffähig zu bekommen. Das scheitert gerade daran, das das Script auf die PMS und Gas Sensoren zugreift, die ich aber beide nicht habe. Der Kommentar des Entwicklers auf meine Frage ob er sein Script an das Enviro Board anpassen könnte (nicht Enviro+ mit PMS) ist:

"...you would need to comment out a few lines from the existing script, please have a go.;)

Ich habe jetzt mal wild im Script auskommentiert aber ich bekomme es nicht hin.

@Otto: würdest du mir dabei helfen? Ich habe das Script mal angehängt. Zum Schluss muss dann noch als Service laufen. 
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Otto123

Original
            values = read_values(bme280, pms5003)
Versuch mal Zeile 200 so zu ändern:
#            values = read_values(bme280, pms5003)
            values = read_values(bme280)
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

Borkk

Zitat von: Otto123 am 07 Juli 2020, 13:49:35
Original
            values = read_values(bme280, pms5003)
Versuch mal Zeile 200 so zu ändern:
#            values = read_values(bme280, pms5003)
            values = read_values(bme280)


Das hatte ich schon mal versucht:

  File "mqtt-all.py", line 201
    values = read_values(bme280)
    ^
IndentationError: unexpected indent


Ich habe gestern lange versucht, auch andere Zeilen auszukommentieren aber ich bekomme immer Fehlermeldungen. Am Ende wäre es Glücksache wenn ich die richtigen Zeilen erwische. Ich kann einfach nicht Programmieren.   :(
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Otto123

Versuch mal so wie im Anhang. Ich kann es leider nicht testen und habe von der Schlange auch keine wirkliche Ahnung.
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

Borkk

Zitat von: Otto123 am 08 Juli 2020, 09:11:56
Versuch mal so wie im Anhang. Ich kann es leider nicht testen und habe von der Schlange auch keine wirkliche Ahnung.

Danke für deine Hilfe, nur leider...


...
name 'pms5003' is not defined
name 'pms5003' is not defined
name 'pms5003' is not defined
name 'pms5003' is not defined
name 'pms5003' is not defined
name 'pms5003' is not defined
^CTraceback (most recent call last):
  File "mqtt-new.py", line 200, in main
    values = read_values(bme280, pms5003)
NameError: name 'pms5003' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mqtt-new.py", line 212, in <module>
    main()
  File "mqtt-new.py", line 208, in main
    print(e)
KeyboardInterrupt
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Borkk

Wenn ich in der Zeile 200 die folgende Änderung machen:


# values = read_values(bme280, pms5003)
    values = read_values(bme280)


kommt das:

read_values() missing 1 required positional argument: 'pms5003'
read_values() missing 1 required positional argument: 'pms5003'
^Cread_values() missing 1 required positional argument: 'pms5003'Traceback (most recent call last):
  File "mqtt-new.py", line 201, in main
    values = read_values(bme280)
TypeError: read_values() missing 1 required positional argument: 'pms5003'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mqtt-new.py", line 213, in <module>
    main()
  File "mqtt-new.py", line 209, in main
    print(e)
KeyboardInterrupt
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Borkk

Mittlerweile hat der Developer ein issue auf Git aufgemacht.

https://github.com/robmarkcole/rpi-enviro-mqtt/issues/7

Wenn wir hier nicht zu einer Lösung kommen, dann schreibe ich mal da was rein.
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Borkk

Ich habe jetzt eine Lösung erarbeitet. Das grundsätzliche Problem besteht darin, das es ein Enviro und ein Enviro+ Board gibt das Enviro+ hat zusätzlich einen MICS6814 analog gas sensor. Die Example MQTT Scripts gehen oft von einem Enviro+ Board aus und laufen in einen Fehler wenn man "nur" ein Enviro Board hat.

Ich habe das mitgelieferte mqtt-all.py Script nicht zum laufen bekommen, bin aber mit diesem Projekt erfolgreich gewesen. https://github.com/hotplot/enviroplus-mqtt

Für ein ENVIRO Board kann die angehängte logger.py verwendet werden.
Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)

Borkk

Ich habe hier noch weitergearbeitet und habe das mitgelieferte mqtt-all.py Script angepasst und als Service implementiert. Die Lösung zeigt nun alle Werte auf dem Display und sendet sie per MQTT an FHEM.

Wer Interesse hat dem stelle ich das fertig Pi Zero Image gerne zur Verfügung.

Proxmox & Docker:  FHEM, Raspberrymatic, ConBee3, Nginx ReverseProxy, ConfigDB, MQTT, NodeRed, InfluxDB, Grafana, HmIP Akt- /Sensoren, Shelly´s, Alexa, ASC, Gardena, E-Paper, FritzBox; (Tado° x), iBeacon, OLED ; ESP32/8266, SwitchBot ... (Netatmo & Homekit über HomeAssistant)