LIFX Setstate stopped working

I’ve been running a script to set the LIFX lights to a different colour for some time now and just of late it doesn’t set the scenes as it used to.

It now flashes the lights and does nothing.

service: lifx.set_state
data:
  brightness_pct: "10"
  rgb_color:
    - 255
    - 0
    - 0
  transition: "2700"
target:
  entity_id:
    - light.hall_strip

The brightness and duration no longer does what it would normally do. The colour is Red like it should be but it stays as bright as it last was before it was changed by setstate

I am also having a very similar issue since updating.

Lifx “set state” no longer controls lifx bulbs reliably. It won’t set a kelvin value and sometimes the colour will not change on previously stable automations.

Hey folks, sorry for this unexpected breakage. This should be fixed in 2022.11.2.

I’m having issues with this today.

It looks like setState is getting the changes from the automation as shown here (I hardcoded brightness for testing):

But when I run it, nothing happens. No color or brightness change. This has the same API as light.turn_on right?

I figured out what was going on, but not how to fix it.

If I do Set State on multiple entities (specifically light groups), it doesn’t work:

But if I do it on a label of every light in those groups, then it works fine.

So is this a problem where it’s getting the light group and Home Assistant isn’t applying “Set State” changes to the individual lights or is it something that needs to be fixed in the LIFX integration?

You can’t target light groups, just LIFX devices. This is a limitation of how the service works.

And always has been. I ran into this limitation years ago with legacy groups.

This template code is a mess, and I couldn’t figure out a way to create a Home Assistant helper template out of it, but this grabs all light entities currently turned on within those groups so long as those groups don’t include other groups:

      {% set light_groups = ['light.basement_lights',
      'light.bedroom_hallway_lights', 'light.dining_room_lights',
      'light.entryway_lights', 'light.guest_bathroom_lights',
      'light.guest_bedroom_lights', 'light.guest_bedroom_vanity_lights',
      'light.kids_bedroom_lights', 'light.kids_bedroom_vanity_lights',
      'light.kitchen_lights', 'light.living_room_lights',
      'light.master_bathroom_lights', 'light.master_bedroom_lights',
      'light.master_closet_lights', 'light.office_lights'] %} {% set
      lights_in_group = light_groups | map('state_attr', 'entity_id') | list %}
      {% set lights_on_in_group = lights_in_group | sum(start=[]) |
      select('is_state', 'on') | list %} {{ lights_on_in_group }}

With LIFX’s Set State, I don’t need the lights to be turned on to change their state, but minimizing the number of lights to target helps speed things up and limit network traffic.

What I’m wondering is if there’s an advantage to using LIFX’s Set State vs just light.turn_on?

The only advantage is the ability to change the HSBK values without the light being on. Then, any plain light.turn_on service call will turn the bulb on with the updated values.

I use the Adaptive Lighting custom integration to generate values that I pass to lifx.set_state across the house in a single automation so that all the other automations can just call light.turn_on without having to customise each one, e.g. motion-controlled or other automatic light control.

1 Like