Skip to content

Instantly share code, notes, and snippets.

@njh
Created January 25, 2016 21:26
Show Gist options
  • Save njh/7126c66255edde91bdb5 to your computer and use it in GitHub Desktop.
Save njh/7126c66255edde91bdb5 to your computer and use it in GitHub Desktop.
Publish temperatures from owfs server to MQTT / collectd
#!/bin/bash
publish_owfs_mqtt () {
temperature=$(owget $1/temperature)
stripped=${temperature//[[:blank:]]/}
timestamp=$(date +%s)
mosquitto_pub \
--host "mqtt.aelius.co.uk" \
--topic "node-red/star.aelius.co.uk/mqtt/temperature-$2" \
--message "$timestamp:$stripped" \
--retain \
--qos 1
}
publish_owfs_mqtt "28.306D9C030000" "pond"
publish_owfs_mqtt "28.AE6108030000" "shed"
publish_owfs_mqtt "28.537FEE020000" "outside"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment