Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
ba2946706b | |||
80573055d9 | |||
1941698a52 |
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
VERSION=3.3.0
|
||||
VERSION=$(grep -oP '(?<=Version: ).*$' debian/DEBIAN/control)
|
||||
dpkg-deb --root-owner-group -b debian "foodoord_${VERSION}_all.deb"
|
||||
|
4
debian/DEBIAN/control
vendored
4
debian/DEBIAN/control
vendored
@ -1,6 +1,6 @@
|
||||
Package: foodoord
|
||||
Version: 3.3.0
|
||||
Maintainer: Bandie <bandie@chaospott.de>, Tobi <tobi@chaospott.de>
|
||||
Version: 3.3.3
|
||||
Maintainer: Tobi <tobi@chaospott.de>
|
||||
Architecture: all
|
||||
Description: Control the doors of the club, ja!
|
||||
Depends: dash, git, python3, pip, tmux
|
||||
|
5
debian/DEBIAN/postinst
vendored
5
debian/DEBIAN/postinst
vendored
@ -26,8 +26,9 @@ while [ "$prompt" != "oben" ] && [ "$prompt" != "unten" ]; do
|
||||
done
|
||||
echo "##################"
|
||||
|
||||
echo "Installing dependencies via pip: pifacecommon pifacedigitalio"
|
||||
pip install pifacecommon pifacedigitalio paho-mqtt
|
||||
PIP_DEP=(pifacecommon pifacedigitalio paho-mqtt)
|
||||
echo "Installing dependencies via pip: ${PIP_DEP[*]}"
|
||||
pip install "${PIP_DEP[@]}"
|
||||
|
||||
echo "Enabling and starting systemd-Services"
|
||||
systemctl daemon-reload
|
||||
|
4
debian/usr/sbin/foodoor-update-keydb
vendored
4
debian/usr/sbin/foodoor-update-keydb
vendored
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
||||
@ -8,7 +8,7 @@ temp_outfile=$dest.tmp
|
||||
|
||||
if [ ! -e "$dest/.git/config" ]; then
|
||||
#echo "Repo does not exist, trying to clone..."
|
||||
git -C "$dest" clone --quiet --single-branch --depth=1 ssh://git.chaospott.de/Keyverwaltung/foodoor-keys.git "$dest"
|
||||
git clone --quiet --single-branch --depth=1 ssh://git.chaospott.de/Keyverwaltung/foodoor-keys.git "$dest"
|
||||
else
|
||||
#echo "Repo exists, updating..."
|
||||
git -C "$dest" fetch --quiet && git -C "$dest" merge --quiet origin/master master
|
||||
|
22
debian/usr/sbin/foodoord_oben
vendored
22
debian/usr/sbin/foodoord_oben
vendored
@ -24,6 +24,7 @@ class FoodoorMQTT:
|
||||
self.client.on_connect = self.on_connect
|
||||
self.client.on_message = self.on_message
|
||||
|
||||
self._last_state = None
|
||||
self._connect_lock = threading.Condition()
|
||||
|
||||
def connect(self):
|
||||
@ -39,6 +40,8 @@ class FoodoorMQTT:
|
||||
self.client.loop_stop()
|
||||
|
||||
def on_connect(self, client, userdata, flags, rc):
|
||||
if self._last_state is not None:
|
||||
self.send_state(self._last_state)
|
||||
with self._connect_lock:
|
||||
self._connect_lock.notify()
|
||||
|
||||
@ -46,6 +49,7 @@ class FoodoorMQTT:
|
||||
print(f"MQTT-Server Message: {msg.topic} {msg.payload}")
|
||||
|
||||
def send_state(self, locked: bool):
|
||||
self._last_state = locked
|
||||
self.client.publish(f"foobar/{self.area}/foodoor/status", {
|
||||
False: "open",
|
||||
True: "closed",
|
||||
@ -108,6 +112,7 @@ class Foodoord:
|
||||
self.status_open = False
|
||||
self.mqtt = FoodoorMQTT("oben")
|
||||
|
||||
self.pifacedigital = pifacedigitalio.PiFaceDigital()
|
||||
self.listener = pifacedigitalio.InputEventListener()
|
||||
self.listener.register(self.DOOR_BELL, pifacedigitalio.IODIR_RISING_EDGE, self.doorbell, settle_time=10)
|
||||
self.listener.register(self.CLOSE_BUTTON, pifacedigitalio.IODIR_RISING_EDGE, self.close_button, settle_time=5)
|
||||
@ -137,15 +142,15 @@ class Foodoord:
|
||||
def set_led(self, color):
|
||||
for led, gpio in self.LEDS.items():
|
||||
if color & led:
|
||||
pifacedigital.leds[gpio].turn_on()
|
||||
self.pifacedigital.leds[gpio].turn_on()
|
||||
else:
|
||||
pifacedigital.leds[gpio].turn_off()
|
||||
self.pifacedigital.leds[gpio].turn_off()
|
||||
|
||||
def doorbell(self, event):
|
||||
if self.status_open:
|
||||
pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
self.pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
time.sleep(2)
|
||||
pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
self.pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
|
||||
def close_button(self, _event):
|
||||
self.status_open = False
|
||||
@ -156,7 +161,6 @@ class Foodoord:
|
||||
self.mqtt.connect()
|
||||
self.listener.activate()
|
||||
|
||||
pifacedigital = pifacedigitalio.PiFaceDigital()
|
||||
signal.signal(signal.SIGTERM, self.signal_handler)
|
||||
|
||||
# Start settings
|
||||
@ -176,18 +180,18 @@ class Foodoord:
|
||||
pipe_cmd = ssh_input.readline().strip()
|
||||
|
||||
if pipe_cmd == "close" and self.status_open:
|
||||
pifacedigital.relays[self.RELAYS_LOCK].toggle()
|
||||
self.pifacedigital.relays[self.RELAYS_LOCK].toggle()
|
||||
time.sleep(1)
|
||||
pifacedigital.relays[self.RELAYS_LOCK].toggle()
|
||||
self.pifacedigital.relays[self.RELAYS_LOCK].toggle()
|
||||
|
||||
self.status_open = False
|
||||
self.update_api(True)
|
||||
self.set_led(self.RED)
|
||||
|
||||
elif pipe_cmd == "open":
|
||||
pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
self.pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
time.sleep(2)
|
||||
pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
self.pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
|
||||
|
||||
if not self.status_open:
|
||||
self.update_api(False)
|
||||
|
4
debian/usr/sbin/foodoord_unten
vendored
4
debian/usr/sbin/foodoord_unten
vendored
@ -22,6 +22,7 @@ class FoodoorMQTT:
|
||||
self.client.on_connect = self.on_connect
|
||||
self.client.on_message = self.on_message
|
||||
|
||||
self._last_state = None
|
||||
self._connect_lock = threading.Condition()
|
||||
|
||||
def connect(self):
|
||||
@ -37,6 +38,8 @@ class FoodoorMQTT:
|
||||
self.client.loop_stop()
|
||||
|
||||
def on_connect(self, client, userdata, flags, rc):
|
||||
if self._last_state is not None:
|
||||
self.send_state(self._last_state)
|
||||
with self._connect_lock:
|
||||
self._connect_lock.notify()
|
||||
|
||||
@ -44,6 +47,7 @@ class FoodoorMQTT:
|
||||
print(f"MQTT-Server Message: {msg.topic} {msg.payload}")
|
||||
|
||||
def send_state(self, locked: bool):
|
||||
self._last_state = locked
|
||||
self.client.publish(f"foobar/{self.area}/foodoor/status", {
|
||||
False: "open",
|
||||
True: "closed",
|
||||
|
Reference in New Issue
Block a user