Duplicated Mapping Key Warning

I’m getting this warning in a blueprint. I want to have choices from both device_classes when defining the trigger . Although I get a warning, the blueprint seems to work as I would like it to. I get choices for both motion and occupancy device classes when I use it. How should this be written to avoid the warning? I’m new to HA and yaml. Thanks!

duplicated mapping key (12:11)
9 | entity:
10 | domain: binary_sensor
11 | device_class: motion
12 | device_class: occupancy
----------------^

Is that a trigger? Hard to tell without more of the code.
If it is a trigger, just do 2 triggers, one for motion, one for occupancy. I doubt that the trigger can take a list there, but 2 triggers should get you triggering when either one happens.

If it’s a selector, check the selector documentation to get the syntax right to put that into a filter.

Using the same key twice in any yaml construct is not going to work.

Thanks for your reply. I’m a newbie when it comes to YAML. It is in fact a selector. I found this under the Device Selector docs:

device_class device_class | list (optional)
Can be either a string with a single device_class, or a list of string device_class to limit the selection to.

So a list is optional. As a newbie to YAML it took me quite a while to find how a list should be entered in YAML. List is such a common term I kept getting all kinds of worthless matches to my searches. I’m a bit chagrined that it is such a simple thing. Once I found:
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
It was clear. In my case:

      selector:
        entity:
          domain: binary_sensor
          device_class:
            - motion
            - occupancy

works. Such a simple thing, but hard to find the right answer. Thanks for your help!

That is in fact the deprecated syntax. The current syntax is found here in the HA docs as I stated with the filter keyword.

I studied the selector documentation, is this what you mean? It seems there is more than one way to specify a list. I’m confused about the usage of dashes after filter:

entity:
  filter:
    - domain: binary_sensor
      device_class: [motion, ccupancy]
1 Like