Difference between revisions of "OWN OpenWebNet Language Reference"
		
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
		
		
		
		
		
		
	
| Line 57: | Line 57: | ||
| *#4*#1*#14*0225*3## Set heating zone 1 manually ON to 22.5°C | *#4*#1*#14*0225*3## Set heating zone 1 manually ON to 22.5°C | ||
| </pre>''' | </pre>''' | ||
| + | |||
| + | |||
| + | |||
| + | == A Monitor Session with Python == | ||
| + | To understand the OWN commands a bit better, you should start a monitor on your Raspberry pi and watch the OWN messages coming in. Analyzing these messages gives you an idea how it works. Below is the source of a simple monitor script in Python. | ||
| + | |||
| + | <pre>#! /usr/bin/python | ||
| + | # -*- coding: utf-8 -*- | ||
| + | import socket | ||
| + | |||
| + | # IP address and port to connect to the gateway, please attapt to your environment | ||
| + | default_gateway_host = "192.168.60.201" | ||
| + | default_gateway_port = 20000 | ||
| + | |||
| + | gateway_addr_port = default_gateway_host, default_gateway_port | ||
| + | |||
| + | def monitor(): | ||
| + |     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
| + |     try: | ||
| + |         sock.connect(gateway_addr_port) | ||
| + |         data = sock.recv(1024) | ||
| + |         # expect ACK from gateway | ||
| + |         if data != "*#*1##": | ||
| + |             raise Exception("Did not receive expected ACK, but: "+data) | ||
| + |         # Switch session to MONITOR mode | ||
| + |         sock.send("*99*1##") | ||
| + |         data = "" | ||
| + |         while 1: | ||
| + |             # Read data from MyHome(R) BUS | ||
| + |             next = sock.recv(1024) | ||
| + |             if next == "": | ||
| + |                 break               # EOF | ||
| + |             data = data + next | ||
| + |             eom = data.find("##") | ||
| + |             if eom < 0: | ||
| + |                 continue;           # Not a complete message, need more | ||
| + |             if data[0] != "*": | ||
| + |                 raise Exception("Message does not start with '*': "+data) | ||
| + |             print data | ||
| + |             msg = data[1:eom] | ||
| + |             data = data[eom+2:] | ||
| + |     finally: | ||
| + |         sock.close() | ||
| + | |||
| + | monitor()</pre> | ||
| == The Tables of WHO WHAT WHERE == | == The Tables of WHO WHAT WHERE == | ||
Revision as of 23:45, 15 November 2014
The OpenWebNet protocol was defined in 2000 by Bticino/Legrand to specify the communication with a Bticino domotic gateway, connected via LAN, RS-232 (serial) or USB.
Contents
Basic Syntax Rules
A Bticino gateway receives and sends OPEN messages:
- A message is a simple string, containing the characters asterisk (*), hash (#) and numbers from 0 to 9.
- each message begins with an asterisk (*) and ends with a double hash (##).
- within the message, fields are separated by an asterisk (*).
Example: *field1*field2*field3*...fieldN##
The following table shows the allowed syntax:
| Message Type | Message | Note | 
|---|---|---|
| ACK | *#*1## | Message accepted/understood | 
| NACK | *#*0## | Message not accepted/understood | 
| Standard | *WHO*WHAT*WHERE## | Standard message | 
| Status Request | *#WHO*WHERE## | Request a state (e.g. if a light is ON or OFF) | 
| Dimension Request | *#WHO*WHERE*DIMENSION## | Request a dimension | 
| Dimension Write | *#WHO*WHERE*#DIMENSION*VAL1*VAL2*...*VALn## | Write a dimension | 
Standard Message
In the table above, we learned a Standard Message consists of  *WHO*WHAT*WHERE##  .
- WHO identifies the service, such as scenario, light or automation
- WHAT is the action to be performed, such as light ON/OFF or dimmer, shutter up/down etc.
- WHERE identifies the object, which can be an area, group, an environment, or just a single light or shutter etc. A WHERE field can also come with optional parameters, separated by a hash (#), e.g. *WHERE#PAR1#PAR2#...#PARn
Some Examples
*1*0*25## Turn off light 2.5 on local interface (e.g. F *1*1*47#4#01## Turn on light 4.7 on interface 1 (#4#01) *1*1*0415## Turn on light 4.15 on local interface *1*0*0## Turn off all lights on local interface *0*13*19#4#06## Launch command 13 of Scenariolist 19 (e.g a F420 is addressed by 19) on interface 6 *2*1*91#4#03## open (1) shutter 9.1 in on interface 3 (#4#03) *#4*#1*#14*0225*3## Set heating zone 1 manually ON to 22.5°C
A Monitor Session with Python
To understand the OWN commands a bit better, you should start a monitor on your Raspberry pi and watch the OWN messages coming in. Analyzing these messages gives you an idea how it works. Below is the source of a simple monitor script in Python.
#! /usr/bin/python
# -*- coding: utf-8 -*-
import socket
# IP address and port to connect to the gateway, please attapt to your environment
default_gateway_host = "192.168.60.201"
default_gateway_port = 20000
gateway_addr_port = default_gateway_host, default_gateway_port
def monitor():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        sock.connect(gateway_addr_port)
        data = sock.recv(1024)
        # expect ACK from gateway
        if data != "*#*1##":
            raise Exception("Did not receive expected ACK, but: "+data)
        # Switch session to MONITOR mode
        sock.send("*99*1##")
        data = ""
        while 1:
            # Read data from MyHome(R) BUS
            next = sock.recv(1024)
            if next == "":
                break               # EOF
            data = data + next
            eom = data.find("##")
            if eom < 0:
                continue;           # Not a complete message, need more
            if data[0] != "*":
                raise Exception("Message does not start with '*': "+data)
            print data
            msg = data[1:eom]
            data = data[eom+2:]
    finally:
        sock.close()
monitor()
The Tables of WHO WHAT WHERE
| WHO | Service | 
|---|---|
| 0 | Scenarios | 
| 1 | Lighting | 
| 2 | Automation | 
| 3 | Load Control | 
| 4 | Heating | 
| 5 | Burglar Alarm | 
| 6 | Door Entry System | 
| 7 | Multimedia | 
| 9 | Auxiliary | 
| 13 | Device Communication | 
| 14 | Light+shutters actuators lock | 
| 15 | CEN MH200N | 
| 16 | Sound System | 
| 17 | Scenario Programming | 
| 18 | Energy Management | 
| 24 | Lighting Management | 
| 25 | CEN F454 | 
| 1000 | Diagnostic | 
| 1001 | Automation Diagnostic | 
| 1004 | Heating Diagnostic | 
| 1013 | Device Diagnostic | 
| WHAT | Adress | 
|---|---|
| The WHAT table depends on the WHO service. Please click on the appropriate service in WHO table. | 
| WHERE | Location | 
|---|---|
| 0 | General | 
| 1..9 | Zone 1 to 9 | 
| 11..99 | Light point 11 to 99 | 
| #1..#9 | Group 1 to 9 | 

