Merge two items in one

Hi,

Currently I have two items:

Switch KNX_GV_Garage_Poort_4_0_0	"Garage Poort"								<garagedoor>	(gGV_Garage) 		{ knx="4/0/0" }
Number Tex_Zone_Z066				"Garagepoort [MAP(tex_contacts.map):%s]"	<garagepoort>	(gGV_Garage, gDeur, gAlarmcontact)

When I send an “ON” to the first item, my garagedoor will be open or closed, depending on the existing status. There is no status-feedback. So I don’t know if the garagedoor is actually open.

The second item is nothing more than a status-item. It is populated by a rule (which reads UDP messages coming from the alarm system). Obviously, this item is “read-only”. Changing the status-value will not put the garagedoor in motion.

How do I “merge” this information in one item? I would like the first item (KNX_GV_Garage_Poort_4_0_0 ) to be updated with the right status. However, when I update this switch based on the second item being changed, it will trigger the garage door being opened.

Any suggestions?

postUpdate instead of sendCommand:

Sorry, I should have posted my rule right away.

This is what I have:

rule "Sync Garagepoort items"

when   
    Item Tex_Zone_Z066 received update
then
	if (Tex_Zone_Z066.state == 0) {
		// Garagedoor is closed
		postUpdate(KNX_GV_Garage_Poort_4_0_0, OFF)
	}
	else if (Tex_Zone_Z066.state == 1) {
		// Garagedoor is opened
		postUpdate(KNX_GV_Garage_Poort_4_0_0, ON)
	}
end

With this rule, I am unable to open my garage for more than 10 centimeters. Very useful if I am on business trip and I want to make sure nobody takes the car. :slight_smile:

Step-by-step analysis:

  • I send a command “ON” to KNX_GV_Garage_Poort_4_0_0 (using OpenHAB or a KNX switch);
  • About a second later, item “Tex_Zone_Z066” is changed to status “1”, since my alarm system detected the garage opened.
  • This triggers the “postUpdate(KNX_GV_Garage_Poort_4_0_0, ON)”. Which in reality sends a command on the KNX bus (because it stops the garage door from opening further).

Does anyone have an idea what could be wrong?

The KNX binding behaviour appears to be atypical, in that using postUpdate on an Item does not cause commands to be sent out by most other bindings.
I don’t know how KNX works, so I wouldn’t necessarily call that a binding deficiency.

Circumvent the problem by not doing that. Have a proxy item, and rules so that commands received by proxy are sent to KNX-out item, and contact updates received update the proxy.

Does your KNX object (ets device object) have a read flag?,
or
Does the KNX switch actuator have a status switch object (passive or active) associated to the switch?
If yes, for the first question, then you should not need to postupdate the item linked to that GA. Maybe a “<” should be added in front of the GA.
If yes for the second question, then add the reading status GA to the KNX binding of the item, like: knx="4/0/0+<x/y/z"
The “<” is used for retrieving the status at startup (if I remember correctly)

BR,
George

Hi both,

Thanks for your input.
@george.erhan: unfortunately, the KNX item does not have a read flag, nor does it have a status switch object.

I used an additional virtual item.

My .items:

Switch KNX_GV_Garage_Poort_4_0_0				"Garage Poort"					<garagedoor>					(gGV_Garage) 		{ knx="4/0/0" }
Number Tex_Zone_Z066						"Garagepoort [MAP(tex_contacts.map):%s]"														<garagepoort>	(gGV_Garage, gDeur, gAlarmcontact)
Switch Virtual_GV_Garage_Poort				"Garage Poort [MAP(garagepoort.map):%s]"							<garagepoortswitch>		(gGV_Garage)

My rule:

// ***************************
// Keep the garagepoort-items in sync.
// ***************************

rule "Sync Garagepoort items - part 1"

when   
    Item Tex_Zone_Z066 changed
then
	if (Tex_Zone_Z066.state == 0) {
		// Garagedoor is closed
		postUpdate(Virtual_GV_Garage_Poort, OFF)
	}
	else if (Tex_Zone_Z066.state == 1) {
		// Garagedoor is opened
		postUpdate(Virtual_GV_Garage_Poort, ON)
	}
end

rule "Sync Garagepoort items - part 2"

when   
    Item Virtual_GV_Garage_Poort changed
then
	postUpdate(KNX_GV_Garage_Poort_4_0_0, ON)
end

It works fine when I trigger my garagedoor by switching “Virtual_GV_Garage_Poort”. I minor attention point is that switching “Virtual_GV_Garage_Poort” immediately updates the status of “Virtual_GV_Garage_Poort” as well. This means that when I switch to “off” (=closed) the status of the object is set to closed immediately. Whereas the garagedoor actually takes approx. 15 seconds to close.

A bigger problem is that switching the item “KNX_GV_Garage_Poort_4_0_0” is still not possible. Switching this item does not happen via the sitemap (otherwise I could just remove it), but via my KNX-bus. There is a KNX-pushbutton in my garage triggering this item.

When my garagedoor is closed, and I switch “KNX_GV_Garage_Poort_4_0_0”, the garagedoor starts to open, and then stops when the door is opened for 10 centimeters (like my initial problem).

Step-by-step analysis:

  • I send a command “ON” to KNX_GV_Garage_Poort_4_0_0 (using a KNX pushbutton);
  • About a second later, item “Tex_Zone_Z066” is changed to status “1”, since my alarm system detected the garage opened.
  • This triggers the “postUpdate(Virtual_GV_Garage_Poort, ON)”. Which then triggers the second part of the rule, which does a postUpdate(KNX_GV_Garage_Poort_4_0_0, ON). This last command stops the opening of the garagedoor…

Back to square 1. :frowning:

Hi,
Use a timer or the expire binding for this kind of situation!
Measure the time the door needs to close and open, and send the command only when the time needed to close/open has elapsed.
I think it will work very nice.

Best regards,
George

Hi @george.erhan,

I’m not really sure if I get your remark.

If I switch item “Virtual_GV_Garage_Poort” to “OFF/closed” via BasicUI, the .state of that same item is updated immediately. It doesn’t pass via a rule. I can use a timer to update the .state of another item, indeed. But not the same item. Right?

What I want:

  • I switch Virtual_GV_Garage_Poort to OFF (/closed) - the status of Virtual_GV_Garage_Poort is not updated;
  • When I get an update from item “Tex_Zone_Z066” the status if “Virtual_GV_Garage_Poort” should be adjusted.

And the delay in status-updates is just the minor problem. The key problem is that the rule above is not working at all (my garagedoor does not open for more than 10cm :slight_smile:)

Hi,

The rule you have written can never work in the setup you described.
Using a timer, or the expire binding allows you to set the sendCommand, or postUpdate to the KNX item at a different time than the virtual item.
Handling the state virtual item manually (through UI, or REST API), should be the object to another rule/s.

BR,
George

Hi George,

Still not sure if I understand you correctly.
You mention the use of a timer. Are you suggesting something like this?
(opening the garagedoor takes approx. 22 seconds)

// ***************************
// Keep the garagepoort-items in sync.
// ***************************

rule "Sync Garagepoort items - part 1"

when   
    Item Tex_Zone_Z066 changed
then
	if (Tex_Zone_Z066.state == 0) {
		// Garagedoor is closed
		postUpdate(Virtual_GV_Garage_Poort, OFF)
	}
	else if (Tex_Zone_Z066.state == 1) {
		// Garagedoor is opened
		postUpdate(Virtual_GV_Garage_Poort, ON)
	}
end

rule "Sync Garagepoort items - part 2"

when   
    Item Virtual_GV_Garage_Poort changed
then
   var Timer garage_timer
   if (Virtual_GV_Garage_Poort.state == ON) {
   timer = createTimer(now.plusSeconds(22)) [|
			postUpdate(KNX_GV_Garage_Poort_4_0_0, ON)
    		]
	}

   if (Virtual_GV_Garage_Poort.state == OFF) {
   timer = createTimer(now.plusSeconds(22)) [|
			postUpdate(KNX_GV_Garage_Poort_4_0_0, ON)
    		]
	}	

end

I think the result would be that in some scenarios, when I switch “Virtual_GV_Garage_Poort” it will take 22 seconds before the garage actually starts responding…

Ok, I’ve found a solution. :slight_smile:

I’ve changed my item to:

Switch Virtual_GV_Garage_Poort				"Garage Poort [MAP(garagepoort.map):%s]"							<garagepoortswitch>		(gGV_Garage)		{autoupdate="false"}

The autoupdate=“false” avoids the garagedoor being ‘closed’ as soon as the close-button is pressed. Status will only be updated by the rule.

I’ve changed my rule to:

// ***************************
// Keep the garagepoort-items in sync.
// ***************************

rule "Sync Garagepoort items - part 1"

when   
    Item Tex_Zone_Z066 changed
then

	if (Tex_Zone_Z066.state == 0) {
		// Garagedoor is closed
		postUpdate(Virtual_GV_Garage_Poort, OFF)
	}
	else if (Tex_Zone_Z066.state == 1) {
		// Garagedoor is opened
	postUpdate(Virtual_GV_Garage_Poort, ON)
	}
end

rule "Sync Garagepoort items - part 2"

when   
    Item Virtual_GV_Garage_Poort received command
then
	postUpdate(KNX_GV_Garage_Poort_4_0_0, ON)
end

I had to changed “when item changed” to “when item received command” in my second rule. This avoids the rule being triggered when not needed.

My sitemap:

Switch item=Virtual_GV_Garage_Poort		label="Garagepoort" mappings=[ON="Open"]	visibility=[Virtual_GV_Garage_Poort==OFF]
Switch item=Virtual_GV_Garage_Poort		label="Garagepoort" mappings=[ON="Close"]	visibility=[Virtual_GV_Garage_Poort==ON]

This makes sure the right button is shown at the right time: