diff --git a/config.yaml b/config.yaml index 1793b3c..c85370e 100644 --- a/config.yaml +++ b/config.yaml @@ -4,7 +4,7 @@ version: "1.0.1" slug: "orb_homeassistant" init: false host_network: true -image: "orbforge/orb" +image: "orbforge/orb-ha" environment: ORB_DATA_DIR: /data arch: @@ -14,3 +14,9 @@ arch: boot: auto services: - mqtt:need +options: + mqtt_push: false + mqtt_frequency: 5 +schema: + mqtt_push: bool + mqtt_frequency: int(1,120) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 9817016..7662841 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -6,7 +6,16 @@ echo "Starting MQTT publishing script..." date # Start MQTT publishing in the background -/app/mqtt.sh & +CONFIG_PATH=/data/options.json +MQTT_PUSH=$(jq -r '.mqtt_push // false' $CONFIG_PATH) + +if [ "$MQTT_PUSH" == "true" ]; then + echo "MQTT Push is enabled" + /app/mqtt.sh & +else + echo "MQTT Push is disabled" +fi + # Now start the original entrypoint or command exec /app/orb sensor diff --git a/docker/mqtt.sh b/docker/mqtt.sh index d02e0de..980ea86 100644 --- a/docker/mqtt.sh +++ b/docker/mqtt.sh @@ -10,6 +10,9 @@ MQTT_PORT=$(echo "$MQTT_INFO" | jq -r '.data.port') MQTT_USER=$(echo "$MQTT_INFO" | jq -r '.data.username') MQTT_PASS=$(echo "$MQTT_INFO" | jq -r '.data.password') +CONFIG_PATH=/data/options.json +MQTT_PAUSE=$(jq -r '.mqtt_frequency // 5' $CONFIG_PATH) + echo "MQTT Host: $MQTT_HOST" echo "MQTT Port: $MQTT_PORT" echo "MQTT User: $MQTT_USER" @@ -82,5 +85,5 @@ while true; do mosquitto_pub -h "$MQTT_HOST" -p "$MQTT_PORT" -u "$MQTT_USER" -P "$MQTT_PASS" \ -t "$STATE_TOPIC" -m "$ORB_OUTPUT" -r - sleep 15 + sleep "$MQTT_PAUSE" done diff --git a/translations/en.yaml b/translations/en.yaml new file mode 100644 index 0000000..f699616 --- /dev/null +++ b/translations/en.yaml @@ -0,0 +1,11 @@ +--- +configuration: + mqtt_push: + name: Push Scores to MQTT + description: >- + If set to `true`, the Orb will push scores to the MQTT broker. + mqtt_frequency: + name: MQTT Frequency + description: >- + The frequency in seconds at which the Orb will push scores to the MQTT + broker.