YAML for-each in config file?

Hi there,

I created a package to address all binary sensors and switches for my unipi neuron device (one package for controller, one package for an extension module).

Since this is a long and repeating list (e.g. 16 digital inputs where only coil number and name are different), and I use these names again in a group, I was wondering if it is possible to do some kind of for-loop in a yaml config file. Maybe looping through a parameter ?

Like this:

define "inputs":{"0":"DigitalInput_1_1","1":"DigitalInput_1_2","2":"DigitalInput_1_3",.....}

      foreach inputs as key=>val
        - coil: key
          name: val

    - entities:
      foreach inputs as key=>val
          - val

Thanks for your insights :slight_smile:

Not exactly, but this should cut down the repetition a bit…

Hi mf_social,
In this case it’s not going to save me time or shorten my config file, but it surely is good to know the &-function for later use :slight_smile:
Thanks for the info