Iphone HAH control / data polling app
Hi All,
Thought I would share this little iphone app and configuration file with you all in case its of any use to others.
I wanted a Joggler style user interface for the Iphone and after much digging stumbled upon an app called "mote".
link here: http://www.worriedcat.com/Mote/Home.html
this is a nice little app that allows you to use your iPhone/iPod touch to control any ethernet-enabled device which communicates via TCP, UDP, HTTP, or HTTPS. Mote is programmable directly on your iPhone/iPod touch, allowing you to lay out buttons the way you want, with full macro functionality.
I use this to send xap messages via UDP to control my HAH relays and rf. I have also setup up a DynDns service so this can even operate over 3G outside the house (with port forwarding setup on the router). Coupled with Brett's Webserver Applet this can also poll 1wire, relay status etc and display on screen.
It can also be setup to poll and display current Pachube values.
This takes a little time to get your head round how it works but is very powerful when you do!. I have attached a basic config file that should be easy enough to modify to suit individuals needs. If you like and need more help setting it up just let me know. The tricky bit is that the Xap messages content need to be entered in HEX, but there are plenty of online TEXT to HEX converters that do the business (i have also done most of this for you in the config file).
Have Fun,
Garry.
p.s. wanted to post some screenshots but got defeated. will try to amend post later with these.
config file link. https://docs.google.com/document/d/10rH6PuCo6xVKq6TvP2VEG96eZIPBQAnT8ItSPCVPBGo/edit?hl=en_US
The HAH is shipped with a bunch of sample scripts burnt in check out
# ls -l /etc_ro_fs/plugboard/samples
-rw-r--r-- 1 502 100 737 Jan 1 1970 airytecSwitchoffApplet.lua
-rw-r--r-- 1 502 100 1274 Jan 1 1970 aliasApplet.lua
-rw-r--r-- 1 502 100 1793 Jan 1 1970 bindRelaysApplet.lua
-rw-r--r-- 1 502 100 421 Jan 1 1970 clockApplet.lua
-rw-r--r-- 1 502 100 831 Jan 1 1970 hbeatWatchdogApplet.lua
-rw-r--r-- 1 502 100 786 Jan 1 1970 jeenodeApplet.lua
-rw-r--r-- 1 502 100 886 Jan 1 1970 rebootApplet.lua
-rw-r--r-- 1 502 100 822 Jan 1 1970 relay1AutoOffApplet.lua
-rw-r--r-- 1 502 100 1374 Jan 1 1970 tcpRelayApplet.lua
-rw-r--r-- 1 502 100 2055 Jan 1 1970 tickerApplet.lua
-rw-r--r-- 1 502 100 955 Jan 1 1970 wolApplet.lua
-rw-r--r-- 1 502 100 3536 Jan 1 1970 xapCacheWebserverApplet.lua
Gary are you having problems posting files to the forums?
Not that I mind you post to google docs and then linking but you should be able to upload to these forums too: Files and Images.
Brett
Thank you Garry for your advice,
everything is working perfect now, including DYNDNS and using via 3G!
Obviously my problem was, that the original aliasApplet.lua in the livebox samples folder didn't work, every time i sent a message (via Twitter, Mote or Google) let the plugboard terminate without any action. Using your version fixed the problem!
Really a marvellous app, thanks for your perfect work!
Greetings from Austria,
Markus
Wasn't aware that sample was broken. Gary can you post up your changes?
Brett
I used the aliasApplet.lua in the /etc_ro_fs/plugboard/samples folder for the v2 plugboard, the older ones do not run any more, do they?
I also compared the two versions and couldn't find bigger differences than some Upper-Lower-Case differences.
But only the downloaded one worked for me!
Thanks,
Markus
I see the following changes. The first is just an increase in the number of controllable RF endpoints from 4 to 9, so I'm not too concerned about this tweak. Technically thou this incorrect as the alias code would now accept relay 5-9 which don't exist.
MINE: [rex.new("(relay|rf) ([1-4]) (on|off)")]=function(m) rfRelayCmd(m) end,
GARY: [rex.new("(relay|rf) ([1-9]) (on|off)")]=function(m) rfRelayCmd(m) end,
You would better to breaking this into two sections so you can't send "relay 5 on" which would be invalid.
[rex.new("(relay) ([1-4]) (on|off)")]=function(m) rfRelayCmd(m) end,
[rex.new("(rf) ([0-9]+) (on|off)")]=function(m) rfRelayCmd(m) end,
However this is a BUG
MINE: function rfRelaycmd(t)
GARY: function rfRelayCmd(t)
Indeed it should be coded as Gary has, this much match the alias function used above.
Brett
This isn't quite up to Mote standards, but it might prove useful http://www.automatedhome.co.uk/New-Products/xAP-Viewer-iOS-Home-Automati...
Never thought i would be anywhere near this level but WOW what a learning curve.
Can you post the script your using for your heating controller please? or share it on google docs or eben email it to me?
dean A______T packetradio dot co dot uk
wife would love it :) (brownie points for me to play)
so far i have mote switching lights over rf on and off :) -well its good for me im a hrdware guy, Getting the HAH integrated into central heating and alarm is a doddle for me wrioting scripts modifying code/scriptsnot so good.
dean
Dean,
I'd love to earn a few brownie points as well, and getting the HAH hooked into the heating system is just what's needed, but my electronics knowledge is very basic. Would you be able to offer any advice on implementing a heating controller?
Karl
Firstly lets forget Rf using the inputs from temp sensors and the 4 relays quite a complex system can be made.
I think the most important thing is to be able to leave existing controller in place with everything switched off, so hah takes control BUT if HAH fails you can quickly re-implement.
additionally Temp switches on walls turn right down use temp sensors on HAH.
so here is what i am thinking of doing ****NOTE RELAYS ON HAH WILL NOT BE DIRECTLY CONNECTED TO CENTRAL HEATING BUT VIA SUB RELAYS****
relay 1 heating on/off
relay 2 thermostat on/off
relay 3 water on/off
relay 4 water temp on/off.
To achieve the above you would need temp sensor in room and one on hot water tank, preferably bolted hard to it somehow.
This would give us total isolation between HAH and MAINS ELECTRICITY.
I will work out some part numbers from maplins for the proper kit but expect cost to be in region of £5 a relay+ box, not sure on relay requirements till i check a heating controller and see what they are rated at, i doubt it will be very high as they are very small boxes.
But for a test rig see the pdf link, just using led's and the relays you could "simulate" a heating controller just to see what happens prior to any integration into central heating system!
I have sort of started :)
http://www.packetradio.co.uk/gallery/index.php/HAH/
Does my logic sound alright so far?
I've been trying to implement a CH controller using RF. I have a Drayton wireless controller which works on 433 MHz and I've found some Arduino code which is said to control it. Unfortunately I can't transcode the data into the URF sub system and persuade it to work.
If anyone else has a similar setup and wants to have a go all the stuff is here:
http://www.homeautomationhub.com/content/rf-output-format
and I have been thinking about this for a while as I tried to get this going with my HomeVision box.
I got hold of an old central heating timer and disconnected the clock and wired into the buttons and relays.
So, I have 4 outputs from the switches which could be used to signal the inputs to the HAH (H/W advance and boost, CH advance and boost)
I then need two outputs (relays?) to control the relays.
Can all be run over CAT 5/6 cable as low voltage and need 7 wires!
Then you have a control head unit that can plug directly in place of the standard timer backplate (they are all the same).
Holding my hands over my ears head bowed shaking head back and forth.
you remind me of a friend of mine who hacked into kids toys to find the easter eggs.
i remember seeing him attatch jtags with blu-tak.
I too have a Drayton RF unit for my heating control.
The main issue is that it works by 'pairing' the thermostat with the receiver switch. This means that if we code up the HAH to send an RF string, the Rx would need to be paired with the HAH. Then, the original thermostat no longer works (and just think how much SWMBO would like that!).
I'm thinking that the best solution would be a little receiver circuit that would 'sniff' the tx signal from the thermostat. Then a script to use this info to generate the correct URF strings for the HAH.
This would then allow the thermostat to work the heating BUT would also allow the HAH to override. So, if you are running late, you can have the HAH switch things off.
Of course, this would take a fair bit of engineering. Time is, as ever, in short supply.
Derek.
i can see your point about the switch input, But you will need 4 relay outputs not only to control heating/water on/off but also thermostat's on/off for heating and water
I plan on using joggler to do overrides and google cal to do std on/off's. thus alleviating any manual switching.
oh and Mote to really make it cool and wife friendly, If she can turn heating on before she gets home that is way cool!! major brownie points
You should have boiler on/off seperate from thermostats on/off as switching off boiler turns pump off in some scenarios (plumbers are not perfect and standards have changed)
sometimes pump will run and boiler not on as heat exchange is still hot.
Dean
hmm hadnt really thought about that - its a nice to have really. You could run another CAT 5 to do it.
Not sure what you mean about switching thermostats? The standard controller has two relays in it, the thermostats are in series with them and they are double throw, so switching the 3way valve in some way I cant quite get my head around.
but according to the author:
I then adapted some PIC code that I had and got it to emulate the serial
packets and send them to a low cost 433MHz transmitter module. The Drayton
receiver was none-the-wiser, that these were not genuine packets from its
own transmitter.
So it's possible that the pairing will not be affected and that the original controller could just continue to be used.
Original post is here:
http://groups.google.com/group/homecamp/browse_thread/thread/3836e893157...
Newer boiler heat exchangers are not like old ones.
there flimsy and expensive and without pumpoverun the livespan could be short.
but anyway i was thinking about switching....be nice to have a 2 or three temp thing going on.
for example:-
Home saturday day doing things 20
eevening before bed sitting relaxing 22
evening asleep 18
out frost gaurd.
be nice to be able to time these setpoints so each overlapped ie 22 comes on 30 minutes prior to sitting down 20 30 minutes before you get up.
also an "out" using an input on the hah that switches ch down to 15degrees to save heating (could connect to alarm system so with system set temp reduced-overridable by mote or google cal to bring temp back up before you get home)
Just thinking ahead :0
I have a 3 way valve and a heating controller "spare" so will have a play when i get time :)
didnt realize they were in series? will have a play.
Don't ask i am a hoarder
http://www.packetradio.co.uk/gallery/index.php/HAH?page=3
didnt know there were so many types.
will have to figure out which is mine :)
Just told wife i am moving controls as i am fed up with leaning over then to set h/w and ch.
she said "thats a good idea" little does she know there is alternative reason and an extra box "may get added" :)
The rate at which your house heats up is proportional to the temperature outside.
So, when its cold outside, your CH needs to come on earlier to get the house warm for when you wake up - infintely achievable if you know the outside temp.
Not sure about the next bit - but if the temperature is rapidly rising, say on a sunny spring morning, why would the heating come on if its gonna be warmer outside than inside (no heat loss, in fact heat gain depending on your insulation) within a short time?
Take your point about pump overrun - my boiler - about 2years old - says its optional.
well you can sort them into 3 way valve or not. (most prob will have 3 way in UK).
But neither of the 3way drawings have pump overrn as live and neutrals wired to boiler L&N ;-)
Hi
I've just been messing around with an old "Sheevaplug" linux box (trying to learn about linux) and have installed PHP (also trying to learn a little of that too) I have made a web page that acts as a TCP client and will send alias messages to HAH as well as parsing out the reply. A couple of questions.. my packet to send an alias is not well received ie
Error Message: A xAP message received was malformed. Object reference not set to an instance of an object.
Received From: 10.0.0.30:3075
xap-header
{
class=alias
}
command
{
text=rf 1 on
}
It still works though. What is the most basic packet that I can send without error.
I know I could use Hah's own web gui but it does not allow for alias messages. Is this a daft approach?
John
John what you are sending is not a valid xAP packet. That is what I call a "short" packet and when sent via by the HAH LUA framework it will pad it out for you. HOWEVER if you are doing this direct to the wire with PHP etc.. you need to build a FULL xAP packet.
xap-header
{
v=12
hop=1
uid=FF123400
source=vendor.device.instance
class=alias
}
command
{
text=rf 1 on
}
There is a nice interaction diagram with the alias Applet published here http://www.dbzoo.com/livebox/twitter
UPDATE:
Its kind of daft sending an alias message as you could send the xAPBSC.cmd packet straight to your RF.1 device and avoid the alias applet completely. That does not negate the fact that you still need to form a good payload.
xap-header
{
v=12
hop=1
uid=FF123400
source=vendor.device.instance
target=dbzoo.livebox.Controller:rf.1
class=xapBSC.cmd
}
output.state.1
{
id=*
state=on
}
State values can be on/off/toggle.
Do consult: http://www.xapautomation.org/ for protocol specifications and the "Basic Status and Control" BSC schema.
Thanks for that Brett but I do need to send alias messages as I need to run timers, have conditional statements etc in a lua script.
Hi Garry,
i implemented your marvellous config into my iphone and did also some testing with my denon receiver that worked very well before my livebox was sent to me.
Now that i have set up my livebox and everything is running fine, i wanted to get the iphone work with it.
My question is, how do i have to configure my hah to receive the data sent from the iphone and to execute the commands?
is there a extra lua script you use?
thanks for your answer!
Markus