One Light on at a Time

I tried something slightly different:

      selector:
        entity:
          domain: light
        entity:
          domain: switch

This seems to work without errors.

Still produces the same warning message for me. I’ve narrowed it down to the moment the blueprint is opened to create an automation, the warning message is generated.

I should clarify that in my previous post I called it an error message but, to be more accurate, it’s a warning. Nevertheless, using the blueprint with this multi-domain syntax does generate warning messages.

In addition, the menu fails to produce a complete list of available entities. In other words, when I use this:

  input:
    first_entity:
      name: First Light
      description: Select a light.
      selector:
        entity:
          domain: light
        entity:
          domain: switch
      default: light.hallway_light

It shows me only two entities in the menu, one light and one switch. There’s only one switch available, so that’s fine, but there are many available lights.

I have a second Entity selector defined in the same blueprint:

    second_entity:
      name: Second Light
      description: Select a light.
      selector:
        entity:
          domain: light
      default: light.foyer_light
variables:

This one’s menu lists all available lights (and not just one like in the first selector).

Finally, if I define three domains for the first selector:

  input:
    first_entity:
      name: First Light
      description: Select a light.
      selector:
        entity:
          domain: light
        entity:
          domain: switch
        entity:
          domain: binary_sensor
      default: light.hallway_light

the resulting menu lists all four binary_sensors, only one light, and no switches. That’s different from the previous test but equally wrong.

Given that the generated menus are inconsistent, and warning messages are produced, I believe this is a bug, not an undocumented feature. There’s no way I would want to release a blueprint that leverages this bug because users are likely to encounter unusual selector behavior.

Wait a minute, isn’t the answer here just to use the target selector? It specifically allows you to select multiple entities of the same type.

@123 I just saw your conversation over in the Single user lights blueprint, this is the same situation isn’t it?

I think so. I failed to examine the other one closely and assumed it was tackling the ‘list of lights’ issue the same way as this one. However, I was wrong and the other one uses target constrained to the light domain.

If the same technique is employed here, the service call will need to be modified to accept target as opposed to entity_id.


EDIT

I recall experimenting with the Target Selector and could only constrain it to a single domain.

I also noticed that the author of this topic’s blueprint has chosen to use an Entity Selector with multiple domains, despite the fact it’s unreliable and logs warning messages. :man_shrugging:

Invalid use of multiple domains in an Entity Selector

I tried using the target selector, but while it appears to work, any automations created using it wouldn’t actually work. It would throw an error in the logs along the lines of:

2020-12-22 12:19:12 ERROR (MainThread) [homeassistant.components.automation] Blueprint Keep One Light on at a Time generated invalid automation with inputs OrderedDict([(‘light_list’, OrderedDict([(‘entity_id’, [‘light.basement_stairs’, ‘light.basement_storage’])]))]): Entity ID entity_id is an invalid entity id for dictionary value @ data[‘entity_id’]. Got None

Did you do this?

I tried, but can’t seem to figure out how to do that.