Command a Philips Hue light from a KNX switch through openHAB

I am using openHAB as my main home automation server. I want to be able to switch on/off Philips Hue lights with the Gira KNX TS3 sensors installed in my rooms.

Basically, you need to create a group address, map it to the TS switch channel, create a virtual KNX device in openHAB and create two rules to link both objects (one rule for switching ON and one for switching OFF).

In the ETS software, create a group address (e.g. 1/9/9) and map it to the TS button’s channel that should allow switching the Hue light ON and OFF.

In openHAB, create a KNX device thing called Virtual KNX switch. Add a channel with type Switch Control and configure it to address 1/9/9. Map an item of type Contact to this channel (let’s name it KitchenVirtualSwitch).

Assuming that your Hue light is called HueLight, create a rule to switch the light ON:

configuration: {}
triggers:
  - id: "1"
    configuration:
      command: ON
      itemName: KitchenVirtualSwitch
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: "

        \          HueLight.sendCommand(ON)

        \          logInfo( \"openHAB.Rules\",\"KitchenVirtualSwitch TS => Hue ON\"
        )

        \ "
    type: script.ScriptAction

The logInfo entry is optional, but very helpful when debugging. Let’s create a second rule for switching the light OFF:

configuration: {}
triggers:
  - id: "1"
    configuration:
      command: OFF
      itemName: KitchenVirtualSwitch
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: "

        \          HueLight.sendCommand(OFF)

        \          logInfo( \"openHAB.Rules\",\"KitchenVirtualSwitch TS => Hue OFF\"
        )

        \ "
    type: script.ScriptAction

Leave a Reply