LocalBytes / localdeck-config

5 stars 3 forks source link

Use native repeat action for bliplights #39

Closed mcristina422 closed 2 months ago

mcristina422 commented 2 months ago

While configuring the device in YAML form, testing new device interactions, I wanted to simplify the generated script blip_light to be less verbose in its YAML form. This uses the native repeat action from ESPHOME.

Fixes #31

The original codegen output: https://github.com/LocalBytes/localdeck-config/blob/9fa3704d7e8937e87561d747afbc43a770fdb94b/packages/localdeck-codegen/esphome-localdeck.yaml#L1165-L1350

New generated output

  - id: blip_light
    parameters:
      led_index: int
    mode: parallel
    then:
      - repeat:
          count: '20'
          then:
            - light.addressable_set:
                id: ledstrip
                range_from: !lambda return led_index;
                range_to: !lambda return led_index;
                red: !lambda return 1.0 - ((float)iteration / 20);
                green: !lambda return 1.0 - ((float)iteration / 20);
                blue: !lambda return 1.0 - ((float)iteration / 20);
                white: !lambda return 1.0 - ((float)iteration / 20);
            - delay: 25ms
AAllport commented 2 months ago

None of them CI fails look like they're due to the contrib... will look to merge 🔜

AAllport commented 2 months ago

This works especially and is a much more elegant solution than before. It will be in today's release.

Great job!