Last active
August 14, 2018 11:01
-
-
Save e-minguez/6b0d97934faa9c905a187edef0b5ac97 to your computer and use it in GitHub Desktop.
rding temper in freebsd jail to mqtt to homeassistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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