Home Assistant steuert einen Infinity Cube mit WLED

Ich habe mir einen Infinity-Cube gebaut – mit einem 3D-Druckgehäuse und halbdurchlässigen Spiegeln.
Zunächst lief er über einen D1 Mini, doch inzwischen bin ich auf einen ESP32 umgestiegen und habe ein digitales Mikrofon angeschlossen.

Am Wochenende habe ich eine Automation erstellt, die den Cube einschaltet, wenn Musik spielt, und alle 4 Sekunden die Farbe wechselt. :blush:
Hier das Ergebnis: Der Cube reagiert zur Musik von meinem Spiel SPACE 2022 – einem Space-Shooter! :rocket:

Hier die Automation dazu:

alias: WLED Farbwechsel mit Sonos
triggers:
  - entity_id: media_player.sonos1
    to: playing
    trigger: state
  - entity_id: media_player.sonos1
    to: paused
    trigger: state
  - entity_id: media_player.sonos1
    to: idle
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: media_player.sonos1
            state: playing
        sequence:
          - repeat:
              while:
                - condition: state
                  entity_id: media_player.sonos1
                  state: playing
              sequence:
                - variables:
                    random_color:
                      - "{{ range(0,255)|random }}"
                      - "{{ range(0,255)|random }}"
                      - "{{ range(0,255)|random }}"
                - action: light.turn_on
                  target:
                    entity_id: light.wled_2
                  data:
                    brightness: 255
                    rgb_color: "{{ random_color }}"
                - delay: "00:00:04"
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: media_player.sonos1
                state: paused
              - condition: state
                entity_id: media_player.sonos1
                state: idle
        sequence:
          - action: light.turn_off
            target:
              entity_id: light.wled_2
            data: {}
mode: restart

1 „Gefällt mir“