diff --git a/addons/check_config/index.html b/addons/check_config/index.html index 420b714b31..b96fd8f0f8 100644 --- a/addons/check_config/index.html +++ b/addons/check_config/index.html @@ -92,6 +92,7 @@
docker
to build the test addon: Available add-ons
Installing third-party add-ons
External storage
+ Execute local things
Architecture
diff --git a/hassio/addon_tutorial/index.html b/hassio/addon_tutorial/index.html
index eb5dcc407e..c3215d30a4 100644
--- a/hassio/addon_tutorial/index.html
+++ b/hassio/addon_tutorial/index.html
@@ -239,6 +239,7 @@ The Python 3 server will allow you to browse the /data folder.
Available add-ons
Installing third-party add-ons
External storage
+ Execute local things
Architecture
diff --git a/hassio/architecture/index.html b/hassio/architecture/index.html
index 10ddd25871..ec9b55ac54 100644
--- a/hassio/architecture/index.html
+++ b/hassio/architecture/index.html
@@ -99,6 +99,7 @@
Available add-ons
Installing third-party add-ons
External storage
+ Execute local things
Architecture
diff --git a/hassio/debugging/index.html b/hassio/debugging/index.html
index a7928fe48b..5541f281f0 100644
--- a/hassio/debugging/index.html
+++ b/hassio/debugging/index.html
@@ -97,6 +97,7 @@ docker logs homeassistant
Available add-ons
Installing third-party add-ons
External storage
+ Execute local things
Architecture
diff --git a/hassio/external_storage/index.html b/hassio/external_storage/index.html
index 21b35da7db..c6a3ab4a5e 100644
--- a/hassio/external_storage/index.html
+++ b/hassio/external_storage/index.html
@@ -88,6 +88,7 @@ It is also possible to create a add-on that only mount stuff to do
if OUTPUT="$(/read_my_sensor.sh)"
then
- mosquitto_pub -h "$MQTT_SERVER" -p "$MQTT_PORT" -t "$TOPIC" -m "$OUTPUT" || true
+ mosquitto_pub -h "$MQTT_SERVER" -p "$MQTT_PORT" -u "$USER" -P "$PASSWORD" -t "$TOPIC" -m "$OUTPUT" || true
else
echo "$(data) [ERROR] can't read sensor: $OUTPUT"
fi
sleep "$WAIT_TIME"
done
+
Commands
+Short story of that caption: We wait on incoming data from mqtt broker to do some things. We can also use on HomeAssistant input_boolean that trigger a automation to publish a custom command to mqtt topic they can process multible things in one add-on.
+Our Dockerfile need to install:
+RUN apk --no-cache add tzdata jq mosquitto-clients
+
+
+Now we can process it with run.sh
:
+#!/bin/bash
+set -e
+
+CONFIG_PATH=/data/options.json
+
+# possible options for processing
+MQTT_SERVER=$(jq --raw-output '.server' $CONFIG_PATH)
+MQTT_PORT=$(jq --raw-output '.port' $CONFIG_PATH)
+TOPIC=$(jq --raw-output '.topic' $CONFIG_PATH)
+USER=$(jq --raw-output '.user' $CONFIG_PATH)
+PASSWORD=$(jq --raw-output '.password' $CONFIG_PATH)
+
+# read data
+while read -r message
+do
+ if [ "$message" == "on" ]; then
+ /do_command_on.sh || true
+ else
+ /do_command_off.sh || true
+ fi
+
+done < <(mosquitto_sub -h "$MQTT_SERVER" -p "$MQTT_PORT" -u "$USER" -P "$PASSWORD" -t "$TOPIC" -q 1)
+
+
+