blueprint:
  name: AWTRIX Unwetter alerts
  description: Unwetter warnungen auf dem AWTRIX Display anzeigen
  author: DJ-Bauer
  domain: automation
  input:
    warning_sensor:
      selector:
        entity:
          domain: sensor
    mqtt_topic:
      selector:
        text:
mode: single
variables:
  warning_sensor: !input warning_sensor
trigger:
  - platform: numeric_state
    entity_id: !input warning_sensor
    above: 1
action:
  - alias: Warnungstyp setzen
    variables:
      warning: >-
        {{ state_attr(warning_sensor, "warning_1_type") }}
  - alias: Icon setzen
    variables:
      icon: |-
        {{ "ww-frost" if warning <= 22 else
          "ww-thunderstorm" if warning <= 49 else
          "ww-wind" if warning  <= 56 else
          "ww-fog" if warning <= 59 else
          "ww-pouring" if warning <= 66 else
          "ww-snow" if warning <= 76 else
          "ww-blackice" if warning <= 87 else
          "ww-thaw" if warning <=  89 else
          "ww-thunderstorm" if warning <= 96 else
          "ww-generic" }}
  - service: script.awtrix_notify
    metadata: {}
    data:
      device: !input mqtt_topic
      duration: "00:00:05"
      text: >-
        {{ state_attr(warning_sensor, "warning_1_name") }}
      icon: "{{ icon }}"
      hexcolor: >-
        {{ state_attr(warning_sensor, "warning_1_color")}}
      hold: true
