[SOLVED] One Item with multiple bindings

Hi,
i tried to link two enocean switches and philips hue to one item but by some reason only one switch is working? strange think is its sometimes the 1. one and sometimes the 2 one.

Dimmer S_LR_Ceiling_D "Livingroom Ceiling Light Dimmer" (R_LR_D, R_LR)			{ channel="hue:0210:0017884e88f5:1:color", enocean="{id=FE:F9:78:84, channel=A, eep=F6:02:01}", enocean="{id==FE:F9:79:09, channel=A, eep=F6:02:01}" }

if i add only one of them they are working

Essentially, you cannot map one item to more than one binding and expect things to continue working.
While the items syntax may allow for this and while there may be instances where it seems to work out, there’s no general explicit logic implemented how openHAB is supposed to handle these cases. Use multiple items with one binding each, and create a rule to synchronize them.

Well, this depends on circumstances… :wink: For example:

DateTime Date  "Date: [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]"  <calendar> { ntp="Europe/Berlin:de_DE", knx="10.001:15/7/10, 11.001:15/7/11" }
DateTime Datum "Datum: [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]" <calendar> {channel="ntp:ntp:home:dateTime", knx="10.001:15/7/10, 11.001:15/7/11" }

Date is OH1, Datum is OH2 style. Both work reliable and as expected. (Of course either the former or the latter)
I think the main issue is, you try to use enocean two times at the same item.

The reason for the two enocean items is that i have multiple switches for the same light.
what i did now is setup the below items and rules. however if possible i would like to minimize it as much as possible.

Dimmer S_LR_Ceiling_D_E1	{enocean="{id=FE:F9:78:84, channel=A, eep=F6:02:01}" }
Dimmer S_LR_Ceiling_D_E2	{enocean="{id=FE:F9:79:09, channel=B, eep=F6:02:01}" }
Dimmer S_DR_Ceiling_D_E1	{enocean="{id=FE:F9:78:84, channel=B, eep=F6:02:01}" }
Dimmer S_DR_Ceiling_D_E2	{enocean="{id=FE:F9:79:09, channel=A, eep=F6:02:01}" }
rule "LR Ceiling light ON"
when
	Item S_LR_Ceiling_D_E1 received command ON or
	Item S_LR_Ceiling_D_E2 received command ON
then
	sendCommand(S_LR_LIGHT_Ceiling_S, ON)
end

rule "LR Ceiling light OFF"
when
	Item S_LR_Ceiling_D_E1 received command OFF or
	Item S_LR_Ceiling_D_E2 received command OFF
then
	sendCommand(S_LR_LIGHT_Ceiling_S, OFF)
end


rule "LR Ceiling light INCREASE"
when
	Item S_LR_Ceiling_D_E1 received command INCREASE or
	Item S_LR_Ceiling_D_E2 received command INCREASE
then
	sendCommand(S_LR_LIGHT_Ceiling_S, INCREASE)
end

rule "LR Ceiling light DECREASE"
when
	Item S_LR_Ceiling_D_E1 received command DECREASE or
	Item S_LR_Ceiling_D_E2 received command DECREASE
then
	sendCommand(S_LR_LIGHT_Ceiling_S, DECREASE)
end


rule "DR Ceiling light ON"
when
	Item S_DR_Ceiling_D_E1 received command ON or
	Item S_DR_Ceiling_D_E2 received command ON
then
	sendCommand(S_DR_LIGHT_DiningTable1_S, ON)
end

rule "DR Ceiling light OFF"
when
	Item S_DR_Ceiling_D_E1 received command OFF or
	Item S_DR_Ceiling_D_E2 received command OFF
then
	sendCommand(S_DR_LIGHT_DiningTable1_S, OFF)
end

rule "DR Ceiling light INCREASE"
when
	Item S_DR_Ceiling_D_E1 received command INCREASE or
	Item S_DR_Ceiling_D_E2 received command INCREASE
then
	sendCommand(S_DR_LIGHT_DiningTable1_S, INCREASE)
end

rule "DR Ceiling light DECREASE"
when
	Item S_DR_Ceiling_D_E1 received command DECREASE or
	Item S_DR_Ceiling_D_E2 received command DECREASE
then
	sendCommand(S_DR_LIGHT_DiningTable1_S, DECREASE)
end

The most common way would be to put all items into a group. Furthermore, there is a statement receivedCommand, so, 2 rules instead of 8 rules:

rule "LR Ceiling light"
when
	Item S_LR_Ceiling_D_E1 received command or
	Item S_LR_Ceiling_D_E2 received command 
then
	S_LR_LIGHT_Ceiling_S.sendCommand(receivedCommand)
end

rule "DR Ceiling light"
when
	Item S_DR_Ceiling_D_E1 received command or
	Item S_DR_Ceiling_D_E2 received command 
then
	S_DR_LIGHT_DiningTable1_S.sendCommand(receivedCommand)
end

With a group, as said before, you could reduce this to one rule, but I doubt it would be less code.
If there are much more switches and actuators - let’s say about 10 switches - one could get information about the last updated item (of the group, containing all switches) and then build the name for the actuator, which has to be updated.

I did use the method Item.sendCommand(State) as this is more reliable when using vars. See sendCommand() Documentation for details.