Using a dimmer switch for Philips Hue automation

Randomising Hue scenes in Home Assistant is a small change, but it stops a group of bulbs looking too uniform. I map a dimmer or input control to a base hue, then add a small per-bulb offset so the room stays in one colour family with slight variation from lamp to lamp. That works well when I want a bit of movement without sitting there fiddling with every light.

Pick a control that gives you a value you can use as a base hue. A Hue dimmer, an unused light dimmer, or an input_number in Home Assistant will do. I use a powered but disconnected Hue dimmer as the input because it reports brightness cleanly through the Hue bridge. Map that brightness to a hue range. A simple formula is val/255*315, which maps a 0–255 scale to a 0–315 hue range supported by Hue bulbs. Keep a separate control for white scenes; do not try to force white out of a colour-mapped dimmer every morning. For white or morning scenes, use color_temperature or white_value so the bulbs use Ambiance white properly.

The automation runs the base-hue calculation, then loops over each light in a group and applies a random offset per bulb. I add 0–69 degrees of randomness using range(0,70)|random. Small offsets look natural; large offsets look messy. Short transitions keep the change smooth. This is the basic Home Assistant automation I use. Replace the entity names with your own, and point the light group at the bulbs you want to affect.

alias: Randomised Hue Scene from Dimmer
trigger:
  - platform: state
    entity_id: sensor.hue_dimmer_brightness

action:
  - variables:
      base_val: "{{ trigger.to_state.state | int }}"
      base_hue: "{{ (base_val / 255 * 315) | int }}"
  - service: light.turn_on
    target:
      entity_id: light.your_light_group
    data:
      brightness: "{{ base_val }}"   # optional: map brightness too
  - repeat:
      count: "{{ expand('group.your_light_group') | length }}"
      sequence:
        - variables:
            light_entity: "{{ expand('group.your_light_group')[repeat.index - 1].entity_id }}"
            random_offset: "{{ range(0,70)|random }}"
            final_hue: "{{ (base_hue + random_offset) % 360 }}"
        - service: light.turn_on
          target:
            entity_id: "{{ light_entity }}"
          data:
            hs_color: [ "{{ final_hue }}", 80 ]  # hue, saturation
            transition: 1

Test with small changes first. Start with a narrow random range, such as 0–20, and increase it until the result suits the room. Use transition: 1 for near-instant smooth updates, or 3–5 for a slower fade. If bulbs lag or drop commands, raise the transition and add short delays between per-light calls. If a bulb ignores hs_color, try xy_color or color_temp for Ambiance bulbs, since some Hue models prefer temperature values over full colour at certain firmware versions.

Troubleshooting is usually quick. If the dimmer does not appear in Home Assistant, check the Hue integration status and the bridge connection. If values look wrong, log the variables with notify or persistent_notification to read back base_hue and final_hue. If the random changes look too busy, reduce the random range or only apply randomness when the scene activates, not on every small dimmer change. Keep a dedicated white scene on a second dimmer or an input_boolean so mornings stay readable and consistent.

The basic pattern is simple: map a control value to a sensible hue range, add a small per-bulb offset, and run light.turn_on per bulb with a short transition. That gives the group a less mechanical look without turning it into a rainbow mess.

Related posts

Embedded payloads in trojanised PDF viewers

Modified PDF viewers are a neat little delivery trick because they look like ordinary job bait until someone opens them. I keep coming back to the same point, the file name is not the danger, the...

Immich | v3.3.6

Immich v3 3 6: onnxruntime telemetry disabled in ML container, anonymous metrics stopped, upgrade to v3 3 6 to restore privacy, thanks to the community

Ransomware group fragmentation and detection priorities

Ransomware group fragmentation means the label matters less than the behaviour, and I trust activity over reputation every time. A small crew with rented services can do plenty of damage, so I watch...