From 764c39f4facfe42d926cd952dcf0f7e2768097a8 Mon Sep 17 00:00:00 2001 From: mm-chen Date: Mon, 9 Apr 2018 21:29:04 +0200 Subject: Display on/off Turns the display off and on via MQTT --- README.md | 4 ++++ example.cfg | 5 +++++ src/display-on-off/display-on-off.sh | 26 ++++++++++++++++++++++++++ systemd/shopsystem-display-on-off.service | 12 ++++++++++++ 4 files changed, 47 insertions(+) create mode 100755 src/display-on-off/display-on-off.sh create mode 100644 systemd/shopsystem-display-on-off.service 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 = Raiffeisenbank Oldenburg\nIBAN: DE34 2806 0228 0037 0185 00\nBI footer3 = Mail: vorstand@kreativitaet-trifft-technik.de\nWeb: www.kreativitaet-trifft-technik.de\n\n\n\nBGB-Vorstand:\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 -- cgit v1.2.3