I am really satisfied with my home made MAX-control system, so i think i would share it here.
We live four here in our house, and there are 4 room's with each own radiator (Livingroom, Bedroom, Childroom1, Childroom2)
The hardware is an Raspberry Pi, with some other automation task, MAX : 4 valves, 1 cube, 1 wall switch etc...
Well. My setup is working as follows : (I have pasted part of Bash script's for better explanation)
The first thing, the system is checking, is if it's winter, then system is checking if it's weekend or weekday
-I don't want any unnessesary valve regulation at night or weekends
Code: Select all
# 1. Be sure AUTO is on, when it is weekend
# 2. Exit script, if it is Weekend
if [ $SCRIPTDAY = "WEEKEND" ]; then
if [ $AUTO -eq 0 ]; then
echo $AUTO_LIVING | netcat -C 192.168.1.127 62910
sleep $D
echo $AUTO_BEDROOM | netcat -C 192.168.1.127 62910
sleep $D
echo $AUTO_FREDE | netcat -C 192.168.1.127 62910
sleep $D
echo $AUTO_JOSSE | netcat -C 192.168.1.127 62910
sleep $D
curl -s -i -H "Accept: application/json" "http://$DOMOTICZ:$PORT/json.htm?type=command¶m=switchlight&idx=$TH2&switchcmd=Off"
curl -s -i -H "Accept: application/json" "http://$DOMOTICZ:$PORT/json.htm?type=command¶m=switchlight&idx=$TH3&switchcmd=Off"
curl -s -i -H "Accept: application/json" "http://$DOMOTICZ:$PORT/json.htm?type=command¶m=switchlight&idx=$TH4&switchcmd=Off"
curl -s -i -H "Accept: application/json" "http://$DOMOTICZ:$PORT/json.htm?type=command¶m=switchlight&idx=$TH5&switchcmd=Off"
echo 1 > $AUTO_ON
echo 1 > $AUTO1_ON
Normally the MAX weekly program sets the temperatures to 17 degrees, between 0900 -> 1430 each weekday
So... if it's e.g are weekday, and let's say all the valves are set to Auto (From the Max weekly program).
Then if my wife (Or myself), has an early day, or maybee a day off, the system is detecting her phone, and regulation is set to MANUEL, e.g 21 degrees. (Livingroom and bedroom)
The same thing happend if one of the kid's are entering the house. Then Livingroom and e.g Childsroom1 heats up
There are some "cooloff/delays" routines, so that small gclithes, or maybee a 1-2 minute phone dropout dosent interfear the system. -Eventually the detection if a phone is leaving house is delayed with approx. 12 minutes...
Code: Select all
if [ $MAN -eq 0 ]; then
if [ $PHONE1 -eq 1 ] || [ $PHONE2 -eq 1 ] || [ $PHONE3 -eq 1 ] || [ $PHONE4 -eq 1 ]; then
let COUNTER=$COUNTER+1
echo $COUNTER > $COUNTER_0
fi
if [ $COUNTER -eq $ONDELAY1 ]; then
echo $MAN_LIVING_20 | netcat -C 192.168.1.127 62910
sleep $D
curl -s -i -H "Accept: application/json" "http://$DOMOTICZ:$PORT/json.htm?type=command¶m=switchlight&idx=$TH4&switchcmd=On"
echo 0 > $AUTO_ON
echo 1 > $MAN_ON
echo 0 > $COUNTER_0
fi
fi
# Bedroom AUTO / MAN (TH5)
if [ $MAN3 -eq 0 ]; then
if [ $PHONE1 -eq 1 ] || [ $PHONE4 -eq 1 ]; then
let COUNTER3=$COUNTER3+1
echo $COUNTER3 > $COUNTER_3
fi
if [ $COUNTER3 -eq $ONDELAY1 ]; then
echo $MAN_BEDROOM_20 | netcat -C 192.168.1.127 62910
sleep $D
Here you can see, what i use right now:
Code: Select all
# codes for setting the MAX
MAN_LIVING_OFF=s:AARAAAAAEUdJBEk=
MAN_LIVING_18=s:AARAAAAAEUdJBGQ= # Man stue (18 C.)
MAN_LIVING_17=s:AARAAAAAEUdJBGI= # Man stue (17 C.)
MAN_LIVING_20=s:AARAAAAAEUdJBGk= # Man stue (20.5 C.)
AUTO_LIVING=s:AARAAAAAEUdJBAA= # Auto stue
MAN_BEDROOM_OFF=s:AARAAAAAEUh2AUk=
MAN_BEDROOM_10=s:AARAAAAAEUh2AVQ= # Man soveværelse (10 C.)
MAN_BEDROOM_17=s:AARAAAAAEUh2AWI= # Man soveværelse (17 C.)
MAN_BEDROOM_20=s:AARAAAAAEUh2AWg=
MAN_BEDROOM_21=s:AARAAAAAEUh2AWo= # Man soveværelse (21 C.)
AUTO_BEDROOM=s:AARAAAAAEUh2AQA= # Auto soveværelse
MAN_FREDE_OFF=s:AARAAAAAEUgCA0k=
MAN_FREDE_17=s:AARAAAAAEUgCA2I= # Man Frederiks værelse (17 C.)
MAN_FREDE_21=s:AARAAAAAEUgCA2o= # Man Frederiks værelse (21 C.)
AUTO_FREDE=s:AARAAAAAEUgCAwA= # Auto Frederiks værelse
MAN_JOSSE_OFF=s:AARAAAAAEUfqAkk=
MAN_JOSSE_17=s:AARAAAAAEUfqAmI= # Man Josefines værelse (17 C.)
MAN_JOSSE_21=s:AARAAAAAEUfqAmo= # Man Josefines værelse (21 C.)
AUTO_JOSSE=s:AARAAAAAEUfqAgA= # Auto Josefines værelse
The phone detection script, was something which took me months to write. I did find it very hard to not having fallout's on the phones, until i found a script, which someone wrote. -I then took part of this excellent script and used in my own. (Sry. can't remember where i found it)
The brilliant part, is where the script is asking my router, which Phone MAC adresses is present, and then execute further on from there:
Code: Select all
macdevice3="xx:xx:xx:xx:xx:xx:xx" #Josefine's Iphone 6
macdevice4="xx:14:xx:xx:xx:xx" #Jesper's Iphone 6
#macdevice4="xx:xx:xx:5D:xx:xx" #Jesper fake OFF!
maclist=$(sshpass -p xxxxxx ssh [email protected] arp | cut -d" " -f4)
# Reset current status. Two variables are used for each device.
# The past known status and the current status. Only a change is reported
maccurrent1=0;
maccurrent2=0;
maccurrent3=0;
maccurrent4=0;
for mac in $maclist; do
case $mac in
"$macdevice1") maccurrent1=1;;
"$macdevice2") maccurrent2=1;;
"$macdevice3") maccurrent3=1;;
"$macdevice4") maccurrent4=1;;
esac
done
if [ $maccurrent1 -eq 1 ]; then
echo 1 > $PHONE1
echo 0 > $COOLOFF1
Hope some here get inspiration ? - I surely have a lot of fun with it
/Jesper.