Compare commits

...

4 Commits

Author SHA1 Message Date
Sven Koehler
bab90fe4d1 fix plzidx issues, include bulma and systemd unit 2024-01-18 14:55:26 +01:00
Sven Koehler
9d406e5f92 Ignore some build files 2024-01-16 22:18:31 +01:00
Sven Koehler
153802bf94 make freilandsolar a submodule 2024-01-16 22:12:47 +01:00
Sven Koehler
7b1fe5f7fd Copy over other files from christoph 2024-01-16 22:10:54 +01:00
21 changed files with 406 additions and 18 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*.pkg.tar.zst
*/pkg/*
*/src/*

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "freilandsolar"]
path = freilandsolar
url = gitea@git.ccc-p.org:christoph/freilandsolar.git

View File

@@ -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()

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -0,0 +1,34 @@
From 61e1918adf17b9c94690c68c973dde40e5a582bf Mon Sep 17 00:00:00 2001
From: Christoph Sterz <christoph.sterz@kdab.com>
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 <ruben+aur-engelsystem@vfn-nrw.de>
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

View File

@@ -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'
}

1
freilandsolar Submodule

Submodule freilandsolar added at b71ab734b7

View File

@@ -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')

1
hedgedoc-tag-searcher/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
hedgedoc-tag-searcher/

View File

@@ -0,0 +1,58 @@
From 2ab6f47039d4bd8c35794e388cc862c3bccb6bc5 Mon Sep 17 00:00:00 2001
From: Sven Koehler <git@svenkoehler.de>
Date: Tue, 16 Jan 2024 23:45:17 +0100
Subject: [PATCH 34/34] Drop mapped_columns (sqlachemy 2.0 feature)
---
plzidx/db.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/plzidx/db.py b/plzidx/db.py
index 8fe86e2..22c084e 100644
--- a/plzidx/db.py
+++ b/plzidx/db.py
@@ -1,7 +1,7 @@
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Table, ForeignKeyConstraint, func
from typing import List
-from sqlalchemy.orm import declarative_base, mapped_column, relationship, Mapped
+from sqlalchemy.orm import declarative_base, relationship
import datetime
@@ -29,10 +29,10 @@ association_table = Table(
class Tag(db.Model):
__tablename__ = 'tag'
- id: Mapped[int] = mapped_column(Integer, primary_key=True)
- text: Mapped[str] = mapped_column(String, unique=True, nullable=False)
+ id = Column(Integer, primary_key=True)
+ text = Column(String, unique=True, nullable=False)
- pads: Mapped[List['Pad']] = relationship('Pad', secondary=association_table, back_populates='tags')
+ pads = relationship('Pad', secondary=association_table, back_populates='tags')
def __repr__(self):
return f'<Tag text={self.text}>'
@@ -85,13 +85,13 @@ class Tag(db.Model):
class Pad(db.Model):
__tablename__ = 'pad'
- uuid: Mapped[str] = mapped_column(String, primary_key=True, nullable=False)
- updatedAt: Mapped[datetime.datetime] = mapped_column(DateTime, nullable=False)
+ uuid = Column(String, primary_key=True, nullable=False)
+ updatedAt = Column(DateTime, nullable=False)
- title: Mapped[str] = mapped_column(String)
- url: Mapped[str] = mapped_column(String, nullable=False)
+ title = Column(String)
+ url = Column(String, nullable=False)
- tags: Mapped[List['Tag']] = relationship('Tag', secondary=association_table, back_populates='pads')
+ tags = relationship('Tag', secondary=association_table, back_populates='pads')
def __repr__(self):
return f'<Pad uuid={self.uuid}, updatedAt={self.updatedAt}>'
--
2.37.1 (Apple Git-137.1)

View File

@@ -2,16 +2,27 @@ pkgname=hedgedoc-tag-searcher
pkgver=0.01 pkgver=0.01
pkgrel=1 pkgrel=1
pkgdesc="Global search for Hedgedoc pads by tags" pkgdesc="Global search for Hedgedoc pads by tags"
source=('hedgedoc-tag-searcher::git+https://github.com/Chaostreff-Potsdam/hedgedoc-tag-searcher.git#tag=v0.01') source=('hedgedoc-tag-searcher::git+https://github.com/Chaostreff-Potsdam/hedgedoc-tag-searcher.git#tag=v0.01' '0001-downgrade-to-sqlalchmy-1.4.patch' 'bulma.min.css' 'plzidx.service')
md5sums=('SKIP') sha512sums=('SKIP'
'84bcc457d18d9a6bc4178dbfaf267f9ef931ca753698648439db5776815c17dcb8daa363064842d305afbebd4639a93ecc094bf0427450affe598d1c8981576f'
'1eac4752424cd1261c6efc54c393fad12cdd393cbf415c00d4926bbda5c9bf8abb9666c36429996aacf4d543ce690bdea317d846fd6d1e8cd618f31cb9306ebd'
'2dacde841246faff873c8beac4c34a88d7385dba61aec8deae43ab23e6a4124780140c6cbf686ad250bf925f90cd53481f1a4da3fb1fb50389d5c3de213ca89e'
)
arch=("any") arch=("any")
license=("MIT") license=("MIT")
makedepends=("git" "python-build" "python-installer" "python-wheel") makedepends=("git" "python-build" "python-installer" "python-wheel")
depends=("python>=3" "python-flask" "python-flask-sqlalchemy" "python-pyaml" "python-dotenv" "python-psycopg2") depends=("python>=3" "python-flask" "python-flask-sqlalchemy" "python-pyaml" "python-dotenv" "python-psycopg2")
prepare() {
cd "$srcdir/$pkgname/"
patch --forward --strip=1 --input="${srcdir}/0001-downgrade-to-sqlalchmy-1.4.patch"
cp "${srcdir}/bulma.min.css" "plzidx/static/css/bulma.min.css"
}
build() { build() {
cd "$srcdir/$pkgname/" cd "$srcdir/$pkgname/"
python -m build --wheel --no-isolation python -m build --wheel --no-isolation
} }
@@ -20,4 +31,8 @@ package() {
python -m installer --destdir="$pkgdir" dist/*.whl python -m installer --destdir="$pkgdir" dist/*.whl
mkdir -p "$pkgdir/etc/webapps/$pkgname/" mkdir -p "$pkgdir/etc/webapps/$pkgname/"
mkdir -p "$pkgdir/usr/var/plzidx-instance/"
ln -s "/etc/webapps/$pkgname/config.py" "$pkgdir/usr/var/plzidx-instance/config.py"
install -Dm644 "${srcdir}/plzidx.service" "${pkgdir}/usr/lib/systemd/system/plzidx.service"
} }

1
hedgedoc-tag-searcher/bulma.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Gunicorn instance to serve hedgedoc-tag-searcher
After=network.target
[Service]
RuntimeDirectory=plzidx
RuntimeDirectoryMode=755
User=plzidx
Group=plzidx
ExecStart=/usr/bin/gunicorn --workers 1 --bind unix:/run/plzidx/plzidx.sock -u plzidx -g plzidx 'plzidx:create_app()'
[Install]
WantedBy=multi-user.target

View File

@@ -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

View File

@@ -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()

1
mddns/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
mddns/

View File

@@ -0,0 +1,3 @@
#!/usr/bin/bash
influx query 'from(bucket:"schreiomat") |> range(start:-1h)'

View File

@@ -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()

View File

@@ -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