in

Actions from one webbrick to another

Last post 10-26-2009 2:56 PM by andy.harris. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-11-2009 10:27 AM

    Actions from one webbrick to another

    I have installed Python on my computer and written a program called C:\Program Files\Python\RAS_Code\Bedtime.py which turns off all lights across several webbricks.

    I can run this by double-clicking on the shortcut I have put on my computer's desktop.

    I want to run this program by pressing a switch.

    I have a spare switch and DI on one webbrick.

    I presume I need to Configure that DI to have UDP Packet Type = Remote and Associated Value = <some number>

    How do I get the computer to "catch" the UDP Packet?

    I couldn't find an answer in v6.6 of the manual.

    I see some code at http://docs.webbrick.co.uk/eventinterfaces/WebbrickUdpEventReceiver.html

       What do I run it in?

        What else do I need to do?

    RAS

  • 07-13-2009 10:19 AM In reply to

    Re: Actions from one webbrick to another

    Hi Richard,

    It is great to see how users of WebBricks start to write their own scripts to run functions and we like to encurage this development. I shall answer your questions in two ways:

     

    Option 1:

    Option one to solve your problem ('pressing a button on one webbrick and issuing a single or multiple commands to other webbricks') is straight forward and suitable for the majority of WebBrick users and installers. We offer the WebBrick Gateway, which is a software application that can easily be configured to listen to WebBrick events and send out commands to other WebBricks. The WebBrick Gateway provides what we refer to as 'global inteligence', whilst the WebBrick Controllers provide 'local control'. The gateway provides many other useful features apart from simply mapping events from one WebBrick to another, such as: 

    • Central Scheduling Facilities
    • HVAC Control
    • Temperature and Energy Monitoring
    • Conditional Evaluation of states around the house
    • Astronomic Scheduling (i.e. based on sunrise & sunset)
    • A rich User Itnerface
    • etc.

    At the moment the Webrick Gateway is distributed as a preinstalled appliance (a low-power embedded PC). We have a public WebBrick Gateway you can take a look at, to get an idea of the default userinterface we provide. 

    http://195.26.42.82:8080/ 

     

    Option 2:

    If you however want to keep writing your own python code, then by no means would we want to discourage this. I have to point out though that we cannot offer support for your custom code or be of assistance on queries about general python coding. We will however do out best to make sure that you have all the information about WebBricks you need to be able to write your own code.  

    As you rightly say WebBricks send out UDP packets on port 2552. These packets are boradcast packets and hence can be picked up by network device that is on the same subnet. You can use the WebBrick Monitor (which can be found here: http://community.webbricksystems.com/files/folders/441/download.aspx) to see these packets on your network or alernatively use a free application like Wire Shark. To write an application in python that listens for these UDP packets, you will have to open a socket and listen for packets on taht socket. Have a look at the inbuilt socket library in python, a minimal bit of code that opens a socket and listens for a single packet could look something like this: 

    >>> import socket
    >>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    >>> s.bind(('',2552))
    >>> s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 65536)
    >>> data = s.recvfrom(32)
    >>> data
    ('\rGST\t\x1a\\R\x00\x01X\xb0\xb0\x00\x00\x00', ('10.100.100.82', 4096)) 

    Filed under:
  • 10-25-2009 1:39 AM In reply to

    Re: Actions from one webbrick to another

    I would like to add voice control to my pc - enabling commands for both local bricks - which I already have woerking and also for across bricks - which I have yet to master.

    Anyone who has done this please let me know :~)

  • 10-26-2009 2:56 PM In reply to

    Re: Actions from one webbrick to another

     Ravi

     This will be straightforward if you can get your voice control software to issue HTTP requests.  I suggest that you use 'sendevent' requests to the gateway and they use the gateway to send whatever commands to the WebBricks, or zone control applications etc.

     Regards

     

    Andy

Page 1 of 1 (4 items)
(c) WebBrick Systems