LCN Binding: Text based configuration for variables with temperature values

Hi all,

I finally migrated my LCN setup from the v1 binding to the new binding version. @fwolter, thanks for your great contribution and all the effort you put in porting the binding. That’s highly appreciated!

I’m using text based configuration files for my OH setup (and thus also for the LCN binding). Most things work flawlessly but I have some issues with temperature values (LCN hardware: TS, GRT, and GT6/GT12) when reading variables. I always see the “native” lcn value instead of “real” degree celsius. Example: currently, it is 1231.0 °C in my home :wink: After spending some hours on this, I’m currently lost how to enable the correct unit conversion. I have tried to set the channel parameter in my things file as follows:

	Thing module M075 "M75 EG Arbeit Tür (GT6)" [ moduleId=75, segmentId=0 ] {
	Channels: 
		Number:variable#3  [ unit="°C" ]
    	}

I also tried these options and several combinations (e.g., with and without “Temperature”):

		Number:Temperature variable#3 [ unit="°C" ]
		Number:Temperature variable#3 [ unit="lcn" ]
        Number:Temperature variable#3 [ unit="native" ]

My item definition looks like this:
Number:Temperature EG_Arbeitszimmer_RawTemperature "Gemessene Temperatur [%.1f °C]" <temperature> (EG_Arbeitszimmer, gTemperature) {channel="lcn:module:RaspiPCHK:M075:variable#3"}

Any help on how to set the unit in a text based configuration is appreciated. Thanks!

If the channel is just a number type channel, linking it to a Number:Temperature type Item probably will not work as you would like.
I don’t think PaperUI would even let you attempt it, but you can force bad configuration when working with files.

I think in OH3 there is an improved transform profile that will allow you to match a plain number channel, add a unit, and feed to a Quantity type Item.

LCN doesn’t reveal the unit of an LCN variable to third-party software like OH. That’s why the user needs to configure the unit manually. And that is why the Item type is defined only as Number and not as QuantityType.

But when a unit is set, the binding sends the correct QuantityType. So, I don’t know what needs to be configured in the .things file (Number or Number:Temperature). Just give it a try.

The correct value for unit is “temperature”. See https://github.com/openhab/openhab-addons/blob/0856a0b3f2cfcb74a2e9b4b15da1a17bc7012dd3/bundles/org.openhab.binding.lcn/src/main/resources/OH-INF/config/config.xml#L84

Please confirm if the following works. I will add it to the readme, then.

	Thing module M075 "M75 EG Arbeit Tür (GT6)" [ moduleId=75, segmentId=0 ] {
	Channels: 
		Number variable#3  [ unit="temperature" ]
    	}
1 Like

Awesome, that works! :smiley: Thank you for providing the code snipped.

This is a small working example for a .things file which you could add to the documentation:

Bridge lcn:pckGateway:myPCHK [ hostname="192.168.123.123", port=4114, username="myUser", password="myPassword", mode="native200" ] {
	Thing module M99 "M99 MyModule" [ moduleId=99, segmentId=0 ] {
	Channels: 
		Contact : binarysensor#6	[ invertState=true ]
		Number	: rvarsetpoint#1	[ unit="temperature" ]
		Number	: variable#3		[ unit="temperature" ]
	}
}

Btw: No changes were needed for my .items file. The example given above should still be valid.

The pull request has been filed. Please have a look: https://github.com/openhab/openhab-addons/pull/9031

1 Like

Looks good. Thanks. I hope this will help some people with text based configurations to get started a bit faster.

Hi Michael,
I love the text based configuration too! Let me extend your example :wink:
Best regard
Ralf

 Thing module S000M125 "LCN M125 SH+ WIH"           [ moduleId=125, segmentId=0 ] {
            Channels:
            Contact : binarysensor#8        [ invertState=true ]
            Number  : variable#1            [ unit="native" ]                       // Lux Light Average by calculation rule in variable definition
            Number  : variable#6            [ unit="temperature" ]          // Temperatur
            Number  : variable#7            [ unit="windspeed" ]            // Wind ms
            Number  : variable#8            [ unit="native" ]                       // Lux Light Ost
            Number  : variable#9            [ unit="native" ]                       // Lux Light Sued
            Number  : variable#10           [ unit="native" ]                       // Lux Light West
            Number  : variable#11           [ unit="angle" ]                        // Azimut
            Number  : variable#12           [ unit="angle" ]                        // Elevation
     }
 Thing module S000M160 "LCN M160 EG Technik Rollosteuerung EG"              [ moduleId=160, segmentId=0 ] {
            Channels:
            Rollershutter : rollershutterrelay#1 "Kueche Erker Links"               [ invertUpDown = false ]
            Rollershutter : rollershutterrelay#2 "Kueche Erker Rechts"              [ invertUpDown = false ]
            Rollershutter : rollershutterrelay#3 "Werkstatt"                                [ invertUpDown = false ]
     }

What’s the reason you are using native for the lux values? You could use light.

Hi Fabian,
because of my setting using these values in rules. It’s not a special reason. Keep in mind, I came originally from OH 1.8.
best regards
Ralf