Announcement

Collapse
No announcement yet.

Rako RA Bridge

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Rako RA Bridge

    Having been a lurker for some time, i thought it about time i contributed something that might help others.

    I'm running HS2 with Zwave (x10 proving unreliable) and now branching into Rako for lighting & human interface (switches)

    After spending the Easter break glued to my laptop, I've created a perl script that watches for udp broadcasts from the RA Bridge (which happens whenever a Rako switch is pressed) then takes the recieved Hex string and forwards it to HS in the form of an ASP call.

    You'll need a copy of perl installed, then i just have an entry in startup that calls the script and leaves it running.

    Please feel free to copy and use!

    Perl Script

    Code:
    require LWP::UserAgent;
     
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->env_proxy;
    
    use IO::Socket;
    while (1) {
    
    print "Starting UDP Service\n";
    my $server = IO::Socket::INET->new(LocalPort=>9761,Proto=>"udp")
      or die "Can't create UDP server: $@";
    my ($datagram,$flags);
    
    while ($server->recv($datagram,50,$flags)) {
      my $ipaddr = $server->peerhost;
      my $hex =unpack('H*',$datagram);
      print "rx: $hex\n";
      my $source = substr($hex,2,2);
    if ($source eq "07") {
      #script to push url here...
      print "tx: http://192.168.1.6/rako.asp?rako=$hex\n";
      my $response = $ua->get("http://192.168.1.6/rako.asp?rako=$hex");
      if ($response->is_success) {
         print $response->decoded_content,"\n";  # or whatever
      }
      else {
         die $response->status_line;
      }
    
    }
    }
    }
    ASP (rako.asp)
    Code:
    <%
    dim rako_code
    rako_code = request.querystring("rako")
    
    'bedroom
    if rako_code = "5307000b00310001c3" Then
        hs.TriggerEvent "Rako MB On"
        response.write "HS: MB1"
    end if
    
    if rako_code = "5307000b00310002c2" Then
        hs.TriggerEvent "Rako MB Overbed"
        response.write "HS: MB2"
    end if
    
    if rako_code = "5307000b00310003c1" Then
        hs.TriggerEvent "Rako MB Dim"
        response.write "HS: MB3 Light Dim"
    end if
    
    if rako_code = "5307000b00310004c0" Then
        if hs.devicestatus("Q31") = 3 Then
            hs.TriggerEvent "Bedtime On (Bed)"
            response.write "HS: MB4 Bedtime On"
        else
            hs.triggerEvent "Confirm On"
            hs.Transmit "Q31","off"
            response.write "HS: MB4 Bedtime Off"
        end if
    end if
    
    if rako_code = "5307000b00310000c4" Then
        hs.triggerEvent "Rako MB Off"
        response.write "HS: MB0 Lights Off"
    end if
    
    %>
Working...
X