img using a dimmer switch for philips hue automation

Using a dimmer switch for Philips Hue automation

Creating randomised hue scenes for Philips Hue lights inside Home Assistant is a small tweak that makes groups of bulbs look less identical. I show a practical setup that maps a dimmer or an input control to a base hue, then adds a per-bulb random offset so the room keeps a single colour family while each lamp has a subtle variation. This works well for Philips Hue automation when we want natural, lively colour without constant manual fiddling. I include a ready-to-paste YAML example and notes on testing and common faults.

Pick a control that reports a value you can use as a base hue. A Hue dimmer, an unused light dimmer, or an inputnumber in Home Assistant will do. I use a powered but disconnected Hue dimmer as my 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; don’t try to force white out of a colour-mapped dimmer every morning. For white or ‘morning’ scenes use colourtemperature or white_value so bulbs use Ambiance white properly.

The automation logic 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 chaotic. Short transitions keep the change smooth. Below is a basic Home Assistant automation that demonstrates the approach. Replace entity names with your own, and set the light group to the bulbs you want to affect.

yaml
alias: Randomised Hue Scene from Dimmer
trigger:

  • platform: state
    entityid: sensor.huedimmer_brightness
    action:
  • variables:
    baseval: “{{ trigger.tostate.state | int }}”
    basehue: “{{ (baseval / 255 * 315) | int }}”
  • service: light.turnon
    target:
    entity
    id: light.yourlightgroup
    data:
    brightness: “{{ base_val }}” # optional: map brightness too
  • repeat:
    count: “{{ expand(‘group.yourlightgroup’) | length }}”
    sequence:
    – variables:
    lightentity: “{{ expand(‘group.yourlightgroup’)[repeat.index – 1].entityid }}”
    randomoffset: “{{ range(0,70)|random }}”
    final
    hue: “{{ (basehue + randomoffset) % 360 }}”
    – service: light.turnon
    target:
    entity
    id: “{{ lightentity }}”
    data:
    hs
    color: [ “{{ final_hue }}”, 80 ] # hue, saturation
    transition: 1

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

Troubleshoot common issues quickly. 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 persistentnotification to read back basehue and finalhue. If random changes look too busy, reduce the random range or apply randomness only on scene activation and not on small dimmer adjustments. Keep a dedicated white scene controlled by a second dimmer or an inputboolean so mornings stay readable and consistent.

Final takeaways: map a control value to a sensible hue range, apply a small per-bulb random offset, and run light.turn_on per bulb with a short transition. That gives a lived-in, natural look while keeping the group visually coherent. Philips Hue automation like this is low-effort and high-impact for a UK smart home looking to stop everything looking factory-identical.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prev
Revamping Home Assistant dashboards for better usability
img revamping home assistant dashboards for better usability home assistant automation

Revamping Home Assistant dashboards for better usability

Transform your Home Assistant setup into a truly efficient smart home with

Next
ESPHome | 2025.12.2
esphome 2025 12 2

ESPHome | 2025.12.2

ESPHome 2025

You May Also Like