Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Ceiling Light Control

  1. #11
    Automated Home Jr Member
    Join Date
    Sep 2009
    Posts
    23

    Default

    Quinten - this really looks good - I am very pleased that you pointed these products and methodologies out to me.

    Can I just take this in some baby steps as I've never used Perl before.

    1. Do I set the code that you posted in the first URL running in the background via the terminal in OS X? This then listens for appropriately structured UDP commands - is this correct?

    2. Would you mind showing me, as an example, exactly what I would type into the terminal in OS X to switch on say a lamp with an address code of C 12?

  2. #12
    Automated Home Sr Member Quinten's Avatar
    Join Date
    May 2004
    Posts
    85

    Default

    Ok, this is without knowing what is installed on OS X by default, although I do believe Perl is.

    The 2nd script (lovingly called "noddy perl script to send an UDP message"), is like a normal command, you would invoke it in Terminal like:

    $ ./client.pl [ip address of controller] <message>

    The script contains a default ip address of 192.168.0.99, which will be used if you do not specify it on the command line.

    A proper example would be:

    $ ./client.pl 192.168.1.12 "D:1A01:E"

    This would send the command "D:1A01:E" to the online controller on ip address 192.168.1.12. The command "D:1A01:E" can be broken down as follows:

    D:<on or off><device id>:E

    "D:" and ":E" are begin and end message identifiers
    1 = switch on, 0 = switch off
    A01 = device id

    So to switch device C 12 on, you'd send:

    $ ./client.pl 192.168.1.12 "D:1C12:E"

    Hope that helps... somewhat

  3. #13
    Automated Home Jr Member
    Join Date
    Sep 2009
    Posts
    23

    Default

    Got it - thanks for taking the time to take me through it.

    I've just checked in the Terminal from OS X and Perl is indeed installed.

    So I fire up the listener app you mentioned first of all. Then in the terminal send the UDP command you outline. Sweet!


    I've just tried running the listener app and it fails on syntax but that's probably because I just cut and paste the app in - I need to research how to run it properly from within the terminal.

    Am I correct in believing that the listener app is started initially and then runs permanently in the background listening for the appropriate UDP commands?

  4. #14
    Automated Home Sr Member Quinten's Avatar
    Join Date
    May 2004
    Posts
    85

    Default

    Correct, the listener app, runs in the background. You don't need it to send commands to, btw, it is just there to show you what the online controller receives. For each command the online controller receives, it will broadcast an UDP message on your network detailing what it received. You can then do what you want with the information (I store the status of each device in a mysql database for instance).

  5. #15
    Automated Home Jr Member
    Join Date
    Sep 2009
    Posts
    23

    Default

    Quentin - I've been trying to run your listener app on my Mac prior to purchasing all the hardware etc. but I can't seem to get it working.

    Do you mind if I outline what I've done and see if there's anything glaringly wrong?

    Any other Perl/OS X experts out there please feel free to chime in also.


    Process

    1. Cut and pasted your listener app script into Text Wrangler (a text editing program)
    2. Saved the file with .pl extension to my desktop. My filename is listener.pl
    3. Launch the Unix terminal in OS X
    4. Typed cd ~/Desktop
    5. Typed perl -e listener.pl


    But nothing happens! I just get the normal Terminal prompt. I realise that I should not be expecting any feedback from the controller since I don't have one yet but should I not at least see the line "Awaiting UDP messages on port 53007" in the terminal. I checked the Console application also for output but there was nothing there either.

    Any ideas as to what I might be doing wrong?

  6. #16
    Automated Home Sr Member Quinten's Avatar
    Join Date
    May 2004
    Posts
    85

    Default

    Hiya,

    I've just done the same thing on my Macbook and I am getting the same result. So a quick perl --help later and it reveals you can just call it like this:

    $ perl listener.pl

    or alternatively, make an executable from it by:

    $ chmod +x listener.pl
    $ ./listener.pl

    Q.

  7. #17
    Automated Home Sr Member Quinten's Avatar
    Join Date
    May 2004
    Posts
    85

    Default

    And if you want to test it, you can use the other script, and change the port number in that to 53007 (so the same as the listener). Then call it as follows (in a new Terminal):

    $ ./client.pl localhost "Parsing |D:1A01:E|"

    That's exactly what the Online Controller would broadcast over UDP.

  8. #18
    Automated Home Jr Member
    Join Date
    Sep 2009
    Posts
    23

    Default

    Quinten - just got around to trying this out now. It works beautifully. Thanks again for taking the time to take me through this. I really appreciate it.

    For any others wishing to try this on their Mac I had to make a couple of very minor adjustments to get it working. I'll detail them here to save others time -

    • Each program seemed to have unrecognized characters when I pasted them into Text Wrangler. I simply deleted all leading spaces on each line of the programs. Anyway the terminal will give you a message such as "Unrecognized character \xC2 in column 8 at client.pl line 9" so you can tell which lines are affected.
    • I had to comment out "!/usr/bin/perl -w" by adding "#" before that line in the client.pl program


    That was all. Now to buy the hardware!

    EDIT: Is there a command to Dim via the Online Controller?
    Last edited by rarem; 23rd September 2009 at 07:49 PM. Reason: Add question on Dimming

  9. #19
    Automated Home Sr Member Quinten's Avatar
    Join Date
    May 2004
    Posts
    85

    Default

    Glad you got it working

    You can not issue a Dim command (there is no such thing), but you can do the same thing as what a wall switch needs to do in order to dim. Press the On button twice, and the receiver will dim up and down until you press the On button again. So with Online Controller, you'd send 2 On commands, followed by another On to stop the 'disco'. Dim levels remain stored though.

  10. #20
    Automated Home Jr Member
    Join Date
    Sep 2009
    Posts
    23

    Default

    So I finally got my Online Controller only to find that it was old stock so I've had to send it back to Domia for the firmware upgrade. Grrr!

    But in the meantime I had it just long enough for another few questions to occur to me (sorry Quinten!).

    • I plug the Online Controller into my Airport Extreme router. Do I need to open any ports in the Firewall? I'm running Snow Leopard
    • How do I find the IP address of the Online Controller in order to hardcode that number into the Perl script and does that IP number change over time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •