LCN binding

142 views
Skip to first unread message

clrose...@googlemail.com

unread,
Jan 12, 2015, 3:41:23 AM1/12/15
to open...@googlegroups.com
I try to figure out which Thing/Channel Design to use with LCN. I would start with one Thing, called PCHK, which is a connection between OpenHAB and the Issendorff PCHK daemon across a TCP connection. The LCN modules provide a lot of possibilities, every sensor or actor could get an own channel.

Just to explain two actors

- output (dimmable output of modules like UPP/SH/HU)
- relay (non dimmable output of modules like UPP/SH/HU)

That means to control the outputs and relays i will have two channels and the valid data of this channels could be 0-100, i.e. i would have two methods per channel:

- convert the value from OpenHAB to the PCHK command and send it through the bridge
- convert an arriving command from PCHK and put it into the item in OpenHAB

Is this as designed by OpenHAB?

Kai Kreuzer

unread,
Jan 12, 2015, 9:19:51 AM1/12/15
to open...@googlegroups.com
The PCHK sounds very much as if it qualifies as a Bridge in openHAB. You then have two options:
1) This is what you describes: You have the one Bridge which has channels for all your actors and sensors
2) You have an additional Thing for every actor and sensor and they would hold the channels

The suggested architecture is 2), if this is feasible. This means that the physical devices should be represented by a Thing each. This only makes sense if LCN allows you to identify the different physical devices. Especially, such an architecture is useful if you can do a discovery of new devices that could then be presented to the user/admin.
If LCN (and PCHK) does not provide you any possibility to get hold of such information, but rather only shows you a "logical" view of the outputs and relays, then 1) is also a valid option to pursue.

Best regards,
Kai

clrose...@googlemail.com

unread,
Jan 12, 2015, 10:15:03 AM1/12/15
to open...@googlegroups.com
he PCHK is a piece of software which is connected via USB to the PKU (LCN connector module). Across this connection it's possible to send commands to every module which is available. The modules will be used by adressing a segment an an ID, 120 segments are possible and 250 ID's per segment.

In principle a module could defined as Thing and it depends on the kind of module which channels are provided. I.e.

SH provides
3 or 4 outputs
8 relays (virtual or physical, depends if a R8H is connected)
3 or 10 variables (depends on the firmware/hardware release)
96 Keys (32 x short/long/stop)
a lot of more

SHS provides the same except the outputs

Due the functionality depends on the hardware release i would need one Thing per hardware release.
Sensors and Actors are combined in modules, so there are no seperate devices. It's possible to connect hardware to existing modules. It's not possible to address this hardware directly, these hardware is available by sending commands to the modules instead.

A discovery is probably not possible but listening on the PCHK will show up values of outputs i.e.

clrose...@googlemail.com

unread,
Jan 13, 2015, 2:18:04 AM1/13/15
to open...@googlegroups.com
This illustrates a part of the possible functions,  a lot of things are missing, i.e. "send keys", "handle groups", "light scenes". It's also possible to ask the firmware version, if there is a better way to describe things without one per firmware please let me know.

<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lcn"
       
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
       
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

   
<!--PCHK Interface-->
   
<thing-type id="LCN-SH-17070A">
       
<label>LCN SH Module Firmware 17070A</label>
       
<description>Describes a LCN SH module with Firmware 17070A</description><config-description>
   
<parameter name="segmentID" type="text"></parameter>
   
<parameter name="moduleID" type="text"></parameter></config-description>

       
<channels>
           
<channel id="output01" typeId="output"/>
           
<channel id="output02" typeId="output"/>
           
<channel id="output03" typeId="output"/>
           
<channel id="output04" typeId="output"/>
           
<channel id="relay01" typeId="relay"/>
           
<channel id="relay02" typeId="relay"/>
           
<channel id="relay03" typeId="relay"/>
           
<channel id="relay04" typeId="relay"/>
           
<channel id="relay05" typeId="relay"/>
           
<channel id="relay06" typeId="relay"/>
           
<channel id="relay07" typeId="relay"/>
           
<channel id="relay08" typeId="relay"/>
           
<channel id="variable01" typeId="variable"/>
           
<channel id="variable02" typeId="variable"/>
           
<channel id="variable03" typeId="variable"/>
           
<channel id="variable04" typeId="variable"/>
           
<channel id="variable05" typeId="variable"/>
           
<channel id="variable06" typeId="variable"/>
           
<channel id="variable07" typeId="variable"/>
           
<channel id="variable08" typeId="variable"/>
           
<channel id="variable09" typeId="variable"/>
           
<channel id="variable10" typeId="variable"/>
           
<channel id="variable11" typeId="variable"/>
           
<channel id="variable12" typeId="variable"/>
           
<channel id="threshold01_1" typeId="threshold"/>
           
<channel id="threshold01_2" typeId="threshold"/>
           
<channel id="threshold01_3" typeId="threshold"/>
           
<channel id="threshold01_4" typeId="threshold"/>
           
<channel id="threshold02_1" typeId="threshold"/>
           
<channel id="threshold02_2" typeId="threshold"/>
           
<channel id="threshold02_3" typeId="threshold"/>
           
<channel id="threshold02_4" typeId="threshold"/>
           
<channel id="threshold03_1" typeId="threshold"/>
           
<channel id="threshold03_2" typeId="threshold"/>
           
<channel id="threshold03_3" typeId="threshold"/>
           
<channel id="threshold03_4" typeId="threshold"/>
           
<channel id="threshold04_1" typeId="threshold"/>
           
<channel id="threshold04_2" typeId="threshold"/>
           
<channel id="threshold04_3" typeId="threshold"/>
           
<channel id="threshold04_4" typeId="threshold"/>
           
<channel id="regulator01" typeId="regulator"/>
           
<channel id="regulator02" typeId="regulator"/>
       
</channels>
       
   
</thing-type>

   
<thing-type id="LCN-SH-140C0D">
       
<label>LCN SH Module Firmware 140C0D</label>
       
<description>Describes a LCN SH module with Firmware 140C0D</description><config-description>
   
<parameter name="segmentID" type="text"></parameter>
   
<parameter name="moduleID" type="text"></parameter></config-description>

       
<channels>
           
<channel id="output01" typeId="output"/>
           
<channel id="output02" typeId="output"/>
           
<channel id="output03" typeId="output"/>
           
<channel id="relay01" typeId="relay"/>
           
<channel id="relay02" typeId="relay"/>
           
<channel id="relay03" typeId="relay"/>
           
<channel id="relay04" typeId="relay"/>
           
<channel id="relay05" typeId="relay"/>
           
<channel id="relay06" typeId="relay"/>
           
<channel id="relay07" typeId="relay"/>
           
<channel id="relay08" typeId="relay"/>
           
<channel id="variable01" typeId="variable"/>
           
<channel id="variable02" typeId="variable"/>
           
<channel id="variable03" typeId="variable"/>
           
<channel id="threshold01" typeId="threshold"/>
           
<channel id="threshold02" typeId="threshold"/>
           
<channel id="threshold03" typeId="threshold"/>
           
<channel id="threshold04" typeId="threshold"/>
           
<channel id="threshold05" typeId="threshold"/>
           
<channel id="regulator01" typeId="regulator"/>
           
<channel id="regulator02" typeId="regulator"/>
       
</channels>
       
   
</thing-type>

   
<!--Channel Types-->
   
<channel-type id="output" advanced="true">
       
<item-type>Dimmer</item-type>
       
<label>LCN dimmable output</label>
       
<description>LCN output of a module - contains virtual outputs too</description>
       
<category>DimmableLight</category>
       
<state>min="0" max="100" step="2" readOnly="false"</state>
   
</channel-type>
   
<channel-type id="relay" advanced="true">
       
<item-type>Relay</item-type>
       
<label>LCN relay output</label>
       
<description>LCN relay of a module - contains virtual relays too</description>
       
<category>PowerOutlet</category>
       
<state>readOnly="false"</state>
   
</channel-type>
   
<channel-type id="variable" advanced="true">
       
<item-type>Variable</item-type>
       
<label>LCN variable</label>
       
<description>LCN variable of a module</description>
       
<state>readOnly="true"</state>
   
</channel-type>
   
<channel-type id="regulator" advanced="true">
       
<item-type>Regulator</item-type>
       
<label>LCN regulator</label>
       
<description>LCN regulator of a module</description>
       
<state>readOnly="false"</state>
   
</channel-type>
   
<channel-type id="threshold" advanced="true">
       
<item-type>Threshold</item-type>
       
<label>LCN threshold</label>
       
<description>LCN threshold of a module</description>
       
<state>readOnly="false"</state>
   
</channel-type>
   
</thing:thing-descriptions>

clrose...@googlemail.com

unread,
Jan 13, 2015, 3:09:10 AM1/13/15
to open...@googlegroups.com
Another solution could be to specify just one ouput channel and specify the output number inside the command from OpenHAB. I could ask the firmware, store it in the item and check the availibility of outputs by checking the firmware release inside the output conversion method.

clrose...@googlemail.com

unread,
Jan 15, 2015, 5:12:21 PM1/15/15
to open...@googlegroups.com
I have problems with the class "Configuration", during the initialization i got following error.

23:05:45.256 [WARN ] [.e.s.config.core.Configuration:83   ] - Could not set field value for field 'BUFFER_SIZE': Can not set static final java.lang.String field org.openhab.binding.lcn.config.EthernetBridgeConfiguration.BUFFER_SIZE to null value
java
.lang.IllegalAccessException: Can not set static final java.lang.String field org.openhab.binding.lcn.config.EthernetBridgeConfiguration.BUFFER_SIZE to null value
    at sun
.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(Unknown Source)
    at sun
.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(Unknown Source)
    at sun
.reflect.UnsafeQualifiedStaticObjectFieldAccessorImpl.set(Unknown Source)
    at java
.lang.reflect.Field.set(Unknown Source)
    at org
.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523)
    at org
.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500)
    at org
.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560)
    at org
.eclipse.smarthome.config.core.Configuration.as(Configuration.java:81)
    at org
.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:129)
    at org
.openhab.binding.lcn.handler.EthernetBridgeHandler.initialize(EthernetBridgeHandler.java:92)
    at org
.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:109)


public class EthernetBridgeConfiguration {

   
public static final String BUFFER_SIZE = "bufferSize";
   
public static final String IP_ADDRESS = "ipAddress";
   
public static final String IS_LISTENER = "isListener";
   
public static final String FIRMWARE_VERSION = "firmwareVersion";
   
public static final String LISTENER_PORT = "listenerPort";
   
public static final String MODE = "mode";
   
public static final String PING_TIME_OUT = "pingTimeOut";
   
public static final String PORT_NUMBER = "portNumber";
   
public static final String RECONNECT_INTERVAL = "reconnectInterval";
   
public static final String REFRESH_INTERVAL = "refreshInterval";
   
public static final String RESPONSE_TIME_OUT = "responseTimeOut";
   
public static final String USER_ID = "userid";
   
public static final String USER_PASS = "password";
   
   
public String bufferSize = "1024";
   
public String ipAddress;
   
public String isListener;
   
public String firmwareVersion;
   
public String listenerPort;
   
public String mode;
   
public String pingTimeOut = "1000";
   
public String portNumber = "4114";
   
public String reconnectInterval = "10";
   
public String refreshInterval = "50";
   
public String responseTimeOut = "100";
   
public String userid = "lcn";
   
public String password = "lcn";
   
}


<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lcn"
       
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
       
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

   
<!--PCHK Interface-->


   
<!--Channel Types-->
   
<bridge-type id="ethernet">
       
<label>LCN Ethernet Bridge</label>
       
<description>This Thing supports the Issendorff PCHK ethernet connection</description>
       
<config-description>
             
<parameter name="ipAddress" type="text">
               
<label>Network Address</label>
               
<description>Network address of the PCHK daemon</description>
               
<required>true</required>
           
</parameter>
           
<parameter name="portNumber" type="text">
               
<label>Port Number</label>
               
<description>TCP port number of the PCHK daemon</description>
               
<required>false</required>
               
<default>4114</default>
           
</parameter>
           
<parameter name="bufferSize" type="text">
               
<label>Buffer Size </label>
               
<description>Buffer size used by the TCP socket when sending and receiving commands the PCHK daemon</description>
               
<required>false</required>
               
<default>1024</default>
           
</parameter>
           
<parameter name="refreshInterval" type="text">
               
<label>Refresh interval</label>
               
<description>Specifies the refresh interval in milliseconds.</description>
               
<required>false</required>
               
<default>50</default>
               
</parameter>
           
<parameter name="responseTimeOut" type="text">
               
<label>Response time out interval</label>
               
<description>Specifies the time milliseconds to wait for a response from the PCHK daemon when sending a command.</description>
               
<required>false</required>
               
<default>100</default>
           
</parameter>
           
<parameter name="pingTimeOut" type="text">
               
<label>Ping time out interval</label>
               
<description>Specifies the time milliseconds to wait for a response from the PCHK daemon when pinging the device</description>
               
<required>false</required>
               
<default>1000</default>
           
</parameter>
           
<parameter name="reconnectInterval" type="text">
               
<label>Reconnect interval</label>
               
<description>Specifies the time seconds to wait before reconnecting to the PCHK daemon after a communication failure</description>
               
<required>false</required>
               
<default>10</default>
           
</parameter>
           
<parameter name="userid" type="text">
               
<label>User ID</label>
               
<description>User ID to connect to the PCHK daemon</description>
               
<required>false</required>
               
<default>lcn</default>
           
</parameter>
           
<parameter name="password" type="text">
               
<label>User Password</label>
               
<description>Password to connect to the PCHK daemon</description>
               
<required>false</required>
               
<default>lcn</default>
           
</parameter>
       
</config-description>
   
</bridge-type>
</thing:thing-descriptions>

...

Kai Kreuzer

unread,
Jan 16, 2015, 5:26:31 PM1/16/15
to open...@googlegroups.com
This is indeed a bug that has been introduced by the latest update - I have reopened the related Bugzilla issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=456320

Regards,
Kai
...

Kai Kreuzer

unread,
Jan 16, 2015, 5:34:44 PM1/16/15
to open...@googlegroups.com
Hi,

In general, this looks like a valid way to structure it.
If the firmware version makes a huge difference for the device (and can be seen as a different model of it), then it is imho ok to have different things defined.
If the list of channels can be determined by knowing the firmware revision, this is good.
If you can only determine the existing channels by querying the device itself, it might be the better option to have only one thing type and construct its channels upon first access. But if I get you right, this is not necessary.

Best regards,
Kai

Am 13 Jan 2015 um 09:09 schrieb clrose...@googlemail.com:

Another solution could be to specify just one ouput channel and specify the output number inside the command from OpenHAB. I could ask the firmware, store it in the item and check the availibility of outputs by checking the firmware release inside the output conversion method.

Am Dienstag, 13. Januar 2015 08:18:04 UTC+1 schrieb clrose...@googlemail.com:
This illustrates a part of the possible functions,  a lot of things are missing, i.e. "send keys", "handle groups", "light scenes". It's also possible to ask the firmware version, if there is a better way to describe things without one per firmware please let me know.

<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lcn"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"

-- 
You received this message because you are subscribed to the Google Groups "openhab2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab2+u...@googlegroups.com.
To post to this group, send email to open...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openhab2/413a2a9c-d56a-4dc2-978a-cab192608322%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages