Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial contribution of the KNX 2.0 binding #21

Closed
wants to merge 1 commit into from

Conversation

kgoderis
Copy link
Contributor

Initial contribution of the KNX 2.0 binding

Signed-off-by: Karel Goderis karel.goderis@me.com (github: kgoderis)

@kaikreuzer kaikreuzer added the new binding If someone has started to work on a binding. For a new binding PR. label Dec 22, 2014
@kaikreuzer kaikreuzer self-assigned this Jan 13, 2015
@kaikreuzer kaikreuzer modified the milestone: 2.0.0 alpha2 Apr 4, 2015
@buildhive
Copy link

openhab » openhab2 #56 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

openhab » openhab2 #64 SUCCESS
This pull request looks good
(what's this?)

@kgoderis
Copy link
Contributor Author

kgoderis commented May 4, 2015

All changes are OK for ESH 20150430 stable release

@kaikreuzer kaikreuzer removed this from the 2.0.0 alpha2 milestone May 4, 2015
@buildhive
Copy link

openhab » openhab2 #176 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

openHAB » openhab2 #224 SUCCESS
This pull request looks good
(what's this?)

@kaikreuzer kaikreuzer modified the milestone: 2.0.0 beta1 Jun 2, 2015
@kaikreuzer kaikreuzer removed this from the 2.0.0 beta1 milestone Nov 21, 2015
@kaikreuzer kaikreuzer removed their assignment Nov 21, 2015
@kaikreuzer kaikreuzer added the awaiting feedback Awaiting feedback from the pull request author label Nov 21, 2015
@kaikreuzer
Copy link
Member

@kgoderis: @teichsta told me that he had a few discussions with you about the architecture and that he is likely to come back with some improvements soon. I therefore removed it from the 2.0beta milestone and put it on hold until we hear back from @teichsta.

@teichsta
Copy link
Member

@kgoderis yes we had the chance to implement some improvements (at least we think they are ;-)) but didn't get the permission to post them here. Once we are allowed to i let you know and would appreciate your feedback.

@kgoderis
Copy link
Contributor Author

Ok - I missed somehow the last 10 days of discussions in this thread.

So, for my understanding @teichsta you implemented some stuff on top of the pending PR for the 2.0 binding? or is that 1.8 stuff you would like to see in the 2.0 ?

@teichsta
Copy link
Member

we've implemented a GenericKnxThing which takes some configuration to represent either a single GA or a 16fold switch actuator. So it's especially for 2.0 and beside the current solution. It may probably replace the type specific ThingHandler.

@kgoderis
Copy link
Contributor Author

kgoderis commented Dec 1, 2015

Mhh... When I developed the binding I had several cases whereby a logical grouping of GA's in a piece of Java code really made sense. Of course, they tend to follow the paradigm of my own equipment ( I have a lot of MDT and Gira), I am not sure to what extend we will be able to define all the specific wanted behaviour in a GenericKNXThing. Well, that is, without having to do a quasi-duplicate configuration of ETS4 of course.

@lewie
Copy link

lewie commented Jan 18, 2016

@kgoderis, @teichsta, are there any news with KNX 2 architecture and its implementation?

While testing (https://github.com/openhab/openhab2-addons/issues/503) KNX for OH2. (with bootdelegation Version for karaf compatibility)
KNX 1.8 is writing to KNX-bus but can't read actually.
KNX 2 from kgoderis/openhab2 can read data from KNX-bus and generates the cool Things per KNX-adress, but it seems it can't write. It ignores Item definitions in Items File.

So actually there is no usable KNX Bundle for OH2, I think this is really critical.

Tomorrow, I will have a deeper look at KNX 1.8 in OH2.

@teichsta
Copy link
Member

no unfortunately not from my side. We still have to clarify some internal issues …

@kgoderis
Copy link
Contributor Author

The KNX 2.0 binding is still pending for review.

There is a separate issue on the tracker that deals with the KNX 2.0 binding, running on top of the Karaf container. I have the 2.0 running on a pre-Karaf snapshot without any problems, and it is actually very stable.

@therealtobo
Copy link

Any news on the KNX 2.0 binding?

I'm currently running the 1.9 version together with OH2 beta 2 and it works as it should. I do, however, experience the duplicate events/messages on the KNX bus even with ignorelocalevents set to true and it would be nice to move over to the real 2.0 binding.

@sjsf
Copy link

sjsf commented Oct 20, 2016

I have been following this discussion and have the binding in its current state happily running since a while with only minor tweaks. So all in all I'm pretty glad that it exists and would also like to help pushing it further.

If I'm not mistaken, so far there is not really a common agreement on how the real world should be abstracted into Bridge, Thing & Channels. Currently everything is a Thing (with mostly only a single channel). Therefore we have an enormous amount of Things and also miss the opportunity to structure the stuff according to the real world (at least where it's possible).

For these reasons I'd propose to move stuff to the Channel layer like in this example:

Bridge knx:bridge:interface "KNX IP Router" [ /* ... */ ] {

    Things:
        knx actor_1 "Actor 1" [ address="0.8.15" ] {
            Type switch : A [ switchGA="0/8/15", statusGA="0/8/15" ] 
            Type switch : B [ switchGA="0/8/15", statusGA="0/8/15" ] 
            /* ... */ 
        } 

        knx actor_2 "Actor 2" [ address="0.8.15" ] {
            Type rollershutter : A [ upDownGA="0/8/15", upDownStatusGA="0/8/15" /* ... */ ]
            Type rollershutter : B [ upDownGA="0/8/15", upDownStatusGA="0/8/15" /* ... */  ]
            /* ... */ 
        }

        knx taster_1 "Sensor 1" [ address="0.8.15" ] {
            Type ga : temperature [ GA="0/8/15" ]
            /* ... */ 
        }

    Channels:
        Type ga : allLightOff [ GA="0/8/15" ]
        /* ... */    
}

In that way, users have the opportunity to structure their stuff (especially for actors IMHO that really makes sense). And if @kgoderis one day figures out how to detect if an actor is still alive by its physical address, we would have the right layer of abstraction to set a whole Thing (a.k.a. actor) offline if it died. Also, if one day we will include device configuration in ESH (dreaming is allowed, isn't it...?) and maybe some crazy guy out there comes up with something which replaces parts of the ETS this also would work nicely.

However, I also see that for many GAs it does not make sense to put them onto a specific device, especially when they are not clearly tied to one actor. Those still could be defined as a channel on the bridge. So in the end, the user is not forced to define things at all - everything could be put as channels into the bridge. Then nothing is won, of course. But with this approach we at least enable and hopefully also encourage such structuring.

The ThingHandler of course somehow needs to know what to do with a channel. Therefore it would make sense to factor the channel definitions out of the current thing definitions into standalone ChannelTypes. I have created eclipse-archived/smarthome#2343 in order to allow referencing them in the DSL then - for whatever reason this was missing so far.

WDYT?

@kgoderis
Copy link
Contributor Author

And if @kgoderis one day figures out how to detect if an actor is still alive by its physical address, we would have the right layer of abstraction to set a whole Thing (a.k.a. actor) offline if it died.

That day was a long time ago. :-) I have the code in place that "ping" actors over the KNX bus and set their state ONLINE/OFFLINE. Also, Group Address discovery is in place by scanning and parsing the data tables exposed by KNX actors. But it is really experimental stuff as (at least in my case, with >120 actors) it floods the KNX bus very easily.

Also, if one day we will include device configuration in ESH (dreaming is allowed, isn't it...?) and maybe some crazy guy out there comes up with something which replaces parts of the ETS this also would work nicely.

I am not crazy enough to give it a go. Actually, I did but had to give up (that was in the ETS4 era)

Now, more seriously, on the channels: I had the whole binding set up with channels as you describe, more or less, but then had to switch to a "full" Thing approach because of eclipse-archived/smarthome#2042, which you provided a fix for (but I was impatient, since it broke my operational environment) in eclipse-archived/smarthome#2053 . I do agree that a large number of things renders UI like paperUI useless

Finally, if you have nice tweaks/improvements, pls feel free to PR them to my branch and I will incorporate them.

@uspringis
Copy link

Hi,
Very interested in this binding as well, some info where to get latest snapshot/how to build is really welcome. The knx branch (https://github.com/kgoderis/openhab2/tree/knx) has last commit 2 months ago - is it the right one?

Regarding things/channels - I would agree with @SJKA - some actors, like dimmable lights have some natural channels - on/off status, dimming value.

@uspringis
Copy link

uspringis commented Oct 25, 2016

@kgoderis - One suggestion - make port number of IP bridge optional and default to constant 3671. Currently, if port number is not specified and debug is enablet, one gets NullPinter:
Caused by: java.lang.NullPointerException at org.openhab.binding.knx.handler.IPBridgeThingHandler.establishConnection(IPBridgeThingHandler.java:118)

@uspringis
Copy link

Some additional thoughts:
Current discovery mechanism is really flooding KNX bus and results have no much use - mainly due to lack of information about discovered group addresses - type, purpose, etc.
Suggestion:
I'm considering implementing discovery based on ETS project export. This would be easy to update when KNX configuration changes and would give full information for the user. Bus flooding resolved as well.
In my ETS project I use building structure with rooms and add functions to rooms with group addresss sets - this makes perfect sense to create things (funtion) with location set as well as for things to have channels (like dimmable light having switch and dimmer).

@kgoderis
Copy link
Contributor Author

@uspringis In the binding the following discovery methods are provided:
a. Passively scan the KNX bus for any Group Address that is used by Actors, and catalogue these. This does not flood the bus
b. Actively scan the KNX bus for Actors, and read out their data tables. This is very similar to the ETS4 "line scan" feature, and does indeed flood the bus

Regarding reading and parsing the ETS project export, I can only comment that these XML files are extremely complicated, long, and hard to decipher. I investigated this a long time and abandoned this pretty fast. With ETS5 there might be an option to do a new attempt based on the Web Services "output" add-in, but my hopes are limited.

@uspringis
Copy link

Checked out ETS 5 project export format, looks really nice and doable:

<Buildings>
          <BuildingPart Type="Building" Id="P-0441-0_BP-1" Name="Building 1" Puid="6">
            <BuildingPart Type="Floor" Id="P-0441-0_BP-3" Name="Floor 1" Puid="8">
              <BuildingPart Type="Room" Id="P-0441-0_BP-7" Name="Room 1" Puid="12">
                <Function Id="P-0441-0_F-1" Name="Dimmabe lights" Type="DimmableLight" Puid="18">
                  <GroupAddressRef Id="P-0441-0_GF-1" Name="" Role="SwitchOnOff" RefId="P-0441-0_GA-1" Puid="25" />
                  <GroupAddressRef Id="P-0441-0_GF-2" Name="" Role="RelativeSetvalueControl" RefId="P-0441-0_GA-2" Puid="26" />
                  <GroupAddressRef Id="P-0441-0_GF-3" Name="" Role="ActualDimmingValue" RefId="P-0441-0_GA-3" Puid="27" />
                  <GroupAddressRef Id="P-0441-0_GF-4" Name="" Role="InfoOnOff" RefId="P-0441-0_GA-4" Puid="28" />
                </Function>
.....
 <GroupAddresses>
          <GroupRanges>
            <GroupRange Id="P-0441-0_GR-1" RangeStart="1" RangeEnd="2047" Name="New main group" Puid="19">
              <GroupRange Id="P-0441-0_GR-2" RangeStart="1" RangeEnd="255" Name="New middle group" Puid="20">
                <GroupAddress Id="P-0441-0_GA-1" Address="1" Name="Switching" Description="Room 1 Dimmabe lights" DatapointType="DPST-1-1" Puid="21" />
                <GroupAddress Id="P-0441-0_GA-2" Address="2" Name="Dimming" Description="Room 1 Dimmabe lights" DatapointType="DPST-3-7" Puid="22" />
                <GroupAddress Id="P-0441-0_GA-3" Address="3" Name="Value" Description="Room 1 Dimmabe lights" DatapointType="DPST-5-1" Puid="23" />
                <GroupAddress Id="P-0441-0_GA-4" Address="4" Name="Status" Description="Room 1 Dimmabe lights" DatapointType="DPST-1-1" Puid="24" />
                <GroupAddress Id="P-0441-0_GA-5" Address="5" Name="Current temperature" Description="Room 1 Heeted floor" DatapointType="DPST-9-1" Puid="30" />
                <GroupAddress Id="P-0441-0_GA-6" Address="6" Name="Setpoint temperature" Description="Room 1 Heeted floor" DatapointType="DPST-9-1" Puid="31" />
                <GroupAddress Id="P-0441-0_GA-7" Address="7" Name="Variable" Description="Room 1 Heeted floor" Puid="32" />
                <GroupAddress Id="P-0441-0_GA-8" Address="8" Name="Operation mode" Description="Room 1 Heeted floor" DatapointType="DPST-20-102" Puid="33" />
                <GroupAddress Id="P-0441-0_GA-9" Address="9" Name="Window contact" Description="Room 1 Heeted floor" DatapointType="DPST-1-19" Puid="34" />
              </GroupRange>
            </GroupRange>
          </GroupRanges>
        </GroupAddresses>

@kaikreuzer
Copy link
Member

@kaikreuzer That being said, we still need a conceptual discussion on some parts of the KNX binding.

I had the whole binding set up with channels as you describe, more or less, but then had to switch to a "full" Thing approach because of eclipse-archived/smarthome#2042, which you provided a fix for (but I was impatient, since it broke my operational environment) in eclipse-archived/smarthome#2053 .

FTR: eclipse-archived/smarthome#2042 and eclipse-archived/smarthome#2053 are both fixed now, so I think all should be in place to go for the multi-channel thing approach that we discussed in the past (I just cannot find a link to the discussion, was that through email?). Just to give the gist of it: Allow "generic" KNX Things to be defined by the user, where any number of Channels can be added, each referring its type (of which we will have a set of KNX Channels like Switch, Dimmer, Rollershutter, etc.). These Things could be the same as a physical KNX device (e.g. if we manage to discover them), but they do not have to be. Afair, you agreed that this would be the best way of mapping KNX to ESH, right?

What other architectural topics were open to discuss?

@kgoderis
Copy link
Contributor Author

kgoderis commented Nov 1, 2016

FTR: eclipse-archived/smarthome#2042 and eclipse-archived/smarthome#2053 are both fixed now, so I think all should be in place to go for the multi-channel thing approach that we discussed in the past (I just cannot find a link to the discussion, was that through email?). Just to give the gist of it: Allow "generic" KNX Things to be defined by the user, where any number of Channels can be added, each referring its type (of which we will have a set of KNX Channels like Switch, Dimmer, Rollershutter, etc.). These Things could be the same as a physical KNX device (e.g. if we manage to discover them), but they do not have to be. Afair, you agreed that this would be the best way of mapping KNX to ESH, right?

I am not sure we are the same page here. Some of the complexity can not be easily captured in an approach as you describe it. At it's core, you would have a Bridge Thing and a bunch of Channels, since Group Addresses somehow are independent entities on the KNX bus. But you want to take it a step further, and define for example a RollerShutter Thing, which you would populate with Channels "a la carte" in function of the functionality required by the user. These Channel Types would be quite generic, e.g. almost mapped to a given DPT? For some types of Actors it would make sense to link channels in a smart way in order to better steer the behaviour of the Thing. For example, as you know, you have pretty often a GA for steering an actor, and an equivalent "status" GA the device uses to feed back the result of the action. Cfr the auto-update mechanism, if you want the OH runtime follow the actual state of the actor, you would have to combine both these GA's into a single channel, with the channel not getting "auto-updated" with the value it receives from the OH bus, but with the real value received over the KNX bus. Another example could be RollerShutters, where pretty often you get a bunch of related GA's that all serve the same purpose of controlling the shutter: direction of movement, absolute position setting/getting, drive to reference position and so forth. I think it is better to keep the linkage between these things in a Thing, rather than having unrelated Channels that you then capture functionality through linked Items in userland. I would therefore not always opt for "Generic" Things. Ofcourse, there should be Generic Things, but I would also provide Purposed Things (which some may be trivial, obviously) ;-)

One other main reason to go further than a Bridge+Channels approach is that there is currently some low-level KNX stuff in the binding to read-out device tables, scanning the bus and so forth.

One last item to discuss is the inclusion, or not, of Virtual KNX actors. E.g. Just imagine a scene controller in software, rather than in an expensive piece of hardware you would have to add. We can build software components with their own device addresses, their own set of GA's and behaviour, that could interact with other devices on the KNX bus.

Now, specifically, the code to both approaches is still present in the binding - I have not deleted anything, so it might be worthwhile to glance through some of the ESH-INF and Thing Handlers to get an idea of where it can go to.

@lewie
Copy link

lewie commented Nov 1, 2016

@kgoderis,

Independent as at the end a virtual actuator in openHAB will be creatable. Is it also conceived to map all the abilities of a real KNX-actuator in openHAB? Specifically I ask, because a GA in KNX can typically be read out by other devices as well. Or later can be(from me) programmed a extended KNX I/O addon which provides this functionality?

On KNX Side, each GA can have several Flags:

  • "c" Communication (Master Flag if GA is active or not)
  • "r" Read (External Actors can read an object an get a response - This is not allowed in current [KNX] bindings. For this we would need the KNX I/O addon)
  • "w" Write (GA Object can be modified via KNX-Bus/openHAB)
  • "t" Transmit (Actor sends GA Object changes to the KNX-Bus, typical Sensors have set)
  • "u" Update (If is set, a response telegram of a read operation is interpreted as a write telegram - In KNX binding can cause Echos, because openHAB [KNX1 binding] does not clearly respect these flags)

We began this discussion, upper here.

What other architectural topics were open to discuss?

@kaikreuzer, I think when we discuss about architectural topics we need to have one eye on the "KNX perspective" too. ;-)

As I learned here Smarthome/openHAB seams to be enough flexible to map such cases.
Is the KNX-bus only one exception and the available possibilities are enough.
Do we get later more of readers which needs a response, like new/Industrial/IoT buses as MQTT etc.?

@kgoderis
Copy link
Contributor Author

kgoderis commented Nov 1, 2016

@lewie Helmut, I not sure I fully understand your concern, but the flags you mention are in fact not related with the GA's as such nor the KNX Telegrams for that matter. They are indicators that describe the behaviour of the Group Objects that an actor exposes, and which are linked to GAs. [The real indicators in the protocol header are GroupValueRead, GroupValueResponse, GroupValueWrite] Virtualising an actor, so to speak, is thus just a question of exposing a wanted behaviour, which ideally, could be described in the documentation with the R/W/T.... flags. So, in short, you can invent a Thing Handler that responds to R requests, that sends U when something relevant happened we want the other actors on the bus to know about, and so forth. The possibilities are endless, the only thing is that virtual actors - and here @kaikreuzer will jump on the bandwagon - are not compatible (that is, from a conceptual point of view) with Eclipse Smarthome/openHAB in the sense that what we do in ESH/OH is rather provide avatars for real world objects, and thus, not create virtual ones that do not have a physical counterpart..... I am a KNX fan as well, Kai too, but he is - for good reasons - a purist ;-) (@kaikreuzer that was a compliment ;-) )

@lewie
Copy link

lewie commented Nov 1, 2016

Karel, I'm trying to describe it more specifically.
I thought, we are already out of this question, Kai has cleared! There is absolutely no conceptual compatibility problem, simply openHAB abstraction should be respected and separated in terms of addons ("north") and bindings ("south").

KNX GroupValueResponse is missed yet in openHAB. To get this functionallity, ItemRegistry is needed. So it should be implemented as a I/O addon. As addon consequently independent of the implementation of this KNX binding.

And as @kaikreuzer aked; Yes, for me there are some architectural topics open to discuss:

  • I think KNXio addon will be dependent on KNX binding, needs it installed.
  • Please think about because deleting of lines in your code, lets discuss common classes, Karel?
    Which approaches is still present in the binding, that can be used in KNXio addon....
    Simply, how KNXio can be done without doubling too much lines of code.
  • Should/can it/I begin to be start KNXio yet or is better to wait? (Depending on the status of the triggers? #1043)

@kgoderis Karel, I definitely do not want to steer to KNXio and a never ending discussion, a little with thought about my thoughts is enough.

Much more important is to bring your genial binding online now! :-)

@kgoderis
Copy link
Contributor Author

kgoderis commented Nov 2, 2016

@kaikreuzer Kai, so far we had a bunch of .io related bundles in both ESH, OH1 and OH2. They are obviously I/O related but they differ quite a bit in nature, and hence, they do not follow all the same design pattern. With respect to the above discussion, and those differences in mind, what is the way forward with respect to I/O bundles? should we adopt the tagging pattern as present in the HomeKit/Hue bindings, and link Items that way? in casu for KNX, we would then tag Items with for example a GA

@kaikreuzer
Copy link
Member

kaikreuzer commented Nov 3, 2016

@kgoderis & @lewie: As it seems that we are on the same page regarding the functional split in KNX binding + KNX IO Add-on, let me suggest that we focus on what the issue title claims this PR is: a KNX 2.0 binding.

My priority for the moment is to get a replacement for KNX 1.x merged as many people (including myself) would love to have this in place. And Karel is indeed waiting long enough already ;-) Hence I would like to move the "Virtual KNX Actor" discussion away from here as I think that it will otherwise result in further long discussions and prevent having the stuff merged on which we can easily agree. I do not mind if this might mean a later refactoring of shared classes - this should imho not be big efforts, but would help to keep the discussions clean. Would you be ok with that?

Back to the "binding" architecture discussion:

At it's core, you would have a Bridge Thing and a bunch of Channels

No! This is not the approach that I meant. I had to search my inbox back to March 2015 to find our past discussion:

In general I think the design of the channels should follow what we find in openHAB 1 (having a „main GA“ for sending commands and „listening GAs“ for status updates).
...
Or would you see as thing types more complex logical groupings (i.e. with multiple channels), such as a metering switch, a weather station, etc.? But then we are getting close to physical devices again. Maybe a compromise would be to have just one generic „KNX thing type“, which stands for a device with a physical address (and thus we could even provide properties like software version, manufacturer etc. for it by dynamically reading it from KNX) and this could have an appropriate list of either channels or channel groups (but they would of course not be defined on the KNX thing type, only the channel types would be defined, so that they can be referenced). Thinking about it, I think this would be the best matching solution.

This is what I described above. There would be a generic KNX thing type without any channel definition by itself. The users would then create such a thing and add channels. A channel EXACTLY corresponds to what you currently find in OH1 as an item binding config, i.e. a combination of several GAs that combined resemble the functionality of an OH item.
Ideally (I think I would set it up for myself this way), the single Things would correspond to physical KNX devices, i.e. I would create one with 8 Rollershutter channels, another one with 12 Switch channels, etc. But this is then really up to the user.

A knx.things file could look like:

Bridge knx:ip:1 [ ipAddress="192.168.0.123" ] {

    Thing generic actuator1 {
        Channels:
            Type switch : a [ mainGA="1/2/3", listeningGAs=["4/5/6", "7/8/9"] ]
            Type switch : b [ mainGA="2/2/2", listeningGAs=["4/0/0", "7/2/3"] ]
            Type switch : c [ mainGA="3/3/3", listeningGAs=["5/0/0", "7/1/5"] ]
            ...
            ]
        }

    Thing generic actuator2 {
        Channels:
            Type rollershutter : a [ upDownGA="1/2/3", percentGA="4/5/6", moveStopGA="7/8/9" ]
            Type rollershutter : b [ upDownGA="0/2/3", percentGA="1/5/6", moveStopGA="5/8/9" ]
            Type rollershutter : c [ upDownGA="2/2/3", percentGA="2/5/6", moveStopGA="6/8/9" ]
            ...
            ]
        }
}

I think this is a very straight forward (as very strongly aligned with OH1) and yet very flexible approach. Does that make sense to you?

@kaikreuzer
Copy link
Member

kaikreuzer commented Nov 3, 2016

Just noticed that this thread is already far too long - my example is almost identical to what @SJKA suggested above (and what I had overlooked); at least that's a good sign as it confirms that it is not only my distorted mind that thinks that this is a good idea :-)

@kgoderis
Copy link
Contributor Author

kgoderis commented Nov 3, 2016

@kaikreuzer I am ok to give it a try; what is described can be done within the existing frame of the PR without too much hassle, I hope. Would leave the other code in place just for future reference and enhancement.

With channels Types being unique, how will we for example support different types of switches or rollershutter actor implementations? Make the type of rollershutter actor we want to support a channel configuration parameter?

@kaikreuzer
Copy link
Member

Would leave the other code in place just for future reference and enhancement.

I'd prefer if you would take it out to keep it clean - store it in a branch in your fork for reference and create a new PR from it once it is time.

With channels Types being unique, how will we for example support different types of switches or rollershutter actor implementations? Make the type of rollershutter actor we want to support a channel configuration parameter?

In OH1 we so far only have one type of rollershutter implementation, right? So that would be the starting point for me.
Nonetheless, it is easy to allow different implementations. You should note that in my example "rollershutter" is not a reference to an item type, but it is the channel type id. So we can have "rollershutterSimple", "rollershutterAdvanced", etc.

@kgoderis
Copy link
Contributor Author

kgoderis commented Nov 3, 2016

You should note that in my example "rollershutter" is not a reference to an item type, but it is the channel type id. So we can have "rollershutterSimple", "rollershutterAdvanced", etc.

Maybe I am a bit confused here as I am too DSL centric. As in:

Switch Input/Output Channel ...

Did we not have the item type as the "Type" qualifier in the DSL a long time ago in the early days, and then changed it? I don't remember. I am too tired.... Anyways, tx for the discussion, I have to have an updated PR shortly.

@kaikreuzer
Copy link
Member

Did we not have the item type as the "Type" qualifier in the DSL

This is what @SJKA implemented recently just for you: eclipse-archived/smarthome#2343
Before this PR, it was only possible to declare a channel with a preferred item type ("Switch") but WITHOUT any channel type.
With this new PR, it is possible to declare a channel of a pre-defined type (that's why "rollershutter" above refers to a knx channel type). So we will have a library of pre-defined KNX channel types incl. their config descriptions and specific implementations within the handlers and the user simply refers to them in their things. Hope things are clearer now!

I have to have an updated PR shortly.

👍

@lewie
Copy link

lewie commented Nov 4, 2016

@kaikreuzer, let us connect to the functionality of KNX1, sounds logical for me. Then we improve the functionality evolutionarily and as required.
@kgoderis, please tell me where I can help you. Tests, documentation etc. ... :-)

Thank You.

@whopperg
Copy link

whopperg commented Nov 8, 2016

Hey, i finally figured out howto build a binding ;-) at least i thought. But if i try to mvn clean install this binding, i got these Errors:
(did i miss something??)

[INFO] Building KNX Binding 2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ org.openhab.binding.knx ---
[INFO]
[INFO] --- tycho-packaging-plugin:0.24.0:build-qualifier (default-build-qualifier) @ org.openhab.binding.knx ---
[INFO] The project's OSGi version is 2.0.0.201611081643
[INFO]
[INFO] --- tycho-packaging-plugin:0.24.0:validate-id (default-validate-id) @ org.openhab.binding.knx ---
[INFO]
[INFO] --- tycho-packaging-plugin:0.24.0:validate-version (default-validate-version) @ org.openhab.binding.knx ---
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ org.openhab.binding.knx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /downloads/git/openhab2/addons/binding/org.openhab.binding.knx/src/main/resources
[INFO]
[INFO] --- tycho-compiler-plugin:0.24.0:compile (default-compile) @ org.openhab.binding.knx ---
[INFO] Compiling 26 source files to /downloads/git/openhab2/addons/binding/org.openhab.binding.knx/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.174 s
[INFO] Finished at: 2016-11-08T17:43:48+01:00
[INFO] Final Memory: 27M/256M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.24.0:compile (default-compile) on project org.openhab.binding.knx: Compilation failure: Compilation failure:
[ERROR] /downloads/git/openhab2/addons/binding/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/handler/physical/GroupAddressThingHandler.java:[117]
[ERROR] for (String anItem : itemChannelLinkRegistry
[ERROR] .getLinkedItems(new ChannelUID(getThing().getUID(), channelType))) {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from element type Item to String
[ERROR] /downloads/git/openhab2/addons/binding/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/handler/KNXBridgeBaseThingHandler.java:[1109]
[ERROR] return itemChannelLinkRegistry.getLinkedItems(channel.getUID());
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from Set<Item> to Set<String>
[ERROR] 2 problems (2 errors)

@kgoderis kgoderis closed this Nov 19, 2016
@muellerbenni
Copy link

Hi all,

I have installed the knx addon, but im not able to create the binding. I get always the same exception in the log. Does somebody know the problem?

20:36:33.663 [ERROR] [org.openhab.binding.knx ] - FrameworkEvent ERROR - org.openhab.binding.knx
org.osgi.framework.ServiceException: Exception in org.apache.felix.scr.impl.manager.SingleComponentManager.getService()
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:222)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72)[33:org.apache.felix.scr:2.0.2]
at org.apache.felix.scr.impl.helper.BindMethod.getServiceObject(BindMethod.java:646)[33:org.apache.felix.scr:2.0.2]
at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2137)[33:org.apache.felix.scr:2.0.2]
at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1651)[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:]
Caused by: java.lang.NoClassDefFoundError: Thing
at java.lang.Class.getDeclaredMethods0(Native Method)[:1.8.0_25]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)[:1.8.0_25]
at java.lang.Class.getDeclaredMethods(Class.java:1967)[:1.8.0_25]
at org.apache.felix.scr.impl.helper.BindMethod.getServiceObjectAssignableMethod(BindMethod.java:454)
at org.apache.felix.scr.impl.helper.BindMethod.doFindMethod(BindMethod.java:186)
at org.apache.felix.scr.impl.helper.BaseMethod.findMethod(BaseMethod.java:171)
at org.apache.felix.scr.impl.helper.BaseMethod.access$400(BaseMethod.java:37)
at org.apache.felix.scr.impl.helper.BaseMethod$NotResolved.resolve(BaseMethod.java:558)
at org.apache.felix.scr.impl.helper.BaseMethod$NotResolved.methodExists(BaseMethod.java:580)
at org.apache.felix.scr.impl.helper.BaseMethod.methodExists(BaseMethod.java:513)
at org.apache.felix.scr.impl.helper.BindMethod.getServiceObject(BindMethod.java:643)
at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2137)
at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.prebind(DependencyManager.java:1048)
at org.apache.felix.scr.impl.manager.DependencyManager.prebind(DependencyManager.java:1457)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.collectDependencies(AbstractComponentManager.java:983)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:812)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:774)
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_25]
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
... 61 more
Caused by: java.lang.ClassNotFoundException: Thing cannot be found by org.openhab.binding.knx_2.0.0.201611281934
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_25]
... 81 more

thanks in advance

@whopperg
Copy link

whopperg commented Dec 2, 2016

Hi @muellerbenni,
there is a new pull request: Initial contribution of the KNX 2.0 (refactored) binding #1438
(https://github.com/openhab/openhab2-addons/pull/1438) with a new refactored knx binding. But i also can get this to work. But i guess @kgoderis is busy on it so you may have to wait a little bit before its ready to test.

digitaldan pushed a commit to digitaldan/openhab-addons that referenced this pull request Jun 13, 2017
…ding-thing-types

Fixed typo on the spelling of auxiliary
@wborn wborn added the knx label Feb 25, 2019
@kgoderis kgoderis deleted the knx branch October 29, 2020 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.