IKEA Traadfri not turning brightness to 0 when button is pressed

Hi All,

I’m trying to set up a rule, so my IKEA Traadfri Bulbs are set to Brightness = 0, when I click a button that I’ve already created in my items file.

//This is the Rules file

//IKEA Tradfri

rule "Turn off IKEA Bulbs when Button1 is pressed in Hobbyrum"
when Item HR_Mainlight changed to ON
        then
         if (Hobbyrum_LED1_Bright.state == ON){
                sendCommand(Hobbyrum_LED1_Bright, OFF)
        } else {
                sendCommand(Hobbyrum_LED1_Bright, ON)
}
end

.items file
//This is the Items File

//IHC Switches (Hobbyrum)

Switch HR_Mainlight "Spot Loft" <light> {ihc="0x1F6112"}

//IKEA Tradfri (Hobbyrum)

Dimmer Hobbyrum_LED1_Bright "Hobbyrum LED1 Brightness" { channel="tradfri:0220:mygateway:Hobbyrum_LED1:brightness" }
Dimmer Hobbyrum_LED1_Color "Hobbyrum LED1 Color" { channel="tradfri:0220:mygateway:Hobbyrum_LED1:color_temperature" }

Can anyone explain me what I’m doing wrong here?

Thanks!

Connect also an Switch Item to the Tradfri Bulb Brightness and send the off to this Switch.

//This is the Rules file

//IKEA Tradfri

rule "Turn off IKEA Bulbs when Button1 is pressed in Hobbyrum"
when Item HR_Mainlight changed to ON
    then
     if (Hobbyrum_LED1_Bright_Switch.state == ON){
            sendCommand(Hobbyrum_LED1_Bright_Switch, OFF)
    } else {
            sendCommand(Hobbyrum_LED1_Bright_Switch, ON)
}
end

//IHC Switches (Hobbyrum)

Switch HR_Mainlight "Spot Loft" <light> {ihc="0x1F6112"}

//IKEA Tradfri (Hobbyrum)

Dimmer Hobbyrum_LED1_Bright "Hobbyrum LED1 Brightness" { channel="tradfri:0220:mygateway:Hobbyrum_LED1:brightness" }
Dimmer Hobbyrum_LED1_Color "Hobbyrum LED1 Color" { channel="tradfri:0220:mygateway:Hobbyrum_LED1:color_temperature" }
Switch Hobbyrum_LED1_Bright_Switch "Hobbyrum LED1 Switch" { channel="tradfri:0220:mygateway:Hobbyrum_LED1:brightness" }

I have use Paper UI for the Items, and it works :slight_smile: Try my Example :slight_smile:

Hi @ei_Gelb_Geek,

Thanks for getting back to me. When you click on your button and your Bulbs turns off, does the Dimmer in your BasicUI or Habpanel also changes do 0.
When I use the above code (Some names have changed) nothing happens, when I click on the Switch. It simply stays on the same values.

Is it possible to trigger the dimmer state somehow? So if I turn off the LED1 as mentioned above, then the Dimmer will also turn down to 0?

I will just populate the changes in my conf files so it perhaps makes more sense:

trådfri.items;
//This is the Items File

//IKEA Tradfri (Hobbyrum)

Switch Hobbyroom_LED1_switch "Hobbyrum LED1 Switch" (gHobbyroom_switch) { channel="tradfri:0100:mygateway:Hobbyroom_LED1_dimmer:brightness" }
Dimmer Hobbyroom_LED1_dimmer "Hobbyrum LED1 Brightness" (gHobbyroom_dimmer) { channel="tradfri:0100:mygateway:Hobbyroom_LED1_dimmer:brightness" }
Dimmer Hobbyroom_LED1_color "Hobbyrum LED1 Color" (gHobbyroom_color) { channel="tradfri:0220:mygateway:Hobbyroom_LED1_color:color_temperature" }

Switch Hobbyroom_LED2_switch "Hobbyrum LED1 Switch" (gHobbyroom_switch) { channel="tradfri:0100:mygateway:Hobbyroom_LED2_dimmer:brightness" }
Dimmer Hobbyroom_LED2_dimmer "Hobbyrum LED1 Brightness" (gHobbyroom_dimmer) { channel="tradfri:0100:mygateway:Hobbyroom_LED2_dimmer:brightness" }
Dimmer Hobbyroom_LED2_color "Hobbyrum LED1 Color" (gHobbyroom_color) { channel="tradfri:0220:mygateway:Hobbyroom_LED2_color:color_temperature" }

Switch Hobbyroom_LED3_switch "Hobbyrum LED1 Switch" (gHobbyroom_switch) { channel="tradfri:0100:mygateway:Hobbyroom_LED3_dimmer:brightness" }
Dimmer Hobbyroom_LED3_dimmer "Hobbyrum LED1 Brightness" (gHobbyroom_dimmer) { channel="tradfri:0100:mygateway:Hobbyroom_LED3_dimmer:brightness" }
Dimmer Hobbyroom_LED3_color "Hobbyrum LED1 Color" (gHobbyroom_color) { channel="tradfri:0220:mygateway:Hobbyroom_LED3_color:color_temperature" }

Switch Hobbyroom_LED4_switch "Hobbyrum LED1 Switch" (gHobbyroom_switch) { channel="tradfri:0100:mygateway:Hobbyroom_LED4_dimmer:brightness" }
Dimmer Hobbyroom_LED4_dimmer "Hobbyrum LED1 Brightness" (gHobbyroom_dimmer) { channel="tradfri:0100:mygateway:Hobbyroom_LED4_dimmer:brightness" }
Dimmer Hobbyroom_LED4_color "Hobbyrum LED1 Color" (gHobbyroom_color) { channel="tradfri:0220:mygateway:Hobbyroom_LED4_color:color_temperature" }

Switch Hobbyroom_LED5_switch "Hobbyrum LED1 Switch" (gHobbyroom_switch) { channel="tradfri:0100:mygateway:Hobbyroom_LED5_dimmer:brightness" }
Dimmer Hobbyroom_LED5_dimmer "Hobbyrum LED1 Brightness" (gHobbyroom_dimmer) { channel="tradfri:0100:mygateway:Hobbyroom_LED5_dimmer:brightness" }
Dimmer Hobbyroom_LED5_color "Hobbyrum LED1 Color" (gHobbyroom_color) { channel="tradfri:0220:mygateway:Hobbyroom_LED5_color:color_temperature" }

Switch Hobbyroom_LED6_switch "Hobbyrum LED1 Switch" (gHobbyroom_switch) { channel="tradfri:0100:mygateway:Hobbyroom_LED6_dimmer:brightness" }
Dimmer Hobbyroom_LED6_dimmer "Hobbyrum LED1 Brightness" (gHobbyroom_dimmer) { channel="tradfri:0100:mygateway:Hobbyroom_LED6_dimmer:brightness" }
Dimmer Hobbyroom_LED6_color "Hobbyrum LED1 Color" (gHobbyroom_color) { channel="tradfri:0220:mygateway:Hobbyroom_LED6_color:color_temperature" }

Number myScenarios "Scenario [%s]"

Group gHobbyroom_switch
Group gHobbyroom_dimmer
Group gHobbyroom_color

ihc.items;
//This is the Items File

//IHC Switches (Hobbyrum)

Switch left_IHC_PUSH "Spot Loft" (Light) {ihc="0x7545C"}

.rules;
rule "Turn off Trådfri Bulbs left_IHC_Push"
when
Item left_IHC_PUSH changed to ON
then
if (Hobbyrum_LED1_switch.state == ON){
sendCommand(Hobbyrum_LED1_switch, OFF)
} else {
sendCommand(Hobbyrum_LED1_switch, ON)
}
end

.sitemap
sitemap home label=“The View”
{
Frame label=“Hobby rum”
{
Switch item=left_IHC_PUSH icon=“switch” label=“Loft Spots (IHC Tastetryk)“
Slider item=gHobbyroom_dimmer label=“Loft Spots [%.1f %%]“
Slider item=gHobbyroom_color icon=“colorpicker” label=“Loft Spots Farve [%.1f %%]” valuecolor=[<33=”#D8D8D8”,<66=”#FACC2E”,<101="#FF8000"]
Switch item=myScenarios mappings=[0=“OFF”,1=“ON”,2=“Morgen”,3=“Aften”]
Text item=Hobbyroom_dimmer label=“Trådfri Bulbs” icon=“light” {
Frame label=“LED1"
Switch item=Hobbyroom_LED1_switch label=“Test"
Slider item=Hobbyroom_LED1_dimmer label=“Brightness [%.1f %%]“
Slider item=Hobbyroom_LED1_color icon=“colorpicker” label=“Color Temperature [%.1f %%]” valuecolor=[<33=”#D8D8D8”,<66=”#FACC2E”,<101="#FF8000"]
}
}
}

I forgot to mention,

That currently I’m playing around with myScenarios

rule "My Scenarios"
when
    Item myScenarios changed
then
    switch (myScenarios) {
        case 0: {
            Item1.sendCommand(OFF)
            Item2.sendCommand(OFF)
            Item3.sendCommand(OFF)
            Item4.sendCommand(OFF)
        }
        case 1: {
            Item1.sendCommand(ON)
            Item2.sendCommand(ON)
            Item3.sendCommand(ON)
            Item4.sendCommand(ON)
        }
        case 2: {
            Item1.sendCommand(OFF)
            Item2.sendCommand(OFF)
            Item3.sendCommand(ON)
            Item4.sendCommand(ON)
        }
        case 3: {
            Item1.sendCommand(ON)
            Item2.sendCommand(ON)
            Item3.sendCommand(OFF)
            Item4.sendCommand(OFF)
        }
        default: { 
            logInfo("myScenarios","incorrect state: {}",myScenarios.state)
        }
    }
end

So that will be why you see the Number myScenarios “Scenario [%s]” in the traadfri.items file and also why you see the
Switch item=myScenarios mappings=[0=“OFF”,1=“ON”,2=“Morgen”,3=“Aften”] in my sitemap.

I’m guessing that it should be possible to do the same here? Just can’t get it to walk with the above commands you already gave me :sweat::disappointed_relieved:

Yes … my Switch turned off, when i dimm to = 0%

Hey @ei_Gelb_Geek,

Thats exactly what I want!!!
So I’m guessing you created a Dimmer and a Switch as a Dummy and then Linked the IKEA Bulb to those two?

For some reason I can’t edit the category when being on the webinterface - I’m doing it all through ssh.
Is it possible that I could see your item, rule and sitemap file perhaps?

There is no Rule and Item File for this … :slight_smile:

I create the Item in PaperUI and linked them to the Bulb

You can’t edit the category in PaperUI, because you create the Item in the .items and not with PaperUI …

In the Sitemap is nothing spectacular :wink:

Text label="Wohnzimmer" icon="wohnzimmer"
                {
                  Frame label="Beleuchtung"
                  {
                    Switch item=Stehlampe_Wohnzimmer_Switch label="Stehlampe"
                    Slider item=Stehlampe_Wohnzimmer_Brightness label="Stehlampe [%.1f %%]"
                  }
                }

Oh Okay… so you added all the things in the PaperUI…

So you didn’t create a traadfri.things or a traadfri.items fiel am I correct?

Yes so I have done this, but both are normally possible

Yeah it should be…
The only thing I don’t understand is, when I try to search for my IKEA Bulbs it only comes up with the 0220 color temperature. It doesn’t add the second one with the 0100. Did you also have to manually add that?

Perhaps a Bug in Tradfri Binding?

I have no Bulb with Color Temperature … only the Brightness Bulb …

Perhaps yes.

I’m not sure whether I should go with all the setup in PaperUI or stick with my conf files…
But thanks a lot for your help!