[BTicino/OpenWebNet] Adding CEN commands: design

See post update 51

I have run simulation tests.
I created button1 ("iLR_scenario ") and a swith (“iLR_sim_scenario”) to simulate two things:

  • activation of the rules by the pressure of the device (physical) CEN
  • via Openhab switch to activate the rules or scene MH202 through CEN frames

Everything works !!!

image

File .things
Thing	bus_on_off_switch   	mylig_sala		"Luce Sala"	@ "Test"	[ where="22" ]
Thing 	bus_scenario_control4   LR_scenario     "Scenario 10-02" 	@ "Test"	[ where="102" ]
File .items
Switch 		Luce_sala 			"Sala" 				<light>		(C_Sala, G_Lights)  [ "Lighting" ]		{ channel="openwebnet:bus_on_off_switch:mybridge:mylig_sala:switch" }
String   	iLR_scenario        "Scenario 10-02"	<network>   (C_Sala, G_Lights) { channel="openwebnet:bus_scenario_control4:mybridge:LR_scenario:button1" }

Switch 	    iLR_sim_scenario 	"Simula CEN 10-02" 	<light>	(C_Sala, G_Lights)  [ "Lighting" ] 	{ channel="openwebnet:bus_scenario_control4:mybridge:LR_scenario:switch" , expire="5s,command=OFF"}

N.B. the expire command is used to simulate the release

File .rules
/************************************
*** CEN 10-02 PRESSED_EX          ***
*************************************/
rule "CEN 10-02 PRESSED"
when
    Item iLR_scenario received update "PRESSED_EXT"
then
		sendCommand(Luce_sala, ON)
end

/************************************
*** CEN 10-02 RELEASED_EXT		  ***
*************************************/
rule "CEN 10-02"
when
    Item iLR_scenario received update "RELEASED_EXT"
then
		sendCommand(Luce_sala, OFF)  
end



/************************************
*** Simula CEN con Switch ON	  ***
*************************************/
rule "Simula CEN con Switch ON"
when
    Item iLR_sim_scenario received command ON
then
		sendCommand(iLR_scenario, "PRESSED_EXT")
    
end

/************************************
*** Simula CEN con Switch OFF		   ***
*************************************/
rule "Simula CEN con Switch OFF"
when
    Item iLR_sim_scenario received command OFF
then
		sendCommand(iLR_scenario, "RELEASED_EXT")
    
end

What does not work is the recognition both automatic and by pressing the button

In any case, excellent work !!!

I wondered if there is a more streamlined way to simulate the switch without creating the 2 rules
“Simula CEN con Switch ON” and “Simula CEN con Switch OFF”.
Addition of parameters for (ON =“PRESSED_EXT”, OFF =“RELEASED_EXT”)
Or does it already exist?