How do i combine binding (IHC/ELKO Switch item) with Channel (HUE)

Hey im pretty new to OH2 but i have managede to get all of my IHC inputs (Switches) mapped in items and it works…
Now i want to use these switch item to turn on my hue lights how do I do this

sorry for the bad english

HI!

You can create one rule, to make what you need.
Map the input resource of the ihc button to one switch, and when this switch changes state do what you need.

Regards!

HI!
could you show me how that rule would look like, my idear on a rule looks likes this but i doesnt seem to work what am i doing wrong

rule "Hue Bulb On/Off"
when
Item TrykOV7 changed
then
if (Light2_Toggle.state == OFF){
postUpdate(Light2_Toggle, ON)
}
else if (Light2_Toggle.state == ON){
postUpdate(Light2_Toggle, OFF)
}
end

Best Regards
Christian

To command something to do something (like turn a light ON or OFF), you should use sendCommand:

rule "Hue Bulb On/Off"
when
  Item TrykOV7 changed  // if this is the correct trigger
then
  Light2_Toggle.sendCommand(if (Light2Toggle.state == ON) OFF else ON)
end

The item TrykOV7 should be binded to one resource of IHC. Check if the id is correct.

this is from my items file it should be correct since i can see it being activated i Basic UI when i push the button
Switch TrykOV7 “Lyttetryk, Pejs v. Værelse, ØV” (GF_Pejs, Lights) {ihc=“0x6E5c”}
Switch Light2_Toggle (GF_Stue, Lights) {channel=“hue:0100:1:bulb2:brightness”}

Which is the type of the channel “hue:0100:1:bulb2:brightness”? its one number? Maybe you need to set one number instead ON or OFF.

rule "Hue Bulb On/Off"
when
Item TrykOV7 changed // if this is the correct trigger
then
Light2_Toggle.sendCommand(if (Light2Toggle.state == ON) 0 else 100)
end

I think you need to set one PercentType and not one OnOffType.

Hi jmv thanks for the help so far!!!
Maybe i havn’t fully understood rules yet is there something i have to import to the rules file for bindings to talk to eachother???

No problem, I will help you here I’m able to.
You don’t need to import anything for such a simple rule.
What I can advise you is to make the rule in baby steps.

First try to trigger the rule, and just Log one simple phrase.
Then try to send one command to the hue, to increase the brightness to 100%.
You need to discover where your problem effectively is, if in IHC or in the Hue.

Let me know the results!

Regards

So far so good made a rule (very simple) and it works in UI

When Hue_kontor_on is activated in UI, Light2_Toggle goes on…
When Hue_kontor_off is activated in UI, Light2_Toggle goes off…

rule "Hue Bulb ON"
when
Item Hue_kontor_on received command
then
sendCommand(Light2_Toggle, ON)
end

rule “Hue Bulb OFF”

when
Item Hue_kontor_off received command
then
sendCommand(Light2_Toggle, OFF)
end

so next “problem”… when i am watching the UI while pressing the psysical switch (Hue_kontor_on) it goes ON in UI, but when going ON it doesn’t trigger rule

Any Idea???

SOLVED!!!

The Rule Should look like this

rule "Hue Bulb On/Off"
when
Item Hue_kontor_on changed from OFF
then
sendCommand(Light2_Toggle, ON)
end

rule “Hue Bulb OFF”

when
Item Hue_kontor_on changed to OFF
then
sendCommand(Light2_Toggle, OFF)
end

This made it all work…

Thank You All for the help

1 Like

Great! but looking to the rule you can simplify…

rule "Hue Bulb On/Off"
when
Item Hue_kontor_on changed
then
sendCommand(Light2_Toggle, Hue_kontor_on.state)
end

Regards,

Hey great thanks currently im working on the dimmer rule

could the rule you have given here be used with number values as well???

If you update with decimal values, the channel of the brightness you can dimmer the light. Search the forum and you will find some examples. :slight_smile:

Hey again and thanks for all the help

now both the on/off rule and dimmer rule works

2 Likes

Hi RudoX

Will you share how you got i both rule working? :slight_smile:

Hi Alexandersen…¨
They are not the most beautiful written rules but they work…

  1. Rules

//Hue Kontor
rule "Hue Bulb On 2"
when
Item Hue_kontor_on changed from OFF
then
sendCommand(Light2_Toggle, ON)
end

rule “Hue Bulb OFF 2”

when
Item Hue_kontor_on changed to OFF
then
sendCommand(Light2_Toggle, OFF)
end

rule “Hue Kontor Dim”

when
Item Hue_kontor_dim changed
then
var Number tal = Hue_kontor_dim.state as DecimalType
if (Hue_kontor_dim.state instanceof DecimalType) tal = Hue_kontor_dim.state as DecimalType
sendCommand(Light2_Dimmer, tal)
end

  1. Items file Example

// Bulb2 Kontor
Switch Light2_Toggle (GF_Stue, Lights) {channel=“hue:0100:1:bulb2:brightness”}
Dimmer Light2_Dimmer (GF_Stue, Lights) {channel=“hue:0100:1:bulb2:brightness”}
Switch Hue_kontor_on (GF_Stue, Lights) {ihc=“2839314”}
Dimmer Hue_kontor_dim “Lys Niveau Hue Kontor” (GF_Stue, Lights) {ihc=“3108371”}

maybe you could help me write a funktionsblok in IHC-Visual that works better than the ones im using

Im also on www.ihc-user.dk

Hi Rudox

Thanks on IHC-User maybe we can do it in danish :slight_smile:

I will try to make a blok - is it default LK bloks you use now?

/Christian

I ment original not default :slight_smile:

I have made a Hue Funktionblok but i lacks some features i cant quiet figure out how to implement