Accessing homematic system variables in openhab2

I thought I am quite familiar with openhab but I’m searching now for hours…

How do I access a homegear system variable in openhab 2?

It must be so easy that no one ever had to ask before but I don’t get it. Please help me.

I don’t know this binding so I don’t know what you mean by a system variable. You also don’t mention where you are trying to access this variable (Rules, sitemap, Habpanel, ???).

If I am guess correctly and you mean the stuff you put into the .cfg file as a system variable the answer is you can’t.

If you mean you want to access a CCU variable, if you are using a supported device and the 2.0 binding these should be discovered automatically and appear in the Inbox. If not the readme for the binding describes how to create a Thing for one. If you are using the 1.9 version binding, the wiki page for the binding describes how to write an Item binding config for one.

I’ve found an example for openHAB 1:

Number VentilstellungKuecheProxy "Küche [%.0f %%]" <heating> { homematic="variable=maxVentilstellungKueche" }

The variable is set in homegear with something like that:

$hg->setSystemVariable("maxVentilstellungKueche", 42);

Afair this provides a normal so called system variable like on a real CCU.

All my homematic devices work like a charm. Even though I use a things file to add my devices they showed up in the paper ui inbox before.

The syntax of the homematic binding has changed in oH2 so the example from oH1 is not usable nor derivable.

As soon as I add a system variable I get this exception when searching for new things in the paper ui:

2016-11-18 17:32:25.468 [ERROR] [very.HomematicDeviceDiscoveryService] - 
java.lang.NullPointerException
        at org.openhab.binding.homematic.type.MetadataUtils.createBigDecimal(MetadataUtils.java:251)[189:org.openhab.binding.homematic:2.0.0.b4]
        at org.openhab.binding.homematic.type.HomematicTypeGeneratorImpl.createChannelType(HomematicTypeGeneratorImpl.java:242)[189:org.openhab.binding.homematic:2.0.0.b4]
        at org.openhab.binding.homematic.type.HomematicTypeGeneratorImpl.generate(HomematicTypeGeneratorImpl.java:128)[189:org.openhab.binding.homematic:2.0.0.b4]
        at org.openhab.binding.homematic.handler.HomematicBridgeHandler.onDeviceLoaded(HomematicBridgeHandler.java:277)[189:org.openhab.binding.homematic:2.0.0.b4]
        at org.openhab.binding.homematic.internal.communicator.AbstractHomematicGateway.loadAllDeviceMetadata(AbstractHomematicGateway.java:389)[189:org.openhab.binding.homematic:2.0.0.b4]
        at org.openhab.binding.homematic.discovery.HomematicDeviceDiscoveryService$1.run(HomematicDeviceDiscoveryService.java:108)[189:org.openhab.binding.homematic:2.0.0.b4]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_65]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_65]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]

For someone to test:

add a variable:

homegear -e 'runcommand $hg->setSystemVariable("maxValveStateBad", 42);'

delete variable:

homegear -e 'runcommand $hg->deleteSystemVariable("maxValveStateBad");'

Could anyone confirm this error or is it just me?

The exception seems to be bug in the binding. Please create an issue at https://github.com/openhab/openhab2-addons/issues

In openHab2 the Homematic binding provides a special thing named “Gateway-Extras”. This thing has got a channel for each variable. You can use the channels of this thing to access variables.

Hello,

I had troublesome hours trying to understand how to sync variables from CCU to OpenHAB2.

The Wiki of the OpenHAB Homematic binding suggests defining a virtual remote control channel on the CCU and a corresponding switch in OpenHAB like this:

Switch Reload_Variables {homematic="address=BidCoS-RF, channel=1, parameter=PRESS_SHORT, action=RELOAD_VARIABLES"}

The OpenHAB2 binding features Gateway-Extras. But the Wiki is missing examples. How can I sync CCU variables to OpenHAB2 using Gateway-Express?

(I managed to control variables in the opposite direction from OH2 to CCU, by the way…)

Best
Matthias

Hi @carciofi,

Did you manage to sync your variables? I am trying since days, but it does not work. The sync from Homematic to OpenHab2 does not happen and I cannot find a full example.
Best regards,
Markus

Any updates concerning this topic yet? What is the best way to update system variables?

I can’t seem to get my HomeMatic custom variables to update in OH2 either. In OH1 there was this item with RELOAD_VARIABLES as action which seemed to keep the variables synced in OH.

This thread is quite old - but (at least for me) the problem still exists.

For me the problem also exists. The state of the variables is not reflected in the switch … the other way round it’s working and the switch alters the state of the variable.
What can I do here?