Skip to content

Commit

Permalink
Manual MQTT
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbelgium committed Jul 14, 2024
1 parent d129f61 commit 2f12a0d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions birdnet-pi/rootfs/etc/cont-init.d/33-mqtt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,23 @@ if bashio::services.available 'mqtt' && ! bashio::config.true 'MQTT_DISABLED' ;
cp /helpers/birdnet_to_mqtt.sh /custom-services.d
chmod 777 /usr/bin/birdnet_to_mqtt.py
chmod 777 /custom-services.d/birdnet_to_mqtt.sh
elif bashio::config.has_value "MQTT_HOST_manual" && bashio::config.has_value "MQTT_PORT_manual" && bashio::config.has_value "MQTT_USER_manual" && bashio::config.has_value "MQTT_PASSWORD_manual"; then
bashio::log.green "---"
bashio::log.blue "MQTT is manually configured in the addon options"
bashio::log.green "---"
bashio::log.blue "Data will be posted to the topic : 'birdnet'"
bashio::log.blue "Json data : {'Date', 'Time', 'ScientificName', 'CommonName', 'Confidence', 'SpeciesCode', 'ClipName', 'url'}"
bashio::log.blue "---"

# Apply MQTT settings
sed -i "s|%%mqtt_server%%|$(bashio::config "MQTT_HOST_manual")|g" /helpers/birdnet_to_mqtt.py
sed -i "s|%%mqtt_port%%|$(bashio::config "MQTT_PORT_manual")|g" /helpers/birdnet_to_mqtt.py
sed -i "s|%%mqtt_user%%|$(bashio::config "MQTT_USER_manual")|g" /helpers/birdnet_to_mqtt.py
sed -i "s|%%mqtt_pass%%|$(bashio::config "MQTT_PASSWORD_manual")|g" /helpers/birdnet_to_mqtt.py

# Copy script
cp /helpers/birdnet_to_mqtt.py /usr/bin/birdnet_to_mqtt.py
cp /helpers/birdnet_to_mqtt.sh /custom-services.d
chmod 777 /usr/bin/birdnet_to_mqtt.py
chmod 777 /custom-services.d/birdnet_to_mqtt.sh
fi

0 comments on commit 2f12a0d

Please sign in to comment.