summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormm-chen <github@malte-modler.de>2018-04-09 21:29:04 +0200
committerSebastian Reichel <sre@ring0.de>2018-06-28 01:52:53 +0200
commit764c39f4facfe42d926cd952dcf0f7e2768097a8 (patch)
tree0c08a3808c056169117f1937e79fb403515ae0b3
parentab2ea719ee4a86e082f8d205c1d33a048e1cfe57 (diff)
downloadserial-barcode-scanner-764c39f4facfe42d926cd952dcf0f7e2768097a8.tar.bz2
Display on/off
Turns the display off and on via MQTT
-rw-r--r--README.md4
-rw-r--r--example.cfg5
-rwxr-xr-xsrc/display-on-off/display-on-off.sh26
-rw-r--r--systemd/shopsystem-display-on-off.service12
4 files changed, 47 insertions, 0 deletions
diff --git a/README.md b/README.md
index 830ae5b..9a0dbf6 100644
--- a/README.md
+++ b/README.md
@@ -84,6 +84,10 @@ but you need to modify a few things.
`sqlite3 shop.db "INSERT INTO categories (name) VALUES ('Getränke')";`
`sqlite3 shop.db "INSERT INTO supplier (name,city,postal_code,street,phone,website) VALUES ('Demo Lieferant','Musterstadt','12345','Musterstraße 5','+49 1234 56789','https://www.ktt.de');"`
+=== Display on / off via MQTT ===
+
+You can control display power via MQTT by configuring the MQTT settings (i.e. BROKER, TOPIC) in the config file.
+
== Customize Your Shop ==
Edit the Logo in the logo.txt File.
diff --git a/example.cfg b/example.cfg
index 27172b1..65056d8 100644
--- a/example.cfg
+++ b/example.cfg
@@ -32,3 +32,8 @@ footer2 = <b>Raiffeisenbank Oldenburg</b>\nIBAN: DE34 2806 0228 0037 0185 00\nBI
footer3 = <b>Mail:</b> vorstand@kreativitaet-trifft-technik.de\n<b>Web:</b> www.kreativitaet-trifft-technik.de\n\n\n\n<b>BGB-Vorstand:</b>\nPatrick Günther, Jan Janssen, Andre Schäfer, Lars Hüsemann
[JVEREIN]
membership_number = intern
+[MQTT]
+broker = mqtt.server.exaple.com
+topic = /exaple/topic
+displayOn = open
+displayOff = close
diff --git a/src/display-on-off/display-on-off.sh b/src/display-on-off/display-on-off.sh
new file mode 100755
index 0000000..23ab10a
--- /dev/null
+++ b/src/display-on-off/display-on-off.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+function getMqttConfig
+{
+ echo `busctl --system call io.mainframe.shopsystem.Config /io/mainframe/shopsystem/config io.mainframe.shopsystem.Config GetString ss MQTT $1 | sed -s "s;s ;;"`
+}
+
+BROKER=$(getMqttConfig broker)
+TOPIC=$(getMqttConfig topic)
+ON=$(getMqttConfig displayOn)
+OFF=$(getMqttConfig displayOff)
+
+mosquitto_sub -h $BROKER -t $TOPIC | while read RAW_DATA
+do
+ case $RAW_DATA in
+ $ON)
+ vbetool dpms on
+ ;;
+ $OFF)
+ vbetool dpms off
+ ;;
+ *)
+ #vbetool dpms on
+ ;;
+ esac
+done
diff --git a/systemd/shopsystem-display-on-off.service b/systemd/shopsystem-display-on-off.service
new file mode 100644
index 0000000..dfa6f0c
--- /dev/null
+++ b/systemd/shopsystem-display-on-off.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Display on-off via MQTT
+After=systemd-user-sessions.service
+
+[Service]
+Type=simple
+ExecStart=/home/shop/serial-barcode-scanner/src/display-on-off/display-on-off.sh
+Restart=always
+RestartSec=10
+
+[Install]
+WantedBy=multi-user.target