[BTicino/OpenWebNet] Adding CEN commands: design

May you please post an example ?
Thanks.

Hi, I have never tried CEN/CEN+ on Openhab before, so apologies for my ignorance.

I do have on my MH202 lots of CEN+ scenarios defined (as I have many 4 button scenario buttons in the house).
I have two entrance gates which I can control via the video entry system. I understand that the ‘unsupported’ 2.5 binding does not support video entry.

I managed to define with MyHome Suite CEN scenarios that can control the entrance gates via MH202.

How could I trigger these scenarios via OpenHab buttons?

Hi, ignore my previous request. I think I figured it out for both CEN and CEN+ by doing a bit of reading of the openwebnet protocol for WHO 15 & 25 :slight_smile:

Hello,
I have a question about cen+ controls.

This is the situation.
In my bedroom I have 2 lights, one on every side of the bed.
Each one is connected to a F411/4.
On each side of the bed I have a L4652/2 button assigned to the light on that side.
They are also inside a group (I use MyHOME_Suite), because I have a button at the entrance of the room that controls the group, meaning it powers ON/OFF both lights at the same time.

What I want to achieve.
I would like to control the single lights by short press, but also control both lights, from both sides, with long press.
The case is: I enter the room, and power ON both lights using the button that controls the group.
I go to bed, want to turn off both lights and can’t do it, unless I press separately both buttons, one on each side, or press the button at the entrance that controls the group.

The only way I figured out till now to do it, is to use a fake CEN+ control, assigning to the buttons in MyHOME_Suite for example CEN=2 / top button=1 / bottom button=2.
Using a rule that catches the changes of state, it works. But I notice an unpleasant delay: if I shortpress, the light powers ON/OFF with a delay of up to 1 seconds (from when I press to when the lights powers ON/OFF). This delay happens both with shortpress annd with longpress.

I don’t know if the cause is my code, that is poor, if the problem is that I am using a “fake” CEN+ or if it is a openHAB/CEN+ limit.

Any idea for a workaround that can fix this delay?

Here are the extracts from my files, for example for the left side of the bed.

.things file:

// BEDROOM   
bus_on_off_switch Camera_luce1 "Luce Camera Letto SX" @ "Camera" [ where="33" ]
bus_on_off_switch Camera_luce2 "Luce Camera Letto DX" @ "Camera" [ where="38" ]

// CEN PLUS / CEN=2 / PULS.SUP.=1 / PULS.INF.=2 (Left side of the bed)
bus_cenplus_scenario_control Dummy2 "Dummy 2" @ "Camera" [ where="22", buttons="1,2" ] // 25.22

.items file:

// BEDROOM
    Switch iCamera_luce1 "Luce Camera Letto SX" <light> (gLuci, gLCamera) [ "Lighting" ] { channel="openwebnet:bus_on_off_switch:mybridge:Camera_luce1:switch" }
    Switch iCamera_luce2 "Luce Camera Letto DX" <light> (gLuci, gLCamera) [ "Lighting" ] { channel="openwebnet:bus_on_off_switch:mybridge:Camera_luce2:switch" }
    // CEN PLUS
    String iDummy2_1 "Dummy 2 btn su"  <network> { channel="openwebnet:bus_cenplus_scenario_control:mybridge:Dummy2:button_1" } // CURRENTLY NOT IN USE
    String iDummy2_2 "Dummy 2 btn giù" <network> { channel="openwebnet:bus_cenplus_scenario_control:mybridge:Dummy2:button_2" } // OWN = *25*21#2*22##

.rules file:

rule "Pulsante camera letto SX"
when
     Item iDummy2_2 changed 
then
	// IF I SHORTPRESS THE BUTTON ON THE L4652/2, POWERS ON/OFF ONLY THE LIGHT ON THAT SIDE
	if (iDummy2_2.state == "RELEASED") {
		if (iCamera_luce1.state == OFF) {
			iCamera_luce1.sendCommand(ON)
		} 
		else {
			iCamera_luce1.sendCommand(OFF)
		}
	}
	// IF I LONGPRESS THE BUTTON ON THE L4652/2, POWERS ON/OFF BOTH LIGHT (ON BOTH SIDES)
	else if (iDummy2_2.state == "RELEASED_EXT") { 
		if (iCamera_luce1.state == OFF && iCamera_luce2.state == OFF) {
			iCamera_luce1.sendCommand(ON) // Left side of the bed
			iCamera_luce2.sendCommand(ON) // Right side of the bed
		}
		else { // BOTH LIGHTS ARE ON, OR ONE IS ON AND ONE IS OFF
			iCamera_luce1.sendCommand(OFF) // Left side of the bed
			iCamera_luce2.sendCommand(OFF) // Right side of the bed
		}
	}
end

I tried also to use PRESSED and PRESSED_EXT, hoping to lower the delay, but it doesn’t work.
I see the change of state in the Log Viewer, but it seems to me that the rule can’t capture the state quickly enough and the state goes to RELEASED / RELEASES_EXT before the rule executes.

Log Viewer:

shortpress:

2021-01-21 11:38:14.054 [vent.ItemStateChangedEvent] - iDummy2_2 changed from RELEASED to PRESSED
2021-01-21 11:38:14.362 [vent.ItemStateChangedEvent] - iDummy2_2 changed from PRESSED to RELEASED
2021-01-21 11:38:14.426 [ome.event.ItemCommandEvent] - Item 'iCamera_luce1' received command ON
2021-01-21 11:38:14.434 [nt.ItemStatePredictedEvent] - iCamera_luce1 predicted to become ON
2021-01-21 11:38:14.475 [vent.ItemStateChangedEvent] - iCamera_luce1 changed from OFF to ON

longpress:

2021-01-21 11:47:51.362 [vent.ItemStateChangedEvent] - iDummy2_2 changed from RELEASED_EXT to PRESSED_EXT
2021-01-21 11:47:52.307 [vent.ItemStateChangedEvent] - iDummy2_2 changed from PRESSED_EXT to RELEASED_EXT
2021-01-21 11:47:52.395 [ome.event.ItemCommandEvent] - Item 'iCamera_luce1' received command OFF
2021-01-21 11:47:52.443 [ome.event.ItemCommandEvent] - Item 'iCamera_luce2' received command OFF
2021-01-21 11:47:52.451 [nt.ItemStatePredictedEvent] - iCamera_luce1 predicted to become OFF
2021-01-21 11:47:52.481 [nt.ItemStatePredictedEvent] - iCamera_luce2 predicted to become OFF
2021-01-21 11:47:52.512 [vent.ItemStateChangedEvent] - iCamera_luce1 changed from ON to OFF
2021-01-21 11:47:52.517 [vent.ItemStateChangedEvent] - iCamera_luce2 changed from ON to OFF

hi,
the problem with delay in your first example with the “released” is clear: you press the button, then “press” is sent, then a little delay (not sure i think 0.5 sec) and then the “release” is sent. if you keep pressing next command ist “pressed_ext”, then again a delay, and now finally (when you free the button) “released_ext”. so this is not a good way to solve your idea.

better use “pressed” and “pressed_ext”. i could imagine this does not work properly with your rule because you trigger on “changed” but in the rule you ask the “state”. so if there comes a “pressed” the rule will trigger. but until the rule reaches the “if” condition maybe the item meanwhile has another state.

i think you could try to split your rule in two rules and use as trigger condition:

when
    Item iDummy2_2 changed to "PRESSED"

and the other rule:

when
    Item iDummy2_2 changed to "PRESSED_EXT"

then no risk that the state could have been changed while the rule is running

I do something similiar but using a MyHomeSuite scenario. I haven’t noticed any significant delay but when I do involve openHAB in the control loop (for other situations) then I do see a delay. I use MH202 Scenarios if I can and rules only when MH202 can not do it for some reason

I use the case function - and it works pretty fast. I dont see why you cant use the group command to turn off the lights. The Myhome system knows if the lights are on already.

rule "Lights off"
  when 
    Item Lightswitch changed 
  then 
  switch(Lightswitch.state ) { 
       case "PRESSED": { 
       LightIndividual.sendCommand(OFF) 
       } 
       case "RELEASED": {
       }  
       case "PRESSED_EXT": {
       LightGroup.sendCommand(OFF)
       }
       case "RELEASED_EXT": {
       }
   }
 end