Browse Source

Verison bump + add serial port

Joachim M. Giæver 3 years ago
parent
commit
eadcbe0de8
3 changed files with 22 additions and 4 deletions
  1. 3 1
      snap/snapcraft.yaml
  2. 2 0
      src/helper/env-wrapper
  3. 17 3
      src/helper/functions

+ 3 - 1
snap/snapcraft.yaml

@@ -1,6 +1,6 @@
 name: zwavejs2mqtt
 base: core20
-version: 'v3.5.0'
+version: 'v4.0.1'
 summary: Fully configurable Zwave to MQTT Gateway and Control Panel. 
 description: |
   - Configurable Zwave to Mqtt Gateway
@@ -38,6 +38,7 @@ apps:
       - network
       - network-bind
       - raw-usb
+      - serial-port
       - hardware-observe
   exec:
     environment:
@@ -49,6 +50,7 @@ apps:
       - network
       - network-bind
       - raw-usb
+      - serial-port
       - hardware-observe
   help:
     command: helper/env-wrapper --help

+ 2 - 0
src/helper/env-wrapper

@@ -52,6 +52,8 @@ if [ ${OPT_HELP} = true ]; then
     echo "- server.host: IP address to bind to, e.g 127.0.0.1"
     echo "- server.port: Port to reach the web interface"
     echo ""
+    echo "Session configuration values: $(snapctl get session -d)"
+    echo ""
     echo "Set options with:         $ snap set ${SNAP_NAME} param=key"
     echo "For example:              $ snap set ${SNAP_NAME} server.host=0.0.0.0"
     echo ""

+ 17 - 3
src/helper/functions

@@ -24,7 +24,7 @@ function same_network_key {
 function plug_connected {
     if ! snapctl is-connected "${1}"; then
         echo "Missing plug: «${1}»" >&2
-        echo "Install with:"
+        echo "Connect with:"
         echo "$ sudo snap connect ${SNAP_NAME}:${1}"
         return 1
     fi
@@ -34,9 +34,23 @@ function plug_connected {
 function plugs_connected {
     MISSING=0
 
-    plug_connected "raw-usb"
-    if [ $? -ne 0 ]; then
+    RAW_OUT=$(plug_connected "raw-usb")
+    RAW_RES=$?
+
+    SERIAL_OUT=$(plug_connected "serial-port")
+    SERIAL_RES=$?
+
+    if [ $RAW_RES -ne 0 -a $SERIAL_RES -ne 0 ]; then
+        echo $RAW_OUT
+        echo "----- OR -----"
+        echo $SERIAL_OUT
         MISSING=1
+    elif [ $RAW_RES -ne 0 ]; then
+        echo "OPTIONAL plug:"
+        echo $RAW_OUT
+    elif [ $SERIAL_RES -ne 0 ]; then
+        echo "OPTIONAL plug"
+        echo $SERIAL_OUT
     fi
 
     plug_connected "hardware-observe"