PDA

View Full Version : Home Automation using Girder / Net Remote and C-Bus



GusKerr
April 29th, 2006, 04:55 AM
Hope this will be of interest to other members and will maybe provide a mechanism for me gaining some help along the way when I get stuck (which will be inevitable)!

Anyway, I have quite an ambitious project ahead of me as I am looking to use Girder 4 & Net Remote to form the heart of my House Automation Project.
Basically I have a C-Bus controller system (which is great by the way) that will take control of all lights, blinds & sensors. I then have an Extron Matrix switcher for juggling the surround sound, the dual SKY+ boxes and music (music will be held on a networked PC). All output from the Matrix switcher can be pumped out to any room in the house. Finally I have a number of IP cameras placed both within and outwith the house.

I am an electronic hobbiest who has a good knowledge of programming (VB and its variants) but never done C programming. The whole project is being done by myself in my spare time so it projected to take me the rest of the year.

My plan is to post progress on this board and ask for help when required.

Regards

Gus

Promixis
April 29th, 2006, 08:29 AM
Hi Gus,

I have looked at the CBUS protocol in the past and it should be fairly easy to do with the serial plugin -> all in Lua. If you know VB it will be easy for you to do Lua.

We have a serial extension for the Extron. It might need some modification depending on the model.

Let us know how we can help out..

GusKerr
April 29th, 2006, 04:04 PM
From my knowledge of C-Bus it is better to use C-Gate as the mechanism to send any messages through. Based on that I have used the GIP Plug-in and do seem to be getting somewhere but have a problem / question.

Here is my initial code:

-- CallBack Function
function CGateCallBack(uData,uReturnCode)

if ( uReturnCode == gip.CONNECTIONCLOSED ) then
print("Connection Closed")
return
end

if ( uReturnCode == gip.CONNECTIONESTABLISHED ) then
if ( uData == 0 ) then
print("New Connection")
else
print("New Connection Failed: ", uData)
end

return
end

print(uData)

end

--Start of Main Code
--Open C-Gate Session & Register Callback
uSession = gip.Open('127.0.0.1',20023)
uSession:Callback(2, '\r\n', 1000, CGateCallBack)


-- Initialise Session
uSession:Write('PROJECT DIR\n')
uSession:Write('PROJECT LOAD CBUSNET\n')
uSession:Write('PROJECT USE CBUSNET\n')
uSession:Write('PROJECT START\n')
uSession:Write('NET OPEN 254\n')
uSession:Write('TREE 254\n')

This sets up the CBUS Project ready for commands to be sent. What I want to be able to do is then allow Actions to send a simple write command.

e.g. uSession.Write('RAMP 254/56/1 50%').

This would switch on a light to 50% of intensity. To make this work I need to be able to hold the uSession variable and call it from various different places (i.e. the script that sits on the back of the Action.

Finally I would have a function that closes the project and clears the uSession variable.

Can someone help please ?

Cheers

Gus

Ron
April 29th, 2006, 04:27 PM
disclaimer, just did a nice hike out in the mountains and I am a little tired :-)

if uSession is not declared local then it should be available from anywhere in Girder. You can verify this in the Variable inspector.

GusKerr
April 29th, 2006, 04:41 PM
9pm at night here in the UK so I guess you are a few hours back. Sounds like you had a good long walk (and I assume in the sun)......

What a platform - I am starting to see the power (and flexibility) it has and am getting a bit more confident. I even have the event messages from the whole C-Bus system now feeding back into the console by reading port 20025 and setting up a similar CallBack.

And yes, it was a missing \n that was causing my problem.

Onwards & upwards

Cheers for now

Gus

Ron
April 29th, 2006, 04:48 PM
Cool! If you have the message feeding into the console, you can even feed them into Girder's event system!



gir.TriggerEventEx([eventstring], [eventdevice], [keymodifier], [payload] ... )


It was a little overcast here in CA, which is good. Hiking out in the mountains during summer is... HOT.

GusKerr
April 29th, 2006, 05:35 PM
Moving onto using the AddEventHandler, how do I find out the device No. I am using an MCE remote control at the moment ?

Cheers

Gus

Ron
April 29th, 2006, 05:36 PM
Plugin page on the settings dialog. Select the MCE plugin it will list the number on the left.

GusKerr
April 30th, 2006, 11:08 AM
Thanks Ron - That has my AddEventHandler picking up all the commands from the remote so that I can programatically issue relevant commands to the C-GATE Server. There are a lot of commands and I wanted to use the structure

Select Case CommandIssued
Case "Up"
Send Increase Brightness Command

Case "Down"
Send Decrease Brightness Command

End Select

Is this possible or must I resort to an If / Else If structure ?

Cheers

Gus

GusKerr
April 30th, 2006, 12:32 PM
How good is LUA for manipulating strings (e.g. Len, RIGHT, LEFT, INSTR etc). If it can do it where would I look for the details ?

Cheers

Gus

danward79
April 30th, 2006, 01:38 PM
The girder manual has good, info on this look at the string library, and the book I linked to you in your other thread.

GusKerr
April 30th, 2006, 04:37 PM
Sorry about that Dan.

I have the manual stored as a shortcut but missed the section on strings - as you say a good section on the very topic I need.

cheers

Gus

danward79
April 30th, 2006, 04:51 PM
No worries,

:P

GusKerr
May 1st, 2006, 10:55 AM
Whilst I have found the online documention fine I always find these kind of things easier to find in a reference book so ordered from Amazon today for the massive !! sum of 12.50 GBP + 2.95 postage.

Getting on really well now and have almost finished the callback routines to get information from the CGATE System. This automatically sends back any interaction on the CGATE Bus either from real switches on the systems or me controlling it from software.

I am keen to share my tales of woe, advice, hints, etc with the rest of community and wonder what is the best way of doing this.

My options:

(1) - Dump the code into this forum

(2) - Add the code as attachments

(3) - Upload it to the Plugins section and update as I move on

(4) - Link to a website of mine.

Any suggestions ?

Cheers

Gus

Promixis
May 1st, 2006, 10:58 AM
Gus,

Great to hear its working out.

To discuss code etc. suggest you post here. If you have something that others can use then please upload it via the developer link.

danward79
May 1st, 2006, 11:25 AM
The book is a real good buy, if you are a commuter like me if filled a lot of journeys up.

Promixis
May 1st, 2006, 11:32 AM
V2 of the book is out... not much new if you are using 5.0 but covers alot of the C side of things much better.

GusKerr
May 1st, 2006, 01:16 PM
Here is the first cut of my code. Can you guys cast an eye over it and let me know if I am doing it in the most effective manner. I have it fairly well commented so should by Ok for picking up.

Basically the Initialisation just loads up my CBUS project. At this stage I am experimenting with four coloured lights. This routine makes sure all the CGATE messages are filtered via Girder Callback routines and loads the project.

The actual functions control the rest of it. If I select a couloured button that lamp is then active. I can then switch it on or off or dim up and down. That's it so far.

Nothing too exciting but it all works................

Gus

-------------------------------------------------------------------------------------------------------


First the Initialisation:
--[[
1st May 2006
Initialise CGate System / Install CallBack Routines
Angus W Kerr
--]]

-- Define System to be Managed
sSystemID = "CGATE"

-- Register Callbacks from CGate Server
uSession = gip.Open("127.0.0.1",20023)
uSession:Callback(2, "\r\n", 1000, CGateCallBackCommand)

uSessionEvent = gip.Open("127.0.0.1",20024)
uSessionEvent:Callback(2, "\r\n", 1000, CGateCallBackEvent)

uSessionSCP = gip.Open("127.0.0.1",20025)
uSessionSCP:Callback(2, "\r\n", 1000, CGateCallBackSCP)

-- Define Remote Control EventHandler Function (230 = MCE Remote Control)
CGATE_CallBackID = gir.AddEventHandler(".*", 230, 230, CGATE_CallBack)

-- Initialise CGate Session
uSession:Write("PROJECT DIR\n")
uSession:Write("PROJECT LOAD CBUSNET\n")
uSession:Write("PROJECT USE CBUSNET\n")
uSession:Write("PROJECT START\n")
uSession:Write("NET OPEN 254\n")
uSession:Write("TREE 254\n")

-- This is a Test to ensure System is working (Will be Removed)
uSession:Write("ON 254/56/1\n")



Then the Functions to do all the work:

--[[
1st May 2006
CallBack for CGATE Command Interface
Extracts Message Code, Device ID & Value of Light
Angus W Kerr
--]]

-- CallBack Function - Command Interface
function CGateCallBackCommand(uData,uReturnCode)

if ( uReturnCode == gip.CONNECTIONCLOSED ) then
print("Connection Closed")
return
end

if ( uReturnCode == gip.CONNECTIONESTABLISHED ) then
if ( uData == 0 ) then
print("New Connection")
else
print("New Connection Failed: ", uData)
end
return
end

if uData ~= "" then
local iStart = {}
local iFinish = {}
CGATE_COM = uData
print("Com:", CGATE_COM)
-- Extract Return Data from CGATE Message (Code, Device, Level)
sCOMDataCode = string.sub(CGATE_COM, 1, 3)
iStart[1], iFinish[1] = string.find(CGATE_COM, "//")
-- Check for OK Command
if sCOMDataCode == "200" then
sCOMDataDevice = string.sub(CGATE_COM, iStart[1] + 10, string.len(CGATE_COM))
sCOMDataValue = 999
end

if sCOMDataCode == "300" then
iStart[2], iFinish[2] = string.find(CGATE_COM, ":")
sCOMDataDevice = string.sub(CGATE_COM, iStart[1] + 10, iStart[2] - 1)
iStart[3], iFinish[3] = string.find(CGATE_COM, "level")
if iFinish[3] == nil then
sCOMDataValue = 999
else
sCOMDataValue = string.sub(CGATE_COM, iFinish[3] + 2, string.len(CGATE_COM))
end
end

-- gir.TriggerEventEx ("CGATE Event", 2000, 0, sCGATEData[1], sCGATEData[2], sCGATEData[3])
end

end

--[[
1st May 2006
CallBack for CGATE Event Interface
For Future Use
Angus W Kerr
--]]

-- CallBack Function - Event Interface
function CGateCallBackEvent(uData,uReturnCode)

if ( uReturnCode == gip.CONNECTIONCLOSED ) then
print("Connection Closed")
return
end

print("Evt:", uData)

end

--[[
1st May 2006
CallBack for CGATE Status Interface
Extracts Message Code, Device ID & Value of Light (0 - 255)
Angus W Kerr
--]]

-- CallBack Function - Status Change Port
function CGateCallBackSCP(uData,uReturnCode)

if ( uReturnCode == gip.CONNECTIONCLOSED ) then
print("Connection Closed")
return
end

if uData ~= "" then
CGATE_SCP = uData
print("Scp:", CGATE_SCP)
-- Extract Return Data from CGATE Message (Message, Device, Level)
local iStart = {}
local iFinish = {}
iStart[1], iFinish[1] = string.find(CGATE_SCP, "//")
iStart[2], iFinish[2] = string.find(CGATE_SCP, " ", iStart[1])
iStart[3], iFinish[3] = string.find(CGATE_SCP, "lighting off")
if iFinish[3] ~= nil then
sSCPData1 = "999"
sSCPData2 = string.sub(CGATE_SCP, iStart[1] + 10, iStart[2])
sSCPData3 = 0
end
iStart[3], iFinish[3] = string.find(CGATE_SCP, "lighting on")
if iFinish[3] ~= nil then
sSCPData1 = "999"
sSCPData2 = string.sub(CGATE_SCP, iStart[1] + 10, iStart[2])
sSCPData3 = 255
end
iStart[3], iFinish[3] = string.find(CGATE_SCP, "lighting ramp")
if iFinish[3] ~= nil then
sSCPData1 = "999"
sSCPData2 = string.sub(CGATE_SCP, iStart[1] + 10, iStart[2])
sSCPData3 = string.sub(CGATE_SCP, iStart[2] + 1, iStart[2] + 3)
end
-- gir.TriggerEventEx ("CGATE Event", 2000, 0, sCGATEData[1], sCGATEData[2], sCGATEData[3])
end

end

--[[
1st May 2006
CallBack for MCS Controller
Runs Command depending on button pressed
Colour Buttons, Channel Changer, Rew, Fwds
Angus W Kerr
--]]

function CGATE_CallBack(sEvent, iPluginID, iModifier, sPayloads, uID)

-- Check SystemID for "CGATE" and Exit if Not
if sSystemID ~= "CGATE" then
return
end

-- Choose Colour of Lights (Colour Keys) - Get Current Value
if sEvent == "31652" then
uSession:Write("GET 254/56/1 level\n") -- Red Light on Dimmer Block A
elseif sEvent == "31651" then
uSession:Write("GET 254/56/3 level\n") -- Green Light on Dimmer Block A
elseif sEvent == "31650" then
uSession:Write("GET 254/56/4 level\n") -- Yellow Light on Dimmer Block A
elseif sEvent == "31649" then
uSession:Write("GET 254/56/2 level\n") -- Blue Light on Dimmer Block A
end

-- Check for Increase / Decrease Command (Channel Up / Down)
if sEvent == "31725" then
-- Increase Brightness
if tonumber(sCOMDataValue) > 239 then sCOMDataValue = 239 end
sCommand = "RAMP " .. sCOMDataDevice .. " " .. sCOMDataValue + 16 .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
elseif sEvent == "31724" then
-- Decrease Brightness
if tonumber&#40;sCOMDataValue&#41; < 16 then sCOMDataValue = 16 end
sCommand = "RAMP " .. sCOMDataDevice .. " " .. sCOMDataValue - 16 .. "\n"
uSession&#58;Write&#40;sCommand&#41;
uSession&#58;Write&#40;"GET " .. sCOMDataDevice .. " level\n"&#41;
end

-- Check for On / Off Command &#40;Fwd / Rev&#41;
if sEvent == "31723" then
-- Turn On
sCommand = "ON " .. sCOMDataDevice .. "\n"
uSession&#58;Write&#40;sCommand&#41;
uSession&#58;Write&#40;"GET " .. sCOMDataDevice .. " level\n"&#41;
elseif sEvent == "31722" then
-- Turn Off
sCommand = "OFF " .. sCOMDataDevice .. "\n"
uSession&#58;Write&#40;sCommand&#41;
uSession&#58;Write&#40;"GET " .. sCOMDataDevice .. " level\n"&#41;
end

end


edit by Ron added code brackets.

Rob H
May 2nd, 2006, 03:15 AM
Well, the first thing that leaps out at me is the CGateCallBackSCP function where you use string.find to return just the start and end of the match.

What is the format of the response that you're decoding here? You may find that you can replace large amounts of code with captures in a regular expression.

GusKerr
May 2nd, 2006, 06:51 AM
Rob,

Many thanks for the challenge. To explain:

The messages that are returned are in the format of a single line of text

lighting off //CBUSNET/254/56/1 0 #xxxxxxxxx
lighting on //CBUSNET/254/56/1 255 #xxxxxxxxx
lighting ramp //CBUSNET/254/56/1 120 4 #xxxxxxxx

The ramp message will trigger a number of times and then settle on the final figure when the 4 will change to a 0.

Messages to this function could be generated by me sending an instruction to the CGATE Queue(uSession.Write) or when a switch is changed on the CBUS network (i.e. someone turns on or off a light). This gives me the current level of a light before I start changing it via software.

One flaw I have thought of - if two lights are changed by an external switch quite quickly, I will not be able to gain the state of the 1st change as it will have been overwritten. I really need to therefore store the name of the device I want to change and to check this before making the change (i.e. on/off/dim). If the sCOMDATDevice is not the same then I would request the data again.

----------
And so to your observation:
I am unfamilar with the capture function but if it is a more efficient method of capturing data then I would be grateful if you would steer me in the right direction.

Cheers

Gus

Rob H
May 2nd, 2006, 08:33 AM
lighting off //CBUSNET/254/56/1 0 #xxxxxxxxx
lighting on //CBUSNET/254/56/1 255 #xxxxxxxxx
lighting ramp //CBUSNET/254/56/1 120 4 #xxxxxxxx

What's the #xxxxxxx bit?

You could use something like this :-


local _, _, device, cmd, address, params, extra = string.find&#40;CGATE_SCP, "&#40;.-&#41;%s&#40;.-&#41;%s//CBUSNET/&#40;.-&#41;%s&#40;.-&#41;%#&#40;.-&#41;$"&#41;

For the first of these you'd end up with the following values


device = 'lighting'
cmd = 'off'
address = '254/56/1'
params = 0,
extra = 'xxxxxxxx'

For the ramp one, params would be '120 4' and you could use a further regular expression to break that up.

GusKerr
May 2nd, 2006, 02:58 PM
Blowed Away......

This is a powerful programming language that offers a lot more than I thought (I have mainly worked with VB). Anyway about to start re-coding all the functions to follow the same format. I have now found the section that refers - "Tricks of the Trade"

Thanks

Gus

Ron
May 2nd, 2006, 02:59 PM
:-) Welcome to the wonderfull world of Lua.

GusKerr
May 2nd, 2006, 03:01 PM
Forgot to say the #xxxxxxxx is just an internal identifier used by CGATE and has no use to the user so I will ignore this parameter.

Gus

Rob H
May 2nd, 2006, 03:10 PM
Good, isn't it? :)

Promixis
May 2nd, 2006, 03:10 PM
Blowed Away......

This is a powerful programming language that offers a lot more than I thought (I have mainly worked with VB). Anyway about to start re-coding all the functions to follow the same format. I have now found the section that refers - "Tricks of the Trade"

Thanks

Gus

Lua is a very common in game programming. Some big name games use it and some of these have over 1/2 million lines of lua code

GusKerr
May 2nd, 2006, 05:15 PM
Can I make this even more efficient



-- Extract Return Data from CGATE Message &#40;Code, Device, Level&#41;
sCOMDataCode = string.sub&#40;CGATE_COM, 1, 3&#41;
-- Check for OK Command
if sCOMDataCode == "200" then
_, _, sCOMDataCode, sCOMDataDevice, sCOMDataValue = string.find&#40;CGATE_COM, "&#40;.-&#41;%s.-%s//CBUSNET/&#40;.-&#41;$"&#41;
end

if sCOMDataCode == "300" then
_, _, sCOMDataCode, sCOMDataDevice, sCOMDataValue = string.find&#40;CGATE_COM, "&#40;.-&#41;%s//CBUSNET/&#40;.-&#41;level=&#40;.-&#41;$"&#41;
sCOMDataDevice = string.sub&#40;sCOMDataDevice, 1, string.len&#40;sCOMDataDevice&#41; - 2&#41;
end


I am wondering if it is possible to check for all possibilities together. in a single statement.

Cheers

Gus

GusKerr
May 2nd, 2006, 05:17 PM
Sorry these are the commands I am testing

Com: 200 OK: //CBUSNET/254/56/1

and

Com: 300 //CBUSNET/254/56/1: level=255

GusKerr
May 6th, 2006, 04:45 PM
I have now started some work with Net Designer / Net Remote to allow wireless control of the 4 coloured lights. Initially I just want to be able to turn them on and off.

So far I have created single scripts within Girder to Turn on and off the red light. Assigned to these are an Action called TurnOn & TurnOff respectively. I can then create two buttons in Net Designer which have a Girder action assigned to them (in this case TurnOn and TurnOff).

This all works which is fine to start with and proves that my basics are right. (i.e. an action initiated in NR is passed through to Girder and actioned)

BUT

I want to be able to use the LUA scripts in Girder to receive the messages from Net Remote and carry out the appropriate commands (in much the same way I am with the MCE control). I assume I can do this using the AddEventHandler but I am unsure of the event ID for NR.

-- Define Remote Control EventHandler Function (230 = MCE Remote Control)
CGATE_CallBackID = gir.AddEventHandler(".*", 230, 230, CGATE_CallBack)

My assumption is that I could then use the following code:

function CGATE_CallBack(sEvent, iPluginID, iModifier, sPayloads, uID)

-- Check for On / Off Command (Fwd / Rev)
if sEvent == "TurnOn" then
-- Turn On
sCommand = "ON " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
elseif sEvent == "TurnOff" then
-- Turn Off
sCommand = "OFF " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
end

end


Am I following the right lines or is this just the wrong approach.

2nd Problem:

How do I get a Girder variables back to NR and display it on the screen. I have a Girder variable called sCOMDataValue that holds the current light level for a light and would like to have this showing as a value on the NR screen.

Can you give me some pointers please.

Cheers

Gus

Rob H
May 6th, 2006, 05:57 PM
Commands from NetRemote come in on the ComServer id which is 232 as far as I remember.





function CGATE_CallBack(sEvent, iPluginID, iModifier, sPayloads, uID)
-- Check for On / Off Command (Fwd / Rev)
if sEvent == "TurnOn" then
-- Turn On
sCommand = "ON " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
elseif sEvent == "TurnOff" then
-- Turn Off
sCommand = "OFF " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
end

end


Am I following the right lines or is this just the wrong approach.

I'd probably define multiple event handlers for the different events rather than using a combination of if then elses.



How do I get a Girder variables back to NR and display it on the screen. I have a Girder variable called sCOMDataValue that holds the current light level for a light and would like to have this showing as a value on the NR screen.

You would use NetRemote.SetVariable('LightLevel', sCOMDataValue) and have a button in NetRemote with a name of {LightLevel} including the braces.

Hope this helps.

GusKerr
May 6th, 2006, 06:03 PM
Cheers for that Rob - Looks like I can do everything I want with a bit of time and effort. On the basis it is now midnight, better call it a night but will hopefully get some spare time tomorrow to develop the NR link.

Gus

GusKerr
May 7th, 2006, 05:33 AM
I have completed the code as you suggested to enable me to test the messages from the NR consule. At this stage I have not created separate events as I want to get the basics working.

Code is

- Define Net Remote EventHandler Function (232 = Net Remote)
NR_CallBackID = gir.AddEventHandler(".*", 232, 232, NR_CallBack)

function NR_CallBack(sEvent, iPluginID, iModifier, sPayloads, uID)
-- Check for On / Off Command
print ("NREvent: ", sEvent)
if sEvent == "TurnOn" then
-- Turn On
sCommand = "ON " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
elseif sEvent == "TurnOff" then
-- Turn Off
sCommand = "OFF " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
end

end

When I run this on the PC (i.e. NR on same PC as Girder) it all works just fine and the light switches as expected. When I run the same CCF on my HP IPAQ it runs NR OK but none of the lights will change and the appropriate messages do not feed into the queues (i.e. I cannot see anything in the LUA Consule).

I do get some messages coming through on the NR_CallBack Event like "Existing Client" and "New Client Connection" but nothing when I click the buttons. On the PC version I get the "TurnOn" and "TurnOff" showing on the Consule and the lights change.

Moving on to the Variable feedback - This works just fine on both PC & IPAQ so that part is cracked (Thanks).

Cheers

Gus

Rob H
May 7th, 2006, 05:38 AM
Do you see the events from the PPC coming in on the Girder logger window?

GusKerr
May 7th, 2006, 06:05 AM
On the PC they are showing just fine but not from the IPAQ. All I get in the Logger window for the IPAQ are the "Adding Client", "Registering Client" etc. After that absolutely nothing ????

Gus

GusKerr
May 7th, 2006, 06:51 AM
Rob,

I have managed to re-create the issue (i.e. get it to work from the IPAQ) but unsure why it has happened and how to resolve it. Basically I seem to have two instances of Girder and the PC is calling one version whilst the IPAQ seems to want to use the other version.

If I am in Net Designer and look at the Element I see Girder (-1) along with all the other Plugins. Under Girder there are 2 instances and if I expand this out I see mediaserver (-1) and MEDIASERVER (-100).

If I run Task Manager from my PC I also find that there are two versions of Girder.exe running (one with 1M of memory and one at about 27). If I close any of these by "end task" the whole of girder shuts down !!

How do I make the IPAQ and the PC use only one instance and also how do I get rid of the other ?

Hopefully this should solve the issue (it's just how).

Cheers

Gus

Rob H
May 7th, 2006, 07:31 AM
I'm guessing that you created one of these yourself and the other one was found by NetRemote using auto discovery.

You can either delete both instances and let NetRemote discover the real instance when it next starts, or disable autodiscovery in File|Properties and delete the -100 instance.

Regarding the two 'copies' of girder.exe in task manager this is perfectly normal and is to do with the copy protection software that Girder uses.

GusKerr
May 7th, 2006, 10:05 AM
I deleted both instances and it then came back on both PC & IPAQ as (-2001). Now works a treat.

Thanks.

My next question:

You said:
I'd probably define multiple event handlers for the different events rather than using a combination of if then elses.

I am fine with creating event handlers but just wanted to check that is the most efficient way of handling each button press from NR when this number gets into the 100's ?

Final thing - Where have all the options to do bold, code etc gone from the forum reply boxes ?

Cheers

Gus

Rob H
May 8th, 2006, 03:45 AM
It should be fine using multiple event handlers, but if you're concerned about it or want to do extra logging or apply the same sort of logic to each of the handlers you could use a table of functions that is indexed by the event string. You might want to do this to simplify the functions for example by just passing the payloads instead of the "event, device, modifier, payloads" parameters e.g. something like this


function NR_CallBack(sEvent, iPluginID, iModifier, sPayloads, uID)
print ("NREvent: ", sEvent)
local func = cbTable[sEvent]
if func then
func(sEvent, unpack(sPayloads))
else
print('Unhandled command '..sEvent)
end
end


and your callback table would looks something like this :-


cbTable = {
["ON"] = function ()
sCommand = "ON " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
end,

["OFF"] = function()
sCommand = "OFF " .. sCOMDataDevice .. "\n"
uSession:Write(sCommand)
uSession:Write("GET " .. sCOMDataDevice .. " level\n")
end,
}


Of course, if you have very similar commands as above then you'd wrap all that sort of code up into a number of functions, rather than duplicating everything e.g. you may want to move the uSession:Write("GET " .. sCOMDataDevice .. " level\n") into the real event handler if it's something that you'd always do.


Oh, and regarding the editor, check the User CP (top left) for the editor options.

GusKerr
May 11th, 2006, 05:41 PM
Makes a lot of sense and so I am working on converting the comand to a table of functions. Got the LUA manual so it is starting to make life easier (well the first few chapters anyway)....

I am also storing the value of each device (i.e. the level of the light) in a separate variable using tables.


DataDevice[sCOMDataDevice] = sCOMDataValue

This gives something like DataDevice[254/56/1] = 255

To handle changes in the lights, I have a Callback in Girder to pick up Script Events from Net Remote. The command I send is "Increase (254/56/1)".



-- Define Net Remote EventHandler Function (232 = Net Remote)
NR_CallBackID = gir.AddEventHandler(".*", 232, 232, NR_CallBack)


My Callback routine is:


function NR_CallBack(sEvent, iPluginID, iModifier, sPayloads, uID)


My challenge is:

The sEvent is "Increase" which is fine but I want to extract the device ID (i.e. 254/56/1). I tried using unpack but this just gives me 2828 10.0.0.8 254/56/1. Can I get the 3rd item or must I use string.find to get the data ?

Cheers

Gus

Rob H
May 11th, 2006, 05:57 PM
You'll need to use string.find() for that.

honnt
May 11th, 2006, 06:05 PM
...or, if unpacking the payloads always gives something in the format "2828 10.0.0.8 254/56/1", looks like you could Split using a " " (space) as the delimiter and item[3] of the resultant table would be your device...

...maybe.

Rob H
May 11th, 2006, 06:10 PM
Ah, just realised that I misread the question.

I thought you meant that you wanted to split the last parameter into its component parts.

You can just use sPayloads[3] to access the third parameter. BTW if that's a form of Hungarian notation then you should use a prefix that indicates that it's a table, rather than a string.

Having said that, I really wouldn't recommend any form of Hungarian notation.

GusKerr
May 13th, 2006, 11:10 AM
I had a good run at developing it now and at last have a working system. :D
Hard work but great satisfaction when it all pieces together and the end to end link "does the job".

THANKS TO YOU GUYS FOR HELPING OUT.

Managed to create a central function to handle any of the light functions by passing parameters from NR so didn't need to worry about amending the callbacks. I have also taken your comments on board about Hungarian notation and removed them from my code.

So here is my Net Remote Screen and the corresponding Girder Code to run it all. Commands from the buttons are in the format TurnOnOff (254/56/1), Increase (254/56/1) or Decrease (254/56/1).

I am not going to take full credit for the design as most of it consists of base elements from all the other designs on the download page with a bit of colour change and a few of my own.

The next stage for this Phase is to create similar screens to accommodate all the other lights in the house and create some preset scenes.

But I am now going to move on with Phase 2 (The Video / Sky + Switcher Box - Extron Crosspoint Matrix).

Mike, you did mention having some code to drive the serial device directly for one of these. Can you point me in the right direction please.

Cheers for now

Gus

Ron
May 13th, 2006, 11:17 AM
Awesome, great job

GusKerr
May 13th, 2006, 01:36 PM
Found some code on the forum to issue commands to the Extron Matrix Switch and it is working fine for getting back current state.

I want to be able read all the outputs using something like


for Cnt = 1, 8 do
Extron:ViewVideoOutPutTie(1)
end


Unfortunately the serial port (or the device) can't cope and it is missing return messages. Is there a pause command in LUA or do I need to create some kind of callback routine to only move onto the next channel when the previous one has been acknowledged.

Cheers

Gus

danward79
May 13th, 2006, 01:45 PM
there is a wait command, but it holds up your thread. win.sleep(200) would pause processing for 200ms

there is also a wait in the serial library you can use to allow your callback conditions to be met

GusKerr
May 13th, 2006, 02:14 PM
It sounds like the Win.Wait Command is not the most sensible approach. Had another look at the output and I wonder if the problem is actually around something else

Here is a dump of the output I am getting

Serial Error (CallLua): ...xis\Girder\/plugins/serial/Extron MatrixSwitcher.lua:63: attempt to concatenate local `command' (a nil value)
...xis\Girder\/plugins/serial/Extron MatrixSwitcher.lua:63: in function `SendCommand'
...ogram Files\Promixis\Girder\/plugins/serial/init.lua:461: in function `SendQueCheck'
...ogram Files\Promixis\Girder\/plugins/serial/init.lua:484: in function `ReceiveResponse'
...xis\Girder\/plugins/serial/Extron MatrixSwitcher.lua:54: in function <...xis\Girder\/plugins/serial/Extron MatrixSwitcher.lua:38>

The Code around Line 63 is


SendCommand = function (self,command,callback)
serial.Classes.Queued.SendCommand (self,command,callback)
gir.LogMessage(self.Name, 'Sent Command: '..command,3)
end,


If I comment out the line
-- gir.LogMessage(self.Name, 'Sent Command: '..command,3)
there are no errors.

Any suggestions as whilst I could check for a Nil value I don't understand why the error is appearing in the first place.

Cheers

Gus

Rob H
May 13th, 2006, 02:52 PM
What's at lines 54 and 38 in the Extron lua file?

GusKerr
May 13th, 2006, 03:12 PM
Code segment enclosed. By the way I got this off another thread and have used it pretty much out of the box.


Also did a quick change to the logging line to remove command and this also solves the problem
BEFORE


SendCommand = function (self,command,callback)
serial.Classes.Queued.SendCommand (self,command,callback)
gir.LogMessage(self.Name, 'Sent Command: '..command,3)
end,

AFTER
SendCommand = function (self,command,callback)
serial.Classes.Queued.SendCommand (self,command,callback)

gir.LogMessage(self.Name, 'Sent Command: ',3)
end,



Cheers

Gus



ReceiveResponse = function ( self, data, code ) - LINE 38

print ('Recieved Command: ', data)


if string.find(data, 'Out%d%d In%d%d Vid') then
self:Log (3,'Command ACK')
gir.LogMessage(self.Name, 'Output Tied '..data,3)
gir.TriggerEvent('UpdateVideoTie',18,data)
end
if string.find(data, 'Out%d%d In%d%d Aud') then
self:Log (3,'Command ACK')
gir.LogMessage(self.Name, 'Output Tied '..data,3)
gir.TriggerEvent('UpdateAudioTie',18,data)
end
serial.Classes.Queued.ReceiveResponse (self,data,code) - LINE 54

end,

Rob H
May 13th, 2006, 05:16 PM
For improved logging you might want to use something like this :-


gir.LogMessage(self.Name, 'Sent Command: '..(command or 'nil'), 3)

GusKerr
May 14th, 2006, 11:05 AM
Working my way through creating the Sound & Vision Distribution Screens in Net Remote and have a couple of questions about how this can be enabled to interact with Girder:

1 - On opening the "Sound & Video" screen in Net Remote I want to call a routine to refresh the current state of the Extron Ties. Is it possible to have an event driven call made to Girder (i.e. when the particular screen is opened I want to run a LUA script).

2 - Each screen has a similar set of buttons represented by the different input units. Now rather than me hand coding each button with all the unit numbers I want to call a LUA script (fine with that bit). BUT, I want to pass a parameter based on the number of the frame it is contained within. i.e. Bedroom 1 would call the script that says switch me to SKY + and I am in Bedroom 1 (something like ChangeTie(1, 2) where 1 is the Output for Bedroom 1 and 2 is the Input for SKY +.
If I put all the buttons in a Frame then I would call it Frame 1 and try and grab this value to pass as the first parameter. The second parameter would be coded into the button itself.

Hope this makes sense

Cheers

Gus

P.S. Thanks for the last tip on how to prevent errors when logging data.

Rob H
May 14th, 2006, 11:12 AM
Working my way through creating the Sound & Vision Distribution Screens in Net Remote and have a couple of questions about how this can be enabled to interact with Girder:

1 - On opening the "Sound & Video" screen in Net Remote I want to call a routine to refresh the current state of the Extron Ties. Is it possible to have an event driven call made to Girder (i.e. when the particular screen is opened I want to run a LUA script).

Look at RegisterPanelWatch() in the manual



2 - Each screen has a similar set of buttons represented by the different input units. Now rather than me hand coding each button with all the unit numbers I want to call a LUA script (fine with that bit). BUT, I want to pass a parameter based on the number of the frame it is contained within. i.e. Bedroom 1 would call the script that says switch me to SKY + and I am in Bedroom 1 (something like ChangeTie(1, 2) where 1 is the Output for Bedroom 1 and 2 is the Input for SKY +.
If I put all the buttons in a Frame then I would call it Frame 1 and try and grab this value to pass as the first parameter. The second parameter would be coded into the button itself.

Not sure that this is currently possible.

GusKerr
May 14th, 2006, 11:52 AM
Where do I get a NetDesigner Manual ?

All I seem to have is the Net Remote Pro Setup and User Guide which doesn't mention any of this commands.

Cheers

Gus

Rob H
May 14th, 2006, 12:42 PM
Assuming you are using NR Designer then just use the help from there.

GusKerr
May 14th, 2006, 05:09 PM
OK found the command but documentation is pretty limited:

[handle] = RegisterPanelWatch([devname], [panelname], [panelcallback])

Kind of makes sense but what is the devname and how do I set this up ?

Searched the forum for this command and found very little (i.e. this thread and one other).

Some example code would be very helpful.


Cheers

Gus

Rob H
May 15th, 2006, 04:53 AM
devname is the page group in NRD terminology and panelName is the page.

Here's an example from Dan's NR Demo CCF :-



RegisterPanelWatch("Lights & Power", '*', function ()
NetRemote.ExecuteAction(-1,0,1,"X10GetCurrentState");
end);


When the user switches to any of the pages in the Lights & Power device it will ask Girder to send the current X10 state.

In that example the page name is given as '*' which indicates that it will match any page in the Lights & Power group. You can also be specific about the page e.g. :-



RegisterPanelWatch("JRMC", "Covers", function ()
NetRemote.SetVariable('UPAVL',0);
loadGAC();
NetRemote.SetVariable('MP.GACCount','20');
NetRemote.SetVariable('MP.GACSize','L');
NetRemote.ExecuteAction(-10,2,255,'GAC "{MP.GACScheme}" {MP.GACStart} {MP.GACCount} {MP.GACSize}',1);
end);


Both these examples use anonymous functions declared inline, but you can of course use a named function if you prefer.

GusKerr
May 15th, 2006, 05:10 PM
Brilliant - just the kind of example I needed.......

BUT

If I place my script in the \Netremote\luascript directory it fails to run so not sure if I have to do something.

If I place it in the \Netremote\luascript\startup directory I get an error as it tries to run prior to the PanelWatch LUA script (my lua script is currently called MyCCF.lua). Should I make it part of Panelwatch.lua or is there a better way.

Cheers

Gus

Rob H
May 15th, 2006, 05:17 PM
The usual way to do this is either to put the code in the CCF's Lua file or use a separate script in the luascript directory and use the require() function in the CCF's Lua file to load it.

To edit the CCF's Lua file, right click on the System node in NRD and select "Edit Lua script file"

GusKerr
May 15th, 2006, 05:34 PM
Gone for the Require Function which now works a treat.

Thanks again.

Gus

Rob H
May 15th, 2006, 05:45 PM
No problem - it's what I'm here for :)

GusKerr
May 17th, 2006, 05:36 PM
I am getting a problem that is confusing me a bit....

I have some code in the LUA Script for taking the feedback from the Extron Device and in this case I am reading back the Output Port that is tied to the Input Port.



_, _, OutputChannel, InputChannel = string.find(Data, "OUT(%d)%sIN(%d)%sVID$")
if OutputChannel ~= nil then
XVideoPort[tonumber(OutputChannel)] = InputChannel
NetRemote.SetVariable("NR_XVideoPort[" .. OutputChannel .. "]", InputChannel)
end


If this is a valid value (i.e. not nil) then I am storing them in a Table called XVideoPort using the Output Channel as the index. You will see I have added the statement "tonumber" because of the problem I am encountering. It appears that this is being stored as for example XVideoPort["1"] = 1 .

I then have a Girder Script that is called from Net Remote that creates a string of the current state for all Outputs against any output (I have 5 inputs and 8 outputs).



for DeviceNo = 1, 5 do
DeviceMatrix[DeviceNo] = ""
for PortNo = 1, 8 do
if (XVideoPort[PortNo]) == DeviceNo then
DeviceMatrix[DeviceNo] = DeviceMatrix[DeviceNo] .. PortNo
else
DeviceMatrix[DeviceNo] = DeviceMatrix[DeviceNo] .. "X"
end
end
NetRemote.SetVariable("ExtronDevice[" .. DeviceNo .. "]", DeviceMatrix[DeviceNo])
end
end


This ultimately send the various strings back to Net Remote for display on the screen. Now without the "tonumber" in the first script the condition always fails.

My understanding of LUA was that it would always try and convert to a number but this doesn't seem to hold true. Any suggestions ?

Cheers

Gus

Rob H
May 17th, 2006, 05:47 PM
There are certain exceptions to the number conversion rule. One of them is in comparisons, and another is when indexing tables. Basically, you need the explicit conversion using tonumber as you have found.

GusKerr
May 27th, 2006, 01:34 PM
I have now bought an IRTrans Unit with a six spider transmitter. One of the transmitters is now placed in front of each device (Sky+ and Extron just now) so that I can use the IPAQ with Net Remote to control them.

I have built a simulated Sky+ Digital remote usung Net Designer and now want to use these buttons to send the appropriate commands. This means I can be anywhere within wireless range to use it.

So I have set it up so that NR send a command to Girder i.e. Sky+(1). This is captured in Girder via the Call back function with the payload of "1" in this case. This provides me with ability to send a command to IRTrans via LUA code
BUT

How do I send the IR code for "1" out of the IRTRans device ?

Can you steer me down the right track please as I can't find anything in the forum about LUA control.

Cheers

Gus

Rob H
May 27th, 2006, 02:07 PM
The usual way to do this is to use gir.TriggerEvent to trigger an action that contains a learned IR code. I would probably recommend that rather than a plain action, you use a macro that contains the IR action, followed by a short Wait action.

For multiple digits e.g. to change to a given sky channel you'd trigger the events in a loop or even a string.gsub e.g.



string.gsub(channel, '(%d)',
function(digit)
gir.TriggerEvent('SKY.'..digit, 18)
end)

GusKerr
May 27th, 2006, 03:17 PM
Did some more searching and came across IRTrans Command

IRTrans.SendIR ("SKYPLUS","Ch+",0,0,"both")

Tried to use this put keeping getting a timeout which I don't understand.
I have a SKYPLUS.rem file with this Ch+ command contained within it.

Current command is [Ch+][T]0[D]S11100000000000000000100000

But back to your suggestion about gir.TriggerEvent how would this work:

Would I use
gir.TriggerEvent('SKYPLUS' .."Ch+", 18) or
gir.TriggerEvent('SKYPLUS' .."11100000000000000000100000", 18) or
something different ?

What is the 18 for ?

Cheers

Gus

Rob H
May 27th, 2006, 05:49 PM
I don't have any experience with the IRTrans I'm afraid.

Of those two I'd suggest the first one, which would trigger an action that actually sends the IR, either using IRTrans.SendIR or using a learned action.

The 18 is the device that responds to the event, and in this case corresponds to a Girder event. See the help file - Lua Library Reference\gir library.

GusKerr
May 31st, 2006, 12:09 PM
Couldn't see any problems with my Girder scripts so back-tracked a bit to understand the IRTrans device. They include some very good debugging tools and a simple VB app to allow testing the device. After creating a basic test harness I sent all the results to Marcus at IRTrans and it appears I have a duff piece of hardware (it happens:( ). That's the bad news.

The good news is that Marcus is shipping out a new device and I should be in a position to move on with my development later this week.

Point to note - Since going down the Girder route I have been very impressed with the support from the Promixis team (and that includes all the various users on this forum). To see the same level of dedication and support from IRTrans is, in my experience, a rare asset in these days of money pinching Corporate cultures.

Final Point - UIRT vs IRTRANS
Both devices look very similar and to be honest I would probably have gone for "your" device but for the fact I am in the UK and you are across the water (EU countries can do VAT). The other pro for IRTrans is that it has a great 6 way IR transmitter that can be used for all my devices.

Will update on progress soon.

Cheers

Gus

Rob H
May 31st, 2006, 01:07 PM
Thanks Gus.

BTW The USB-UIRT is available in the UK - see the link from the USB-UIRT website. ISTR that the UK vendor is Darren Karp whom you may know from the UKHA-D discussion list.

GusKerr
June 3rd, 2006, 02:47 PM
Got my new IRTrans device in the post and plugged it in only to find exactly the same error (scratch of heads....)

Back to Marcus who suggested a new USB cable. Purchased a new one at Maplin for &#163;4.99 (by the way don't go to Curry's or Dixons as exactly the same cable costs &#163;14.99 !!!).
Everything then worked (never had a problem with a purchased cable before in my life) so happy man.

So to update progress - I have created a NR screen to control the whole of sky+ and added some code around each control using the SendCommand - SkyDigital(Select) is an example behind the "Select" button. Within Girder I have a simple Callback that picks up commands from NR and issues these to the IRTrans device. This is based on me creating a file of all these commands within the IRTrans System that have these commands (Again this is really easy as Marcus has included a simple VB app that allows you to learn any command).

This is the code in Girder:


function NR_CallBack(Event, PluginID, Modifier, Payloads, ID)
-- Get Parameter
DeviceID = (Payloads[3])

-- Send all Sky+ Commands
if Trim(Event) == "SkyDigital" then
print("SkyDigital", DeviceID)
IRTrans.SendIR("SKY-DIGITAL",DeviceID,0,0,"both")
end
end


So now I have Lights, Video and sound switching, remote control via wireless of Sky+. So now it is wireless IP cameras & music.

Gus

GusKerr
July 22nd, 2006, 05:09 PM
It has been a wee while since I have posted due to the fact that I have been working on the physical installation of the C-Bus Network into the house. I have been working on getting the whole of the 2nd floor (currently the top floor) installed. This involves ripping out the existing light switches, replacing them with C-BUS switches and then linking them back to the central control unit. In addition all lights must then be wired back to the dimmer switches. I have also installed a light / occupancy sensor and a temperature sensor. I am half way there but it is all working great.

I have also been working on the NR interface so now have wireless access via my IPAQ to all the SKY+ functionality from any room + the ability to push SKY to any telly. All lights can also be controlled by this unit or the switches on the wall (on / off and dimming). Sample of some of the screens are enclosed.

So my problem is now:

The temperature sensor is one of the original C-BUS devices and is somewhat lacking in functionality. I have got Girder calling C-BUS for a temperature reading but all manual at this stage. I want this to be automatic so looked at the scheduler functionality. From what I can see this will only go down to an hourly call. How do I run a routine every minute ?

Regards

Gus

Promixis
July 22nd, 2006, 11:45 PM
Gus,

use the

gir.CreateTimer

function and set it up to call the function to check the temperation every minute.

GusKerr
July 29th, 2006, 03:13 PM
Thanks for the help on the Timer Mike.

So on to my next task - Database access.

I am looking to store the various CBUS messages into a Database so that I can analyse what happens in a typical day and then play this back at a later date (e.g. to put off burglars). It will also allow me to record light levels, temperature levels in rooms and analyse this via Excel or whatever (it's almost sad but heck I think the fun is more in the challenge.....).

So to my problem.

I cannot get the database connection to function which is kind of stopping me moving on. I have searched the forum for help and this has got me so far but would appreciate some more help. I have enclosed the code showing the 2 options I have tried so far.



require("odbc", "luaopen_luasqlodbc" )
Environment = assert(luasql.odbc())
--Connection = assert(Environment:connect("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\Promixis\\Girder\\HomeAutomation.mdb"))
Connection = assert(Environment:connect("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\Program Files\Promixis\Girder\HomeAutomation.mdb;UID=Admin ;Pwd=;"))
Environment:close()


Cheers

Gus

Promixis
July 29th, 2006, 07:03 PM
Gus,

I will leave this one for Ron.

mhwlng
July 30th, 2006, 02:16 AM
I use:

Environment:connect("trend")

and open 'data sources(odbc)' in 'control panel\administrative tools' and add a system DSN :
name : trend
driver : microsoft access driver
database c:\program files\promixis\girder\trend.mdb

(see trend.lua and callerid.lua in marcel2.0.zip via the url in my sig)


Marcel

GusKerr
July 30th, 2006, 11:56 AM
Many thanks Marcel,

I have had a look through your code and picked up enough information to get the Access Connecton functioning just great. :D

Also picked up a bit of code to get the current date & Time as a DateTimeStamp so hope you don't mind. Now that I have got the basics working with Access hope to amend this to write the information to a SQL Table so that I can read this information into an ASP Page on the web.



function LogCBUSMessage(DeviceID, Result)
require("odbc", "luaopen_luasqlodbc" )
local Environment = luasql.odbc()
local DBaseConnect,ErrMsg = Environment:connect("HomeAutomation")
if not DBaseConnect then
gir.LogMessage('HomeAutomation.LogCBUSMessage', ErrMsg, 1)
else
local DateTime = win.GetLocalTime()
DateTimeStamp = string.format("%02d/%02d/%02d %02d:%02d",DateTime["Day"], DateTime["Month"], DateTime["Year"], DateTime["Hour"], DateTime["Minute"])
local Return,ErrMsg
SQLString = "INSERT INTO DeviceTracking (DateTimeStamp, DeviceID, Result) VALUES('" ..DateTimeStamp.. "','" ..tostring(DeviceID).. "'," ..Result.. ")"
Return,ErrMsg = DBaseConnect:execute(SQLString)
if not Return and ErrMsg ~= "" then
gir.LogMessage('HomeAutomation.LogCBUSMessage', ErrMsg, 1)
end
DBaseConnect:close()
end
Environment:close();
end


Hopefully I should be OK for a few more days whilst I build up the code to create the rest of the functionality around this topic.

Cheers for now

Gus

GusKerr
July 31st, 2006, 04:43 PM
:confused: Sorry but I am having a dumb moment and have been trying to figure out a command for most of the evening but without success. I have tried many combinations but the code below is my latest.

CGATE_COM is 320- Application 56 ($38) [lighting]



if string.find(CGATE_COM, "(.w)%sApplication%s(.d+)%s.-%[Lighting]") then
print("Found")
end


Why oh why won't it find it ?

Cheers

Gus

GusKerr
July 31st, 2006, 05:37 PM
Kept persisting and found the issue - Lighting should have been lighting (case sensitivity).

Doh................

GusKerr
October 6th, 2006, 04:23 PM
It's been a couple of months since I posted but I thought it was time to bring the thread back to life.

An update first:
Now have the whole of the top floor kitted out with CBUS technology so that every switch is CBUS and every light comes back to the "Control Centre". Also have movement and temperature sensors installed. So what does Girder do ?
Well it links into the CBUS network and now takes all relevent messages from the network and logs them in a database. I can then use Excel or the Internet to display this date. Also got Net remote on my IPAQ doing the lights and displaying temperature all via a wireless connection. Oh and to top it all it can play my music collection via Media Centre. Really waiting to install my LCD TV and Surround sound to finish this off.

Looks like March now for our loft extension and that it when it really comes to life as I am installing CBUS everywhere. So I will now be able to send SKY+ or DVD to any screen in the house, control SKY+ from anywhere, manage all lights, blinds, music and probably more all from a touch screen on the wall (bought from ebay @ &#163;80) or the wireless IPAQ.

The current task has been the outside and so I have installed floodlights, movement sensors and light sensors. These are being linked into the CBUS network. Finally I have bought some downlighters for the eves and with blue bulbs now installed look just the business in those winter nights.

AND HERE IS MY PROBLEM:
Having searched the archives I see mention of "Scheduler Plugin" but cannot locate it. Basically I want the outside downlighters to come on from darkness (about 7.00pm at the moment) until about 11.00pm. This will involve a mixture of timers and light sensors. The sensors are driven by CBUS so have this info but what is the best way to run a daily schedule of checking ?

Gus

Ron
October 6th, 2006, 04:26 PM
the scheduler comes with Girder (4+)

GusKerr
October 6th, 2006, 04:29 PM
I have v 4.0.5.1 (361).

Does that mean I need an update ?

By the way I wish to program this via LUA - Is this possible ?

Gus

Ron
October 6th, 2006, 04:31 PM
version is fine. Do you have G4 Pro or WHP? If so then you should be able to enable this plugin in the plugin settings.

GusKerr
October 6th, 2006, 04:50 PM
I have G4 Pro and can locate the Scheduler Plugin in the Actions Menu
BUT
I want to be able to add some code to my script - something like

Trigger Event (i.e. check every day)
If DataDevice["254/p/4] > 56 Then - This is the CBUS light sensor
Session:Write("ON 254/56/20\n") - turn on outside light
else
Reset timer to try in an hour
end

Hope this makes sense and you can help Ron.

Gus

Promixis
October 7th, 2006, 02:27 PM
Gus,

Have you looked at

gir.CreateTimer ?

ie

function CheckDayLight ()

...

end

CheckDayLightTimer = gir.CreateTimer (nil,CheckDayLight,nil,1)
CheckDayLightTimer:Arm (60000) -- check once a minute

GusKerr
October 16th, 2006, 05:45 PM
Thanks for help with my last challenge.

Now my next one (more Girder than me I think) - Is there any way to adjust the columns on Variable Inspector (1st one in particular) as I can't see the full name of the variables ?

Gus

Rob H
October 17th, 2006, 05:01 AM
Yes, as with most list controls with a header if you move your mouse over the divider between Name and Value the cursor should change to something like <-|-> and you can then drag that to the right to resize the column

Ron
October 17th, 2006, 09:53 AM
Lua is pretty darn good.

http://www.lua.org/manual/5.0/manual.html#5.3

GusKerr
October 17th, 2006, 03:45 PM
Rob,

I was expecting to be able to do the same (as per Excel style). Interestingly I can do this in Net Designer and this has titles at the top which can be dragged around. In Girder the column headings do not appear and I cannot move the information.

Then thought I would try a bit of checking on version numbers. Currently running v4.0.5.1 so downloaded v4.0.12.1 and hey presto it works. Not sure if this was a bug in this version or the over right did ther job but I am happy.

Ron,

Thanks for the link. It also gives a great amount of detail at the end of the page on how to use the raw interface (debug mode) to query such information.

As always much appreciated


Gus

GusKerr
January 8th, 2007, 04:01 PM
Will,

Best to post in the Forum so that anyone can share knowledge. I have just searched through under C-BUS and found a recent post to which I have replied.
http://www.promixis.com/forums/showthread.php?t=15448&highlight=cbus

This should give you an idea of the possible.


I have most of my experimentation posted in the undernoted thread (this one) so would refer you to this as I will update it tonight.

http://www.promixis.com/forums/showthread.php?t=14311&highlight=cbus

Cheers Gus


sorry to PM, I'm new to Girder and am evaluating Cbus,

could you point me in the right direction for controlling Cbus ?

I'm also evaluating CQC, but that's very expensive in comparison to Promixis...


many thanks for any help !

Will

GusKerr
January 8th, 2007, 04:13 PM
This is my attempt at coding Girder. I know it not the most perfect code and I do intent to tidy it up, make it more efficient and make it a Plugin at some stage BUT
Time is at a premium and it works....

But it may help....

Please post here if you have any specific questions but if you copy the initialisation routine you should get a single light switching on for Bank 1 of device 56 (lighting dimmer in my case). It also runs a few timer Events but these are not needed if you want something simple. I have tried to comment the rest of the code as best I can but sometimes it can be hard to follow.

Gus

rickd
April 21st, 2008, 01:27 AM
Hi I am keen to understand how this is going as I want to integrate cbus lighting wireless and or heating

how far did you get do you have a provider or device manager under G5?

did you use ip controller from cbus this code looks like it uses the gip lua code?

yamy125
July 1st, 2008, 07:49 AM
Also interested to know how you got on. I'm just looking at running c-bus throughout the house and think Promixis Girder/Netremote could be an ideal control solution if this is made relatively 'easy' :)