Philips Hue "fluid" dimming using press-and-hold

Hi all,

Just wanted to share how I got dimming to work using a binary_sensor (my LK IHC-buttons) and Philips Hue bulbs.

It involves a few scripts and automations, and is probably way more complicated than it needs to be, but it works great for me, and has been for a long time now.

In order this to work, we need to get a few things from our Hue-bridge. Username, and the Group ID’s from the hue-groups we want to adjust.

Let’s start with the username.
Follow this guide here:
https://developers.meethue.com/develop/get-started-2/ (if you have a developer account) or
just see the page as PDF HERE and follow the instructions.

Once you have a username that looks like this format; “1028d66426293e821ecfd9ef1a0731df” replace <CHANGE_THIS_TO_YOUR_HUE_USERNAME> in each of the attached .sh scripts with the username, like so: http://192.168.100.114/api/1028d66426293e821ecfd9ef1a0731df/groups/$1/action

So now we should be able to communicate with the bridge - so now we just need to get the group-id’s.
Head back to https://HUE_BRIDGE_IP/debug/clip.html and add this command:
/api/<hue_username>/groups/
and press GET.

Now you should see all your light-groups, and you simply find the group you want to dim, and write the number in the 3 attached automations (under “groupid”).


Below are the things you need to add to Home Assistant:

Automations: (unless you go template-crazy, you will need these 3 automations for each room you want to be able to dim)

  - alias: 'Raise lights'
    hide_entity: True
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: binary_sensor.1_3 #IHC button used to dim up
        to: 'on'
    action:
      - service: shell_command.dimup
        data_template:
          groupid: '4' #hue group id
            
  - alias: 'Lower lights'
    hide_entity: True
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: binary_sensor.1_4 #IHC button used to dim down
        to: 'on'
    action:
      - service: shell_command.dimdown
        data_template:
          groupid: '4' #hue group id
            
  - alias: 'Stop dimming stue'
    hide_entity: True
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: binary_sensor.1_3
        to: 'off'
      - platform: state
        entity_id: binary_sensor.1_4
        to: 'off'
    action:
      - service: shell_command.dimstop
        data_template:
          groupid: '4' #hue group id

Shell_command:

  dimstop: 'sh /config/scripts/dimstop.sh "{{groupid}}"' #stop dimming hue-group
  dimdown: 'sh /config/scripts/dimdown.sh "{{groupid}}"' #dim down
  dimup: 'sh /config/scripts/dimup.sh "{{groupid}}"' #dim up

scripts: (place files in /config/scripts/)
Download HERE