Need help setting up KNX

Hi, dear community

i need some help setting up rather simple KNX-Switches.

I configured my KNX/IP Gateway. It shows “online”

UID: knx:ip:d49019977f
label: KNX/IP Gateway
thingTypeUID: knx:ip
configuration:
  useNAT: false
  readRetriesLimit: 3
  ipAddress: 192.168.178.47
  autoReconnectPeriod: 60
  type: TUNNEL
  localSourceAddr: 0.0.0
  readingPause: 50
  portNumber: 3671
  responseTimeout: 10

After this i added an KNX Device as a thing. I have here a list of KNX bus-adresses. This one should most defninateley work. The thing is “online”, too:

UID: knx:device:d49019977f:162c9933cf
label: TestGartenhaus
thingTypeUID: knx:device
configuration:
  pingInterval: 100
  address: 1.1.1
  readInterval: 0
  fetch: false
bridgeUID: knx:ip:d49019977f
channels:
  - id: TestGH
    channelTypeUID: knx:switch
    label: TestGH
    description: ""
    configuration:
      ga: "1.001"

As you can see, i added a channel. Here, i am unsure, how to do it.
After this i added a switch to the channel but it won´t work.

This is all the info i have got for this actuator. I didnt configure the KNX-Bus-Settings myself ;(

    <GroupRange Name="Gartenhaus Gross" RangeStart="2304" RangeEnd="2559">
      <GroupAddress Name="Gartenhaus Innenlicht Gross Status" Address="1/1/0" DPTs="DPST-1-11" />
      <GroupAddress Name="Gartenhaus Innenlicht Gross Schalten" Address="1/1/1" DPTs="DPST-1-1" />

Maybe anybody sees my fault?

Thank you! :wink:

Hello Sebastian,
multiple errors I see, young Padawan :wink:, e.g. 1.001 is not a group address but a datapoint type.
You are mixing things up.
The IP interface definition seems to be fine though.
Please take a look into this little post containing a step by step description on how knx configuration links to OH config. and how to set up a basic knx switch.

Thomas

@Oggerschummer

Master Obi-Wan! This was perfect help, thank you so much!

The main problem was, that i didnt understand the difference between group-adresses and bus-adresses.
Now i can switch things :wink:

TY!

@Oggerschummer

I just saw in ETS, that all channels of the actuator (its an AMS-0816.02 8-fach Schaltaktor mit Strommessung) have a “status-adress”, is that right?
Could you point me in the right direction on how to get these into OH correctly?

Ty :wink:

Enter a/b/c+<d/e/f as channel group address.
The first GA ist the switching object, the second one the status GA.
You find examples in the binding documentation.
This will allow you to switch the actor and the channel will reflect it’s status.

@Oggerschummer

Works wonderfully, thank you!

One last thing, as you please :wink:
The garage gate is controlled by this device here. Its a bit more complicated, i cannot get it to run properly, even after reading the documentations. KNX A3-B2 - Elsner Elektronik

Here are the adresses from ETS:

I can get the gate going up and down using the GAs in the list. However, i need to setup two individual channels, one for up, one for down.
I have tried it with the rollershutter-channel and added “5/1/0+5/1/2” But this way it doesn´t work at all.

I appreciate yor help, mate!

You have to use different channels :slight_smile: For controlling these two switches, there are some options, but I would prefer to use another Item and a rule. What about stopping the gate? Is this done by a second impulse for the same input?

@Udo_Hartmann

Hi Udo, thank you for your help :wink:

I created a rule with simple switches, which works for now. A little complicated and not very elegant. And no status–updates. The problem is, that both switches need to get to their “Off-position” before it can send another impulse.

You are right, second impulse in the same direction the gate is moving stops it.

The thing i don´t get is, that there is no “Datentyp” for “hoch, runter and lüften” in ETS. Only for “Tor geöffnet” und “Tor geschlossen.” Maybe this is needed to get the Motor running? (Hörmann)

So, which way do you suggest?

Ah, no. This is only true for Switches in the UI.

Simple version:
Contact Item for “gate open”
Contact Item for “gate closed”
Switch Item for “open gate”
Switch Item for “close gate”
Number Item to control the gate

Unfortunately there is no Channel for “gate is moving”, so maybe we have to create something for that.

rule "garage door"
when
    Item ConGDoorOpen   changed to CLOSED or
	Item ConGDoorClosed changed to CLOSED or
	Item NumGDoorControl received command
then
    var Integer iNew = -1
    if(receivedCommand !== null) {                     // rule triggered by NumGDoorControl
		switch((receivedCommand as Number).intValue) { // which command was sent?
			case 2: SwGDoorOpen.sendCommand(ON)        // for 2, send open
			case 3: SwGDoorVent.sendCommand(ON)        // for 3, send vent
			case 4: SwGDoorClose.sendCommand(ON)       // for 4, send close
			case 5: {                                  // for 5, send a stop
				if(SwGDoorOpen.state == ON)
					SwGDoorOpen.sendCommand(ON)
				else if(SwGDoorClose.state == ON)
					SwGDoorClose.sendCommand(ON)
				else if(SwGDoorVent.state == ON)
					SwGDoorVent.sendCommand(ON)
			}
		}
	} else {                                           // end position
        if(triggeringItemName.contains("Closed")) {    // rule triggered by ConGDoorClosed
			iNew = 6                                   // show closed
			SwGDoorClose.postUpdate(OFF)               // switch off the item
		} else  {                                      // rule triggered by ConGDoorOpen
			iNew = 1                                   // show open
			SwGDoorOpen.postUpdate(OFF)                // switcch off the item
		}
	}
	if(iNew > 0)
		NumGDoorControl.postUpdate(iNew)
end

Now, in the UI, create different buttons for open, close, vent and stop. (these buttons have to send the corresponding number) Configure to display different messages for the Numbers (maybe use MAP transformation service):

1=OPEN
2=opening
3=venting
4=closing
5=stop
6=CLOSED
-=-
NULL=-

:slight_smile:

You could even use a Rollershutter Item or a Dimmer Item (maybe more work…) to use the garage door icon. You would have to change the numbers for display and commands.

@Udo_Hartmann

Hi Udo, i tried to digest this, but honestly, i am a bit lost :wink:

For the simple Version:
Do i add one channel for each item you wrote? I.e. for Contact Item for “gate open” i would add a channel “Contact” → Group-Adress : 5/1/3 → and then?

Also i am not sure about what to do with the number item you suggest for controlling the gate.

Can you helm me any further? Sorry, me noob :wink:

Also: This code you send me, is it a rule or a script? Pasting it into a rule gives me plenty of errors.

:slight_smile:

Yes. You need one channel per attribute, one channel for sending “open the door”, one channel for “close the door”, one channel for “go to venting position”, one channel for detecting closed door and one channel for opened door. All command channels are of type switch, the two channels to get the end positions are of type contact. Each of these channels are setup with only one GA. Each of the channels are linked to one specific Item.

That is another Item, which is not linked at all, so simply create it.

It’s a rule (to be more specific: it’s a DSL rule written in a text file). You could input this rule via UI, but be aware that within the UI, the when part of the rule is built through the UI. The same rule as UI Rule in code:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: ConGDoorOpen
      state: CLOSED
    type: core.ItemStateChangeTrigger
  - id: "2"
    configuration:
      itemName: ConGDoorClosed
      state: CLOSED
    type: core.ItemStateChangeTrigger
  - id: "3"
    configuration:
      itemName: NumGDoorControl
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "4"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >2
            var Integer iNew = -1
            if(receivedCommand !== null) {                     // rule triggered by NumGDoorControl
        		switch((receivedCommand as Number).intValue) { // which command was sent?
        			case 2: SwGDoorOpen.sendCommand(ON)        // for 2, send open
        			case 3: SwGDoorVent.sendCommand(ON)        // for 3, send vent
        			case 4: SwGDoorClose.sendCommand(ON)       // for 4, send close
        			case 5: {                                  // for 5, send a stop
        				if(SwGDoorOpen.state == ON)
        					SwGDoorOpen.sendCommand(ON)
        				else if(SwGDoorClose.state == ON)
        					SwGDoorClose.sendCommand(ON)
        				else if(SwGDoorVent.state == ON)
        					SwGDoorVent.sendCommand(ON)
        			}
        		}
        	} else {                                           // end position
                if(triggeringItemName.contains("Closed")) {    // rule triggered by ConGDoorClosed
        			iNew = 6                                   // show closed
        			SwGDoorClose.postUpdate(OFF)               // switch off the item
        		} else  {                                      // rule triggered by ConGDoorOpen
        			iNew = 1                                   // show open
        			SwGDoorOpen.postUpdate(OFF)                // switcch off the item
        		}
        	}
        	if(iNew > 0)
        		NumGDoorControl.postUpdate(iNew)
    type: script.ScriptAction

Of course, the Item names have to fit.

@Udo_Hartmann

Dear Udo,
i am trying really hard, but i am not almost there :wink:

So, i added all the channels with the names from your rule:

UID: knx:device:d49019977f:cb8c81cfa1
label: Garagentor Steuereinheit
thingTypeUID: knx:device
configuration:
  pingInterval: 600
  address: 4.1.3
  readInterval: 0
  fetch: false
bridgeUID: knx:ip:d49019977f
channels:
  - id: ConGDoorOpen
    channelTypeUID: knx:contact
    label: Garagentor offen
    description: ""
    configuration:
      ga: 5/1/3
  - id: ConGDoorClosed
    channelTypeUID: knx:contact
    label: Garagentor geschlossen
    description: ""
    configuration:
      ga: 5/1/4
  - id: SwGDoorOpen
    channelTypeUID: knx:switch
    label: Garagentor öffnen
    description: ""
    configuration:
      ga: 5/1/0
  - id: SwGDoorClose
    channelTypeUID: knx:switch
    label: Garagentor schließen
    description: ""
    configuration:
      ga: 5/1/1
  - id: SwGDoorVent
    channelTypeUID: knx:switch
    label: Garagentor lüften
    description: ""
    configuration:
      ga: 5/1/2

For each i linked the corresponding items (contacts and switches).

I added the number-item for controling (can´t find any code for this in the UI):

Ofc I put in the rule you gave me in the rules-ui → no more errors.

Now, i don´t know, what else i need to do. Ofc all the switches and contacts are shown in the model and overview and i can click on them, but i dont know what to do with this number-item. Maybe i am wrong about the final result of this whole odyssey :wink: In the end i want (mainly) two “buttons” for up and down, which also show the state of the garagedoor. Am i right?

Thank you so much for your efforts!

Looks promising. Now create a Number Item without any links (i.e. Main UI->Administration->Settings->Items->Add Item (white + on blue circle)
Give it the correct name and set type to Number. This Item will be the only one you’ll need in the UI.
Save the Item. Go to the Item and add Metadata state Description. Paste the List to Options:

1=OPEN
2=opening
3=venting
4=closing
5=stop
6=CLOSED
-=-
NULL=-

Now the state reads the words instead of the number.

Create a list card in Main UI and set the YAML code to this:

component: oh-list-card
config:
  simpleList: false
slots:
  default:
    - component: oh-label-item
      config:
        item: NumGDoorControl
    - component: oh-list-item
      config:
        listButton: true
        title: Open
        action: command
        actionItem: NumGDoorControl
        actionCommand: "2"
    - component: oh-list-item
      config:
        listButton: true
        title: Stop
        action: command
        actionItem: NumGDoorControl
        actionCommand: "5"
    - component: oh-list-item
      config:
        listButton: true
        title: Close
        action: command
        actionItem: NumGDoorControl
        actionCommand: "4"
    - component: oh-list-item
      config:
        listButton: true
        title: Vent
        action: command
        actionItem: NumGDoorControl
        actionCommand: "3"

Result should be similar to this:
garage

four buttons and status on top. The rule will translate the commands to the switches and set the status.

We´re almost there, i think! :wink:

So, i got this now. Not pretty, but i am not complaining :wink: The status is not shown here, i am completly lost, where i have to search for the mistake, haha!

Anyway, the gate opens and closes ONE time, after this it won´t work again. After checking for the switches i can see, that both switches for up and down are turned on. After switching them back to off manually, it works again. Once :wink:
Is there any way to create simple push-buttons that return to their default position?

You could use the Expire metadata property for this, I think.

For your Item:

Click Add Metadata
Click Expiration Timer

You can update the switch item state after a minimum of 1 second.
This may solve your problem.

1 Like

Did you create the rule? You don’t need to use an expiration timer, this is all done by the rule. Maybe the logic is wrong. The rule is now triggering if one of the contacts is closing. So, if the Item ConGDoorOpen changed to CLOSED, the Status of NumGDoorControl is changed to 1 (which is mapped to “OPEN”). If the Item ConGDoorClosed changed to CLOSED, the Status of NumGDoorControl is changed to 6 (which is mapped to “CLOSED”). But maybe the trigger has to be changed to OPEN.

1 Like

@Udo_Hartmann
@Oggerschummer

Hi guys,
just right now i managed to click together several UI-Rules which work really well.
Scince i was not able to get your rule running, @Udo_Hartmann , i tried to recreate the same in different UI rules. So THANK YOU for your inspiration :wink:

I got a 99% solution now:
Klicking on “up” on a rollershutter item moves the gate. Another item “Gate-Status” shows “moving”.
After full open the status tells me “open”. Vice versa when closing. I dont need “venting” … :wink: I used the expire-meta to reset the switches 1s after i klicked them. Works wonderfully.

The only -1% is, that the little icon of the “Status-Item” does not change its state. Its a Number-Item with Metadata state description. Any ideas?! :wink:

Again… Thank you!

Given, that all Items are named like in my rule, the only thing to do is to paste the code…

And as said above… If you want to use the garage door Icon to reflect position of the door, you would have to change then numbering (so that a closed Garage door is a 100, an opened door is 0, closing and opening between those two levels and even venting would be a position. Stop maybe at 50?
You will have to select the icon to show item state, change the sent commands and the mapped text and the rule should work.

If you want it neat and shiny, you are free to create a custom widget for your garage door. :wink:

1 Like

@Udo_Hartmann

Alright! Got it! :wink: At least in the MainUI (?) Icon is changing correctly between OPEN, CLOSED and MOVING. I dont need STOP or VENTING, scince i never plan to do these commands :wink:
Thank you, i learned so much this way!
8

BUT! … argh…
In the BasicUI, which i am usin in the app (Sitemap) it looks a little different.

Item is not moving and i have a switch instead of the text from the number item.
EDIT: Funny… In my Android-App the Sitemap works just as intended. But not in the browser-view of the sitemap (basic-ui)

Sitemap must be handled completely different.

1 Like