esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
420 stars 26 forks source link

Shared addressable effects #1495

Closed muxa closed 2 years ago

muxa commented 3 years ago

Describe the problem you have/What new integration you would like I want to be able to create custom addressable effects so that they can be:

Please describe your use case for this integration and alternatives you've tried: I'm working on a MIDI integration which detects MIDI notes, and the next phase of the project is to control addressable LED lights by MIDI. I want to have the logic of mapping MIDI events to LEDs in an effect module, so that a single addressable light can have multiples effects, including multiple MIDI effects.

Additional context An idea to made this work:

addressable_effects:
  - platform: midi # I want to create this component
     midi_in_id: midi1
     id: random_midi_fx
     name: "MIDI Random"
     start_note: "0x15"
     note_on_fade: 500ms
     note_off_fade: 5s
     palette: random # rainbow, white, ...
  - platform: midi # I want to create this component
     midi_in_id: midi1
     id: rainbow_midi_fx
     name: "MIDI Rainbow"
     start_note: "0x15"
     note_on_fade: 500ms
     note_off_fade: 5s
     palette: rainbow.

light:
  - platform: fastled_clockless
    ...
    effects:
      - addressable_rainbow: # this exists
      - addressable_component: # this does not exist
        name: "MIDI Random Custom Name"
        id: random_midi_fx
      - addressable_component: # this does not exist
        id: rainbow_midi_fx
oxan commented 3 years ago

I'm working on custom effects, but life has been busy lately... If you're feeling adventurous, the light/transitions branch in my repository should be somewhat usable.

tungmeister commented 2 years ago

@oxan will this offer the ability to create, say, a twinking random color effect on a single light?

oxan commented 2 years ago

Wait, I misread, this is about effects and not transitions. For effects it's already possible to do this from a component.

tungmeister commented 2 years ago

@oxan, are you saying it's already possible to create a twinkle effect that changes color at random on a single rgb light? If so I couldn't see any way to achieve this via the effects within the light component.

oxan commented 2 years ago

Yes. You can do it either with an addressable lambda effect from YAML, or from a component by using one of the register_*_effect decorators (from esphome.components.light.effects, see e.g. the adalight component for an example).

tungmeister commented 2 years ago

Thanks, I'll take a look 👍

muxa commented 2 years ago

Cool, ESPHome already supports what I want to do, looking at example here: https://github.com/esphome/esphome/tree/dev/esphome/components/adalight

So my custom effects are going to look something like this:

midi_in: # MIDI In support is being added here: https://github.com/esphome/esphome/pull/2698
   - id: midi1

light:
  - platform: fastled_clockless
    ...
    effects:
      - addressable_rainbow: # this exists
      - midi_effect: # this is what I want to build
        name: "MIDI Random"
        midi_in_id: midi1
        start_note: "0x15"
        keys: 88
        note_on_fade: 500ms
        note_off_fade: 5s
        palette: random