blueprint:
  name: Awtrix random effect
  description: This blueprint allows you to select the effects, which should be randomly displayed on your Awtrix light
  domain: automation
  author: N1c093
  input:
    awtrix_3:
      name: Awtrix Display
      description: Select the target Awtrix display.
      selector:
        device:
          model: "AWTRIX 3"
    effect_list:
      name: Effects
      description: "Select the effects which should randomly be displayed. See: https://blueforcer.github.io/awtrix3/#/effects"
      selector:
        select:
          options:
            - BrickBreaker
            - Fireworks
            - Radar
            - Snake
            - TheaterChase
            - SwirlOut
            - LookingEyes
            - Pacifica
            - PlasmaCloud
            - Checkerboard
            - PingPong
            - Ripple
            - TwinklingStars
            - ColorWaves
            - SwirlIn
            - Matrix
            - Plasma
            - MovingLine
          mode: list
          multiple: true
    duration:
      name: Effect duration
      description: Select how long each effect should be displayed.
      default: "10"
      selector:
        number:
          min: 1
          max: 999
          mode: box
          unit_of_measurement: seconds
    change_interval:
      name: Effect change interval
      description: 'Select how often (in minutes) the effect should change. Input must start with "/" Example: "/5"'
      default: "/5"
      selector:
        text:
          suffix: minutes

mode: queued

variables:
  device_id: !input awtrix_3
  awtrix_3: "{{ iif( device_attr(device_id, 'name_by_user') != none, device_attr(device_id, 'name_by_user'), device_attr(device_id, 'name') ) }}"
  effect_list: !input effect_list
  effect_random: "{{effect_list|random}}"
  duration: !input duration

trigger:
  - platform: time_pattern
    minutes: !input change_interval

action:
  - service: mqtt.publish
    data:
      qos: 0
      retain: false
      topic: "{{awtrix_3}}/custom/effect"
      payload: |-
        {   
          "effect": "{{ effect_random }}",
          "duration": "{{ duration }}"
        }