diff --git a/aquaponic-receiver/aquaponic-receiver.py b/aquaponic-receiver/aquaponic-receiver.py new file mode 100755 index 0000000..d5de8a2 --- /dev/null +++ b/aquaponic-receiver/aquaponic-receiver.py @@ -0,0 +1,64 @@ +import os +import paho.mqtt.client as mqtt +from influxdb_client import InfluxDBClient +from influxdb_client import Point +from influxdb_client.client.write_api import SYNCHRONOUS +import json + +import logging +logging.basicConfig(level=logging.DEBUG) +# mqttc = mqtt.Client("client-id") +# but note that the client id must be unique on the broker. Leaving the client +# id parameter empty will generate a random id for you. +mqttc = mqtt.Client() +influx_client = InfluxDBClient(url="http://localhost:8086", token="bjzIaf-hQU6eUf7-Sk9XvmjPNBG6EXuYg6iEjFhHfd2ggdqtL_5WpQxKBCRxWChB31YYXPoVrG2X0faoTZl1Eg==", org="sensors") +write_api = influx_client.write_api(write_options=SYNCHRONOUS) + +def messageReceived(client, userdata, message): + print("received topic" + str(message.topic) + "with payload:" + str(message.payload)) + message_as_json = json.loads(message.payload.decode("utf-8")) + + #extract fields from json + CmToWater = float(message_as_json["uplink_message"]["decoded_payload"]["CmToWater"]) + Temperature1 = float(message_as_json["uplink_message"]["decoded_payload"]["Temp1"]) + Temperature2 = float(message_as_json["uplink_message"]["decoded_payload"]["Temp2"]) + Temperature3 = float(message_as_json["uplink_message"]["decoded_payload"]["Temp3"]) + Temperature4 = float(message_as_json["uplink_message"]["decoded_payload"]["Temp4"]) + Temperature5 = float(message_as_json["uplink_message"]["decoded_payload"]["Temp5"]) + Temperature6 = float(message_as_json["uplink_message"]["decoded_payload"]["Temp6"]) + + Datapoint = Point("environment_measurement")\ + .field("CmToWater", CmToWater)\ + .field("Temperature1", Temperature1)\ + .field("Temperature2", Temperature2)\ + .field("Temperature3", Temperature3)\ + .field("Temperature4", Temperature4)\ + .field("Temperature5", Temperature5)\ + .field("Temperature6", Temperature6)\ + + print("writing Datapoint", Datapoint) + write_api.write("abfd776339848ad0", "cccp", Datapoint) + +def on_connect(client, userdata, flags, rc): + print("Connected with result code "+str(rc)) + + if (rc == 0): + print("(Success)") + else: + print("(Fail)") + + # Subscribing in on_connect() means that if we lose the connection and + # reconnect then subscriptions will be renewed. + client.subscribe("#", 0) + +appid = "freiland-sensors@ttn" +key = "NNSXS.LDAC6EEMEJNHGGWH44PKTWVB4VJWR7BAOS4CQJY.G7IEQBYOANUEMBGWOLL6WRC6QXYSFWJZLK2GK6J2Z6TNYFT73EEA" +devid = "board1" + +mqttc.username_pw_set(appid, key) +mqttc.on_message = messageReceived +mqttc.on_connect = on_connect +mqttc.connect("eu1.cloud.thethings.network", 1883, 60) + + +mqttc.loop_forever() diff --git a/aquaponic-receiver/aquaponic-receiver.service b/aquaponic-receiver/aquaponic-receiver.service new file mode 100644 index 0000000..4963d4d --- /dev/null +++ b/aquaponic-receiver/aquaponic-receiver.service @@ -0,0 +1,10 @@ +[Unit] +Description=Sending the aquaponic data to the influx db +After=multi-user.target + +[Service] +Type=simple +ExecStart=/usr/bin/python /usr/bin/aquaponic-receiver + +[Install] +WantedBy=multi-user.target diff --git a/co2ampel-receiver/co2ampel-receiver.py b/co2ampel-receiver/co2ampel-receiver.py new file mode 100755 index 0000000..0dbc820 --- /dev/null +++ b/co2ampel-receiver/co2ampel-receiver.py @@ -0,0 +1,64 @@ +import os +import paho.mqtt.client as mqtt +from influxdb import InfluxDBClient +import json + +import logging +logging.basicConfig(level=logging.DEBUG) +# mqttc = mqtt.Client("client-id") +# but note that the client id must be unique on the broker. Leaving the client +# id parameter empty will generate a random id for you. +mqttc = mqtt.Client() +influx_client = InfluxDBClient("localhost", 8086, "co2ampel", "55zP5S5YOS5+zQ==", "co2ampel") + +def messageReceived(client, userdata, message): + print("received topic" + str(message.topic) + "with payload: " + str(message.payload)) + sensorId = message.topic.replace("/co2ampel/","") + print("sensor id: " + sensorId) + message_as_json = json.loads(message.payload.decode("utf-8")) + insert_json = [ + { + "measurement": "measurement", + "tags": { + "sensor": sensorId, + }, + "fields": { + "ppmCO2": float(message_as_json["ppmCO2"]) + } + } + ] + optional_description = message_as_json.get("description") + if (optional_description): + insert_json[0]["fields"]["description"]=optional_description + + optional_temperature = message_as_json.get("temperatur") + if(optional_temperature): + insert_json[0]["fields"]["temperature"]=optional_temperature + + print("sending") + + print(insert_json) + if (influx_client.write_points(insert_json)): + print ("insert success") + else: + print ("insert fail") + +def on_connect(client, userdata, flags, rc): + print("Connected with result code "+str(rc)) + + if (rc == 0): + print("(Success)") + else: + print("(Fail)") + + # Subscribing in on_connect() means that if we lose the connection and + # reconnect then subscriptions will be renewed. + client.subscribe("/co2ampel/#", 0) + +mqttc.username_pw_set("knurps", "LEPEZ1ELYDUmjg") +mqttc.on_message = messageReceived +mqttc.on_connect = on_connect +mqttc.connect("ccc-p.org", 1883, 60) + + +mqttc.loop_forever() diff --git a/co2ampel-receiver/co2ampel-receiver.service b/co2ampel-receiver/co2ampel-receiver.service new file mode 100644 index 0000000..3a1210c --- /dev/null +++ b/co2ampel-receiver/co2ampel-receiver.service @@ -0,0 +1,10 @@ +[Unit] +Description=Sending co2 ampel data to the influx db +After=multi-user.target + +[Service] +Type=simple +ExecStart=/usr/bin/python /usr/bin/co2ampel-receiver + +[Install] +WantedBy=multi-user.target diff --git a/engelsystem/0001-Update-to-3.2.0.patch b/engelsystem/0001-Update-to-3.2.0.patch new file mode 100644 index 0000000..79dcb50 --- /dev/null +++ b/engelsystem/0001-Update-to-3.2.0.patch @@ -0,0 +1,34 @@ +From 61e1918adf17b9c94690c68c973dde40e5a582bf Mon Sep 17 00:00:00 2001 +From: Christoph Sterz +Date: Sun, 17 Oct 2021 22:08:49 +0200 +Subject: [PATCH] Update to 3.2.0 + +--- + PKGBUILD | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/PKGBUILD b/PKGBUILD +index d81a1c3..a10a42c 100644 +--- a/PKGBUILD ++++ b/PKGBUILD +@@ -2,7 +2,7 @@ + # Contributor: Ruben Kelevra + + pkgname=engelsystem +-pkgver=3.1.0 ++pkgver=3.2.0 + _dl_pkgver="v$pkgver" + pkgrel=1 + pkgdesc='tool for coordinating helpers and shifts on large events' +@@ -18,7 +18,7 @@ backup=(usr/share/webapps/engelsystem/config/config.php) + install='engelsystem.install' + source=("${pkgname}-${pkgver}.tar.gz::${_download_url_base}/archive/${_dl_pkgver}.tar.gz" + 'engelsystem.install') +-sha512sums=('12f931994d9ab73ffe6926228709f9774a80e11a14ad7cc64b99d4a6d68b03c897dd196e1ac3226aac91a1f755bfcd0af07700a0bb9f07e3b0aa6fdd262fdf8b' ++sha512sums=('8388121086127ba9b4f703b0b5f642d4fedeb3ac4f8643611d03a61047f095aa49f878f2a9180cc8b1529d8e7c87de78ac23a6d915fbdf0d90a0a37b4cba89e6' + 'SKIP' + ) + # validpgpkeys=('SKIP') # version 3.0.0 is not signed on github +-- +2.33.0 + diff --git a/engelsystem/engelsystem.install b/engelsystem/engelsystem.install new file mode 100644 index 0000000..00f06e2 --- /dev/null +++ b/engelsystem/engelsystem.install @@ -0,0 +1,22 @@ +post_install() { + echo "enabling the pdo_pgsql module in PHP" + sed -i -e 's/;extension=pdo_pgsql/extension=pdo_pgsql/' /etc/php/php.ini + + install -dm775 /usr/share/webapps/engelsystem/import + chown http:http /usr/share/webapps/engelsystem/import + install -dm775 /usr/share/webapps/engelsystem/storage + chown http:http /usr/share/webapps/engelsystem/storage +} + +pre_remove() { + cp -r /usr/share/webapps/engelsystem /usr/share/webapps/engelsystem_backup + echo 'Your Engelsystem folder was backed up to /usr/share/webapps/engelsystem_backup' +} + +post_remove() { + rm -rf /usr/share/webapps/engelsystem +} + +post_upgrade() { + echo 'Engelsystem was placed in /usr/share/webapps' +} diff --git a/freilandsolar/PKGBUILD b/freilandsolar/PKGBUILD deleted file mode 100644 index c898a69..0000000 --- a/freilandsolar/PKGBUILD +++ /dev/null @@ -1,16 +0,0 @@ -pkgname="freiland-solardata-forwarder" -pkgdesc="Copies Data from FreilandSolar to Opensensemap" -pkgver=1.1 -pkgrel=2 -arch=("x86_64") -source=('solar-forwarder.py' 'solar-forwarder.service') -depends=('python-paho-mqtt' 'python-requests' 'python') - -package() { - cd "$srcdir" - install -Dm644 solar-forwarder.service "${pkgdir}/usr/lib/systemd/system/solar-forwarder.service" - install -Dm755 solar-forwarder.py "${pkgdir}/usr/bin/solar-forwarder" -} - -sha256sums=('6ffe957f54897c1e0b45d0b76d68aedb4b1ce4905274e196e5538a02109e4e3a' - '481243ff3c4ff019c3d31c1b6dbd8d70308402efef5a5b22f7b21b08312bc70c') diff --git a/machbarschalter-signal-bot/machbarschalter-signal-bot.service b/machbarschalter-signal-bot/machbarschalter-signal-bot.service new file mode 100644 index 0000000..c7968a8 --- /dev/null +++ b/machbarschalter-signal-bot/machbarschalter-signal-bot.service @@ -0,0 +1,10 @@ +[Unit] +Description=Sending the MachbarSchalter status into a Signal group +After=multi-user.target + +[Service] +Type=simple +ExecStart=/usr/bin/python /usr/bin/schalter_listener + +[Install] +WantedBy=multi-user.target diff --git a/machbarschalter-signal-bot/schalter_listener.py b/machbarschalter-signal-bot/schalter_listener.py new file mode 100755 index 0000000..700ca02 --- /dev/null +++ b/machbarschalter-signal-bot/schalter_listener.py @@ -0,0 +1,34 @@ +import os +import paho.mqtt.client as mqtt + +import logging +logging.basicConfig(level=logging.DEBUG) + +# If you want to use a specific client id, use +# mqttc = mqtt.Client("client-id") +# but note that the client id must be unique on the broker. Leaving the client +# id parameter empty will generate a random id for you. +mqttc = mqtt.Client() +lastmessage = "" + +def onConnect(client, userdata, flags, rc): + print("Connected with result code "+str(rc)) + mqttc.subscribe("/sensors/spaceschalter/status", 0) + +def messageReceived(client, userdata, message): + print("received topic" + str(message.topic) + "with payload:" + str(message.payload)) + global lastmessage + if (str(message.payload) == lastmessage): + print("already got message " + lastmessage + ", skipping.") + return + lastmessage = str(message.payload) + print("sending Message via signal…") + os.system("signal-cli --config /home/christoph/.local/share/signal-cli/ -u +491639709611 send -m \"Machbar: %s\" -g 4itR+98YIW1Xc4BJwKKoew==" % message.payload.decode("utf-8")) + +mqttc.username_pw_set("christoph","dNppWZ2nukh+RQ") + +mqttc.on_message = messageReceived +mqttc.on_connect = onConnect +mqttc.connect("ccc-p.org", 1883, 60) + +mqttc.loop_forever() diff --git a/schreiomat-receiver/queryschreiomat.sh b/schreiomat-receiver/queryschreiomat.sh new file mode 100755 index 0000000..26a6555 --- /dev/null +++ b/schreiomat-receiver/queryschreiomat.sh @@ -0,0 +1,3 @@ +#!/usr/bin/bash + + influx query 'from(bucket:"schreiomat") |> range(start:-1h)' diff --git a/schreiomat-receiver/schreiomat-receiver.py b/schreiomat-receiver/schreiomat-receiver.py new file mode 100755 index 0000000..e30104f --- /dev/null +++ b/schreiomat-receiver/schreiomat-receiver.py @@ -0,0 +1,44 @@ +import os +import paho.mqtt.client as mqtt +from influxdb_client import InfluxDBClient +from influxdb_client import Point +from influxdb_client.client.write_api import SYNCHRONOUS +import json + +import logging +logging.basicConfig(level=logging.DEBUG) +# mqttc = mqtt.Client("client-id") +# but note that the client id must be unique on the broker. Leaving the client +# id parameter empty will generate a random id for you. +mqttc = mqtt.Client() +influx_client = InfluxDBClient(url="http://localhost:8086", token="7KIKWL-7REcvJzNnDHKmvTDWqtJ_vflOfDXwncM78SI80xLEo2aXrjiLspCxPhVTiWFn4V6VWfAqedaxLJX9nQ==", org="sensors") +write_api = influx_client.write_api(write_options=SYNCHRONOUS) + +def messageReceived(client, userdata, message): + print("received topic" + str(message.topic) + "with payload: " + str(message.payload) + "\n") + sensorId = message.topic.replace("schreiomat/","") + print("sensor id: " + sensorId) + + print("sending") + result = "" + write_api.write("dac77b8b5d0fd121", "sensors", Point("soundlevel").tag("sensor", sensorId).field("dbA", float(message.payload))) + +def on_connect(client, userdata, flags, rc): + print("Connected with result code "+str(rc)) + + if (rc == 0): + print("(Success)") + else: + print("(Fail)") + + # Subscribing in on_connect() means that if we lose the connection and + # reconnect then subscriptions will be renewed. + client.subscribe("schreiomat/#", 0) + +mqttc.username_pw_set("knurps", "LEPEZ1ELYDUmjg") +mqttc.on_message = messageReceived +mqttc.on_connect = on_connect +mqttc.connect("ccc-p.org", 1883, 60) + + +mqttc.loop_forever() diff --git a/schreiomat-receiver/schreiomat-receiver.service b/schreiomat-receiver/schreiomat-receiver.service new file mode 100644 index 0000000..383dd0e --- /dev/null +++ b/schreiomat-receiver/schreiomat-receiver.service @@ -0,0 +1,12 @@ +[Unit] +Description=Sending the noise data to the influx db +After=multi-user.target + +[Service] +Type=simple +ExecStart=/usr/bin/python /usr/bin/schreiomat-receiver +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target