Set state
The Set state action sets a color and brightness on a LIFX light, and can optionally turn the light on or off at the same time. Unlike light.turn_on, which always powers the light on, this action leaves the power state alone unless you ask it to change. That makes it useful for preparing how a light looks while it is still off, so it comes on the way you want when a motion sensor, a button, or another automation switches it on.
This action accepts every color and brightness option that light.turn_on accepts, such as Color name, Brightness, or Color temperature, and adds a few LIFX-only options on top. It works with any light provided by the LIFX integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more].
Using this action from the user interface
If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.
To set the state of a LIFX light from an automation or a script:
- Go to Settings > Automations & scenes.
- Open an existing automation or script, or select Create automation > Create new automation.
- If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
- In the Then do section, select Add action.
- From the search box, search for and select Set state.
- Select what you want to control. Under By target (see Targets), pick the area your LIFX lights are in (like your living room or bedroom). You can also select a floor, a device, a specific entity, or a label.
- Choose the color and brightness you want. Optional: to also switch the lights on or off, enable Power and set it. If you leave Power out, the lights keep the power state they already have.
- Select Save.
Options in the UI
The zone numbers to change on multizone lights, such as the LIFX Z, Lightstrip, and Beam. Zones start counting at 0. Any zone you leave out keeps its current color.
You can also set any color and brightness option that the Turn on light action offers, such as Color name, Brightness, Color temperature, or Effect.
The Infrared option is deprecated. Use the Infrared brightness entity that Home Assistant creates for every LIFX Nightvision bulb instead. In an automation or a script, target that entity with the Select option action. If you still use Infrared, Home Assistant logs a warning that points you at the right entity.
Using this action in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.
In YAML, refer to this action as lifx.set_state. A basic example looks like this:
action: lifx.set_state
target:
entity_id: light.living_room
data:
color_name: "blue"
brightness: 120
transition: 2
This fades the living room light to blue at a brightness of 120 over two seconds, without changing whether the light is on or off.
Options in YAML
Set to true to turn the lights on, or false to turn them off. Leave this out to keep the power state as it is.
Optional, see description
How long, in seconds, it takes to reach the final state, from 0 to 3600.
A list of zone numbers to change on multizone lights, such as the LIFX Z, Lightstrip, and Beam. Zones start counting at 0. Any zone you leave out keeps its current color.
You can also use any color and brightness option that the light.turn_on action accepts, such as color_name, brightness, brightness_pct, hs_color, rgb_color, xy_color, color_temp_kelvin, or effect.
Targets of the action
This action requires a target. The target is the object of the action. You can point the action at a single entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], a device, an area, a floor, or a label, and Home Assistant will run the action on every matching light entity behind that target.
-
Entity: one specific light entity, such as
light.living_room. - Device: every light entity that belongs to a device.
- Area: every light entity in a room or area.
- Floor: every light entity on a floor.
- Label: every light entity that shares a label.
You can also select different target types in one action. For example, you can add a specific entity and an area as targets in the same action to run the action on both of them at once.
Good to know
- If you don’t specify a
poweroption, the light will stay in its current power state. There is no default, so the action won’t switch a light on or off unless you tell it to. - The
infraredoption is deprecated. Home Assistant logs a warning telling you to use the Infrared brightness entity with theselect.select_optionaction instead, and returns an error if the target is not a LIFX Nightvision bulb. - The
zonesoption only applies to multizone lights. On any other LIFX light, it is ignored and the whole light changes color.- LIFX Z and Lightstrip have 8 zones per segment, up to 10 segments, for a maximum of 80 zones (numbered 0 to 79).
- LIFX Beam has 10 zones per segment plus 1 per corner piece, up to 8 segments and 2 corners, for a maximum of 82 zones (numbered 0 to 81).
- LIFX String has 3 zones per bulb and 12 bulbs per segment, for a maximum of 108 zones if you connect three segments together (numbered 0 to 107).
- LIFX Neon Flex comes in two lengths: 6.5ft/2M which has 24 zones and 16ft/5M which has 60 zones for a maximum of 120 zones if you connect two 16ft/5M segments together (numbered 0 to 119).
- To paint several colors across a light in one step, use Paint theme instead of listing zones one at a time.
- This action stops a running software effect such as Pulse or Color loop for you. If a firmware effect such as Move, Flame, Morph, or Sky is running, start with Stop effect so your new color isn’t overwritten.
- This action only works on lights provided by the LIFX integration. Other lights in the target are left alone, and if you name a light that is not a LIFX light, Home Assistant logs a warning instead of returning an error.
Try it yourself
Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.
More examples
Real scenarios where this action shows up in automations and scripts. Copy any example and adapt it to your setup. In the visual editor, select the UI options listed in the example or paste the YAML code.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: preset the hallway lights before they come on
At sunset, set the hallway lights to a dim, warm color without switching them on. When a motion sensor turns them on later that evening, they come on at that setting instead of at their bright daytime one.
- Trigger: Sun: sunset
-
Action: Set state
-
Target: Hallway lights (
light.hallway)
-
Target: Hallway lights (
alias: "Preset the hallway lights for the evening"
triggers:
- trigger: sun
event: sunset
actions:
- action: lifx.set_state
target:
entity_id: light.hallway
data:
color_name: "orange"
brightness_pct: 15
Automation: highlight part of a light strip when the front door opens
Turn the first five zones of a light strip red and switch the strip on when the front door opens. The rest of the strip keeps its current colors.
- Trigger: State: front door opens
-
Action: Set state
-
Target: Light strip (
light.light_strip)
-
Target: Light strip (
alias: "Highlight the light strip when the front door opens"
triggers:
- trigger: state
entity_id: binary_sensor.front_door
to: "on"
actions:
- action: lifx.set_state
target:
entity_id: light.light_strip
data:
zones:
- 0
- 1
- 2
- 3
- 4
color_name: "red"
power: true
transition: 1
Still stuck?
The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.
Related actions
Explore related actions:
-
Paint theme: Paints either a provided theme or custom palette across one or more LIFX lights.
-
Set HEV cycle state: Start or stop a HEV (Clean) cycle on a LIFX Clean bulb.
-
Stop effect: Stop a running effect on LIFX lights.