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

Member for

15 years 4 months

wpmax

15 years 2 months ago

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

Member for

15 years 7 months

garrydwilms

15 years 2 months ago

Markus,

Great to hear you are using this neat little app. I love it, so useful for things other than just HAH.

You do need Brett's lua script for handling alias xap messages. but before we get to that there are a couple of other things to check you have done.

This app sends UDP messages via port 3639 therefore you need to make sure your wireless router is port forwarding this port to your HAH address.

Then you need to modify the IP address within the controllers section in the app to match your HAH (or better still set up a DYNDNS account and configure your router. Then you can enter your webaddress in here and use the app outside of your wifi range)

Once this is done the HAH should be receiving Alias style XAP messages (see the wiki for more info on alias messages)

These alias messages need a lua script to decode them and control the HAH.

The script, written by Brett, can be found here

https://docs.google.com/leaf?id=0By6nfqTVUDOXMDRiNTQ1OTYtNjQxYi00MzI4LT…

and needs to be put into the /etc/plugboard folder. reboot to initiate the script.

This should now by fine, rf and relay control operational via iphone.

A bit of playing and you can produce nice looking and useful gui screens, below is my heating control that I'm particularly pround off :).

Any further problems you encounter, let me know and we'll see if we can sort it.

Thanks

Garry

Member for

16 years 10 months

brett

15 years 2 months ago

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

Member for

15 years 4 months

wpmax

15 years 2 months ago

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

Member for

15 years 7 months

garrydwilms

15 years 2 months ago

As far as I can remember I didn't make any changes to the alias script. I will check the one on google docs posted above and compare with that in the samples folder to be sure. I wonder wether Markus used the alias script in /etc/plugboard/samples folder instead which I think is written for original plugboard not v2? Markus can you confirm? Thanks Garry

Member for

15 years 4 months

wpmax

15 years 2 months ago

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

Member for

16 years 10 months

brett

15 years 2 months ago

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

Member for

15 years 10 months

g7pkf

15 years ago

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

Member for

16 years 5 months

BoxingOrange

15 years ago

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

Member for

15 years 10 months

g7pkf

15 years ago

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?

Member for

15 years 7 months

garrydwilms

15 years ago

But I have cheated a little.

I basically have broken into the live connection between the CH controller and the thermostat in my exsisting heating system. I then butchered an aldi RF socket and connected this accross the break.

I then have to leave the old controller on heating continously to power the RF socket and the existing thermostat on full so that it never breaks.

The rf socket then switches heating on and off. I know this has downsides and is not as neat as Dean's solution but it does have the benefit of easy install and no wire runs.

I then have a script that I will share later when I get home that monitors 1 wire temps and compares them to a setpoint in order to switch off the heating when set point reached. The switching on is done via a google calendar event lasting as long as the required heating period (as long as temp is below setpoint).

Note, this doesn't work for my water as this is not as simple. My three way valve still needs a signal when the water is off so I cannot just use this break in technique for this. I Haven't found a quick solution to this problem as yet.

Thanks

 

Garry.

Member for

15 years 1 month

allanayr

15 years ago

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:

/content/rf-output-format

 

Member for

16 years 4 months

Alanmh

15 years ago

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).

Member for

17 years

derek

15 years ago

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.

Member for

15 years 10 months

g7pkf

15 years ago

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

Member for

15 years 10 months

g7pkf

15 years ago

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

Member for

16 years 4 months

Alanmh

15 years ago

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.

Member for

15 years 1 month

allanayr

15 years ago

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/3836e89315…

 

Member for

15 years 10 months

g7pkf

15 years ago

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

Member for

15 years 10 months

g7pkf

15 years ago

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

Member for

16 years 4 months

Alanmh

15 years ago

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.

Member for

16 years 4 months

Alanmh

15 years ago

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 ;-)

Member for

15 years 7 months

garrydwilms

15 years ago

For interest, i currently doing this variable thermostat thing using a modified alias script.

The alias script supplied with the HAH was modified as here  https://docs.google.com/open?id=0By6nfqTVUDOXMjEzYWMwNjctN2RmZS00NGQ3LW… (sorry still struggling with file attachments) so that the following messages sent via google calender, mote, twitter etc are decoded.

Thermostat xx: sets the thermostat to xx oC

Heating on: Switches the heating on

Boost x: Sets a google calendar event for "heating on" starting now and ending in x hours.

The thermostat works by saving the value in a text file "ThermostatSetting" stored on the HAH which other scripts can pull from.

The heating is then switched off by a script such as this:

function Thermostatfunction()
housetemp = xap.getValue("input.state","text")
local file = io.open("/etc/plugboard/ThermostatSetting","r")
        ThermostatValue = file:read("*all")
    file:close()
           if tonumber(housetemp) > tonumber(ThermostatValue)then
            sendBscCmd("dbzoo.livebox.Controller:rf.2","state=off")
    end
end

The thermostat could then easily be programmed via google calender, one off setting via twitter or mote etc, or even via logic within a script such as lower it if your out as Dean suggested.

Sure there are better ways but this works for me. Hope its of some use.

 

Garry.

Member for

14 years 6 months

magill

12 years 8 months ago

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

Member for

16 years 10 months

brett

12 years 8 months ago

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.

Member for

14 years 6 months

magill

12 years 8 months ago

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.