Ok this script should work.
Code: Select all
#!/bin/sh
STATE=-1
while true
do
NEWSTATE=`curl -Nks http://localhost/happ_thermstat?action=getThermostatInfo | sed 's/.*"burnerInfo":"\([0-9]\)".*/\1/'`
if [ $NEWSTATE -eq 2 ]
then
# burning for hot water, do not start fans
NEWSTATE=0
fi
if [ $NEWSTATE -eq 3 ]
then
# toon is in preheating state, turn on fans also
NEWSTATE=1
fi
if [ "$STATE" -ne "$NEWSTATE" ]
then
STATE=$NEWSTATE
RESULT=`curl -Nks "http://192.168.1.138/control?cmd=GPIO,12,$STATE"`
fi
sleep 10
done
Place it in your toon (for example as filename /usr/bin/fancontroller). Then change the file on the toon to be executable (chmod +x /usr/bin/fancontroller).
You then can run the script manually (just type /usr/bin/fancontroller) to see if it works as intended.
If you are happy, then place this line in /etc/inittab (just after where the line starts with qtqt)
Code: Select all
fanc:245:respawn:/usr/bin/fancontroller >/dev/null 2>&1
and then restart your toon or type 'init q' to get the script started.