Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Last active August 14, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-minguez/6b0d97934faa9c905a187edef0b5ac97 to your computer and use it in GitHub Desktop.
Save e-minguez/6b0d97934faa9c905a187edef0b5ac97 to your computer and use it in GitHub Desktop.
rding temper in freebsd jail to mqtt to homeassistant
#!/bin/csh
set MQTT_HOST="192.168.1.2"
set MQTT_ID="n54l"
set MQTT_TOPIC="n54l/input/temp"
set MQTT_OPTIONS="-V mqttv311"
# Raw message to MQTT
set tempraw=`sysctl -n dev.ugold.0.sensors.inner`
set temp=`echo "scale=2; $tempraw / 1000000" | bc`
mosquitto_pub -h ${MQTT_HOST} -i ${MQTT_ID} -t ${MQTT_TOPIC} ${MQTT_OPTIONS} -m $temp
# Install mosquitto_pub as:
# pkg upgrade
# pkg install mosquitto
# Set a cron task in FreeNAS GUI as
# usbconfig -d `usbconfig | awk -F: '/TEMP/ { print $1 }'` power_on && sleep 3 && jexec mqtt /root/temp.csh && usbconfig -d `usbconfig | awk -F: '/TEMP/ { print $1 }'` power_off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment