Modbus binding for openHAB-2

Hi!

What is the current status of this addon? I can see on github-discussions that some people are or were working on this topic.

Best regards,
Jochen

Hey Jochen,
I did small test of modbus tcp binding some time ago. It did run properly with OH2, however I didnt went futher than basic veriication if its able to talk to bus.

I have tested modbus snapshot 1.9 with openhab 1 and found it working well.
Now I want to go on and build my real application for my house, but want to use OH2.

Is it possible to use modbus-tcp for openhab2? I haven’t found any documentation that supports this.

Regards,
Per

It’s quite possible, you should be able to install it as other openhab2 addons. It does require the openhab1 addon compatibility layer (downloaded automatically I believe).

I think “native” openhab2 implementation of modbus binding is still quite far off: see this PR for the discussion.

Best,
Sami

I am a bit on my way!

I copied my .items and .sitemap to OH2 folders, and it seem to work with switches and temperatures.
However Dimmers is generating an error when starting openhab2?

16:34:35.807 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'modbus' of item 'Fx_WC__Dimbart_ljus_Status' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: item 'itemName' is of type 'DimmerItem', only Switch, Contact or Number are allowed - please check your *.items configuration
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.validateItemType(BindingConfigReaderDelegate.java:39)
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:311)
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:268)
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:102)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_101]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_101]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_101]
        at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_101]
        at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BindMethod.invoke(BindMethod.java:41)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1660)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1636)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:370)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:319)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:295)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:120)[33:org.apache.felix.scr:2.0.2]
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:914)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:998)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.openhab.core.binding.internal.BindingConfigReaderFactory.registerDelegateService(BindingConfigReaderFactory.java:69)
        at org.openhab.core.binding.internal.BindingConfigReaderFactory.addBindingConfigReader(BindingConfigReaderFactory.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_101]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_101]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_101]
        at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_101]
        at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.helper.BindMethod.invoke(BindMethod.java:41)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1660)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1636)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:370)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:319)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:295)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:120)[33:org.apache.felix.scr:2.0.2]
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:914)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:399)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:676)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:360)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.Activator.access$000(Activator.java:53)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:260)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)[33:org.apache.felix.scr:2.0.2]
        at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)[33:org.apache.felix.scr:2.0.2]
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)[org.osgi.core-6.0.0.jar:]
        at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)[org.osgi.core-6.0.0.jar:]
        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.Module.start(Module.java:457)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
16:34:35.863 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'modbus' of item 'Fx_Utanfr_garageport__Dimbart_ljus_Status' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: item 'itemName' is of type 'DimmerItem', only Switch, Contact or Number are allowed - please check your *.items configuration
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.validateItemType(BindingConfigReaderDelegate.java:39)
 

This is the items:

Group Vardagsrum <corridor>
Group Ljusfunktion <switch>
Group Sovrum_4_Kontor <office>
Group Temperaturzon <temperature>
Group Telefon <phone>
Group Sovrum_3_PJ <bedroom>
Group WC <toilet>
Group Hall <corridor>
Group Rot <house>

Switch    Fx_Sovrum_4_Kontor__Ljusfunktion_Tak_Status                      "Sovrum 4 (Kontor)-Tak"                      (Sovrum_4_Kontor,Ljusfunktion)     {modbus="slave1:0"}           
Switch    Fx_Sovrum_4_Kontor__Ljusfunktion_Fnster_Status                   "Sovrum 4 (Kontor)-Fönster"                  (Sovrum_4_Kontor,Ljusfunktion)     {modbus="slave2:0"}           
Switch    Fx_Vardagsrum__Ljusfunktion_Fnster_LU_Status                     "Vardagsrum-Fönster LU"                      (Vardagsrum,Ljusfunktion)          {modbus="slave3:0"}           
Switch    Fx_Entr_Ljusfunktion_VU_Status                                   "Rot-Entré-  VU"                             (Rot,Ljusfunktion)                 {modbus="slave4:0"}           
Number    Fx_Sovrum_3_PJ__Temperatur_Temperatur_rum                        "Sovrum 3 (P&J)-Temperatur [%.1f] °C"                  (Sovrum_3_PJ,Temperaturzon)        {modbus="slave5:0"}           
Contact   Fx_Sovrum_3_PJ__Temperatur_Status                                "Sovrum 3 (P&J)-Temperatur"                  (Sovrum_3_PJ,Temperaturzon)        {modbus="slave6:0"}           
Dimmer    Fx_WC__Dimbart_ljus_Status                                       "WC"                                         (WC,Dimbart_ljus)                  {modbus="slave7:0"}           
Switch    Fx_Hall__Ljusfunktion_ute_entr_Status                            "Hall-ute entré"                             (Hall,Ljusfunktion)                {modbus="slave8:0"}           
Contact   Fx_Ljuskanal__Natt_Status                                        "Ljuskanal-Natt"                             (Ljuskanal,Analog_komparator)      {modbus="slave9:0"}           
Contact   Fx_Ljuskanal__Kvll_Status                                        "Ljuskanal-Kväll"                            (Ljuskanal,Analog_komparator)      {modbus="slave10:0"}          
Contact   Fx_Ljuskanal__Skymning_Status                                    "Ljuskanal-Skymning"                         (Ljuskanal,Analog_komparator)      {modbus="slave11:0"}          
Contact   Fx_Tnd_utelampor_Status                                          "Rot-Tänd utelampor"                         (Rot,Multigate)                    {modbus="slave12:0"}          
Switch    Fx_Sovrum_3_PJ__Ljusfunktion_Tak_Status                          "Sovrum 3 (P&J)-Tak"                         (Sovrum_3_PJ,Ljusfunktion)         {modbus="slave13:0"}          
Switch    Fx_Sovrum_3_PJ__Ljusfunktion_Fnster_Status                       "Sovrum 3 (P&J)-Fönster"                     (Sovrum_3_PJ,Ljusfunktion)         {modbus="slave14:0"}          
Number    Fx_Parkering_Motorvrmare_Temperatur                              "Rot-Parkering"                              (Rot,Motorvrmare)                  {modbus="slave15:0"}          
Contact   Fx_Parkering_Motorvrmare_Status                                  "Rot-Parkering"                              (Rot,Motorvrmare)                  {modbus="slave16:0"}          
Switch    Fx_Spa__Ljusfunktion_Spegel_Status                               "Spa-Spegel"                                 (Spa,Ljusfunktion)                 {modbus="slave17:0"}          
Switch    Fx_Gillestuga__Ljusfunktion_Akvarium_Status                      "Gillestuga-Akvarium"                        (Gillestuga,Ljusfunktion)          {modbus="slave18:0"}          
Switch    Fx_Gillestuga__Ljusfunktion_Fnster_Status                        "Gillestuga-Fönster"                         (Gillestuga,Ljusfunktion)          {modbus="slave19:0"}          
Switch    Fx_Korridor__Ljusfunktion_Status                                 "Korridor"                                   (Korridor,Ljusfunktion)            {modbus="slave20:0"}          
Switch    Fx_Gym__Ljusfunktion__fnster_Status                              "Gym-fönster"                                (Gym,Ljusfunktion)                 {modbus="slave21:0"}          
Switch    Fx_Sovrum_2_Fanny__Ljusfunktion__Fnster_Status                   "Sovrum 2 (Fanny)-Fönster"                   (Sovrum_2_Fanny,Ljusfunktion)      {modbus="slave22:0"}          
Contact   Fx_Tnd_grund_kvll_Status                                         "Rot-Tänd grund kväll"                       (Rot,Multigate)                    {modbus="slave23:0"}          
Switch    Fx_Status_Hemma_Status                                           "Rot-Status Hemma"                           (Rot,Ljusfunktion)                 {modbus="slave24:0"}          
Switch    Fx_Status_nattknapp_Status                                       "Rot-Status nattknapp"                       (Rot,Ljusfunktion)                 {modbus="slave25:0"}          


Great to hear that! Unfortunately the dimmers are currently not directly supported in the binding.

You might want to try to workaround the issue by using a number item and couple of rules (pseudo code but hopefully you get the idea) :

on switchitem received command
sendCommand numberitem switchitem.state

on numberitem received update
Post update switchitem numberitem.state

Where the numberitem is bound to the modbus

Best
Sami

ok, lets see if I get you right.

  • Change items from Dimmer to Number
  • Add a Switch for each dimmer to use in sitemap
  • Let the rule use the Switch to turn on/off the dimmer (0/100% ?)- so dimming is not possible?

I’m sorry I was a bit unclear in my hasty response.

I meant that you would have two kind of items

  • dimmer items, not bound to modbus
  • number items, bound to modbus

You would then use rules to convert dimmer item commands to numbers for modbus. Similarly, modbus state updates (numbers) would be converted to dimmer item.

Let me know if you need more examples…

Hi,

I am in a similar situation with the dimmers via modbus. I would appreciated some examples of how to construct the rules for the work around.

Thanks

Tim

Hi

Please see this thread for the general idea

Best
Sami

Hi I’m net to openhab, but i read in another post that you used to work with dupline.
MC = bh8-ctrlx-230

1 Could you advise me how to connect openhab 1/2 to my mastercontroler via ip?
I have edited config files, and added modbus addon but still, i can’t connect. Perhaps I’m not editing the right config file?

distribution-1.8.3-runtime\configurations\openhab_default.cfg

  1. Is there anyway you could export/show all the config and settings you have to get a dupline modbus installation going

  2. How/what program could connect to the master generator and get the address of a button getting pressed?

  3. Is it possible to “scan” the modbus neet to get all items attached, addresses and what they are?

(yes i lost my old config file and replaced a dead 38xxx with a bh8-ctrlx-230)
Regards.
Niels

Hi Niels,

BH8-CTRLX-230 and SH2WEB24 that I use are totaly different when it comes to how modbus is implemented.

SH2WEB has a modbus adress for every function and every I/O. This is easy in one way since one can read and write data to a specific function easily. But with Openhab one need to create a modbus slave to each eand every parameter one want to read/write.(I have about 200 slaves in my project due to this)

With BH8-CTRLX it is different, here you can for example read all 128 outputs with one slave in openhab, since all outputs are put into 16bit registers. You can simply ask for 8 registers starting from register 0 and then mask every bit into an openhab item in the .items-file

The table of all modbus adresses should be found in the helpfile of the BH8-CTRLX tool.
There are modbus registers for digital inputs and outputs, analink (analog values), counters etc. So you just need to know wich dupline channel you want to read or write and what type it is.

Sorry I cannot give a direct answer about how to configure the openhab files, simply because I am not an expert on them, so chances are that i put some faulty code wich you would copy and paste with bad results.

I am an expert of the Dupline products however, so if you need help on that just let me know.

Good luck!

I got it working, finally! Had much trouble with the rules,

There isn’t much official documentation about the rules syntax, it is copy & paste from other examples(which one cannot be sure it works) and a lot of trial & error.

The solution to my error was “simply” to add “as DecimalType” to the item.state. Otherwise the item.state returned null.

This is how i set it up to make it work. Hope it can help someone else.

Number    Fx_WC__Dimbart_ljus_Status                                       "WC"                                         (WC,Dimbart_ljus)                                      {modbus="slave7:0"}           
Dimmer    Fx_WC__Dimbart_ljus_Status_proxy                                 "WC"                                         (WC,Dimbart_ljus)                                                

rule "dimmer-WC"
when
	Item Fx_WC__Dimbart_ljus_Status changed
then
	postUpdate(Fx_WC__Dimbart_ljus_Status_proxy,Fx_WC__Dimbart_ljus_Status.state as DecimalType)
end

rule "dimmer-WC2"
when
	Item Fx_WC__Dimbart_ljus_Status_proxy received update
then
	sendCommand(Fx_WC__Dimbart_ljus_Status,Fx_WC__Dimbart_ljus_Status_proxy.state as DecimalType)
end

Cheers
Per

Great that you got it figured out!

The proxy approach might not be needed anymore with the new transformation support out as experimental version

I believe with the new version the dimmer items work straight away as the binding no longer ignores any item types. Since dimmer item type is decimal type, you might get it working without any transformation.

Let me know if you decide to try it out.

Best
Sami

Modbus binding is now available for testing: Modbus openHAB2 binding available for alpha testing

Hi,

Update to let you know.

I have reinstalled to OH2.1 and also the new modbus-binding.

I removed the proxy-items and the rules and run the dimmers as Dimmer.

I have 14 Dimmers like this via modbus TCP and it works like a charm!

Thanks Sami for this improvement, very nice!

/Per

Would you find the time to post a new “v2” write up , perhaps in “Tutorials” section - overview of your hardware, how you configured binding things, items etc. ? Plus a simple rule and/or sitemap sample for one of each dimmer type.

I will try to!

Give me some time :slight_smile:

Hello
Can you guys be so polite and give me some example how to write several registers by FC16 of Modbus by one switch ? Now i have “rude” single register by register on item file like “{modbus=”>[slave1:1:trigger=ON,transformation=255],>[slave1:2:trigger=ON,transformation=255],(…)}" but it end looking nasty when you have 10 dimmers (they start by small delay but it is noticeable )

Ok, here is my small tutorial, hope it can help. If there is something not clear let me know so I can improve the tutorial.