AWTRIX 3 - Blueprint for creating simple apps for dummies

here is full example

blueprint:
  name: AWTRIX playing now
  description: Show the current playing track
  domain: automation
  input:
    media_player:
      name: Media player
      description: Media player what you want to control.
      selector:
        entity:
          filter:
            - domain: media_player
          multiple: false

    awtrix_device:
      name: AWTRIX device
      description: The AWTRIX device for show playing status.
      selector:
        device:
          integration: mqtt
          manufacturer: Blueforcer
          model: AWTRIX Light
          multiple: false

trigger:
  - platform: state
    entity_id: !input media_player
    id: player

  - platform: time_pattern
    seconds: '/10'
    id: timer

condition:
  - condition: or
    conditions:
      - condition: trigger
        id:
          - player
      - condition: and
        conditions:
          - condition: trigger
            id:
              - timer
          - condition: template
            value_template: "{{ states(media_player_device) == 'playing' }}"

variables:
  awtrix: !input awtrix_device
  awtrix_device_name: "{{ iif( device_attr(awtrix, 'name_by_user') != none, device_attr(awtrix, 'name_by_user'), device_attr(awtrix, 'name') ) }}"
  media_player_device: !input media_player

action:
  - variables:
      playing_state: "{{ states(media_player_device) }}"
      title_template: "{{ state_attr(media_player_device, 'media_title') }}"
      album_template: "{{ state_attr(media_player_device, 'media_album_name') }}"
      artist_template: "{{ state_attr(media_player_device, 'media_artist') }}"
      playing_percent: "{{ (100 - ((state_attr(media_player_device, 'media_duration') | default(0, true) - (state_attr(media_player_device, 'media_position') | default(0, true) + as_timestamp(now()) - as_timestamp(state_attr(media_player_device, 'media_position_updated_at') | default(now(), true)))) / 60) * 100 / (state_attr(media_player_device, 'media_duration') | default(1, true)  / 60)) | int }}"

  - if:
      - condition: template
        value_template: "{{ playing_state != 'playing' }}"
    then:
      - service: awtrix.{{awtrix_device_name}}_push_app_data
        data:
          name: sonos
          data: {}
    else:
      - service: awtrix.{{awtrix_device_name}}_push_app_data
        data:
          name: sonos
          data:
            rainbow: false
            repeat: 1
            pushIcon: 0
            textCase: 0
            progress: "{{playing_percent}}"
            progressC: "18B04C"
            progressBC: "#333333"
            text: >-
              {{ playing_state~': '~(artist_template ~ ' - ' if artist_template else '') ~ (title_template if title_template else '-') ~ (' ÷ ' ~ album_template ~ ' ÷ ' if album_template else '') }}
            icon: >-
              /9j/4AAQSkZJRgABAgEASABIAAD/4QDKRXhpZgAATU0AKgAAAAgABgESAAMAAAABAAEAAAEaAAUAAAABAAAAVgEbAAUAAAABAAAAXgEoAAMAAAABAAIAAAITAAMAAAABAAEAAIdpAAQAAAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAeQAAAHAAAABDAyMjGRAQAHAAAABAECAwCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAAAigAwAEAAAAAQAAAAikBgADAAAAAQAAAAAAAAAAAAD/wAARCAAIAAgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9sAQwABAQEBAQECAQECAwICAgMEAwMDAwQGBAQEBAQGBwYGBgYGBgcHBwcHBwcHCAgICAgICQkJCQkLCwsLCwsLCwsL/9sAQwECAgIDAwMFAwMFCwgGCAsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsL/90ABAAB/9oADAMBAAIRAxEAPwD8R/2bvjdd/sOeKvhP+zJqHjTwH8P9Obw7b+NfHviPT7aPVtQ1VPtF/fQ6O93AsscjyafLAISAHAbNrNKHhjn/AF+/4fO/8E1f+ikf+UfVf/kOv42v2vf+Sr6T/wBiT4H/APUc02vl6v5qxnA+Azmnh82xLcataCnO0KTvKUpNu86c5dbJc1lFJLY/Z8NxPi8tnWwFFXp05csbyqKyikkrRnFeb01bbe5//9k=
            lifetime: 900
2 Likes

Thank you. I will look at it and make additional tests.

1 Like

Hi. I am trying to understand this application, I have done everything as written, but when I run it, I get an error “UndefinedError: ‘float object’ has no attribute ‘text’”
Here is a sample of my code:

alias: Outdoor_Temperature
description: ""
use_blueprint:
  path: awtrix-simple.yaml
  input:
    app_name: awtrix_outdoor_temp
    entity: sensor.outdoor_temperature
    suffix_text: °
    awtrix_device:
      - eb1be74d7c363471816af76dbd349e3c
    app_icon: "96"
    user_options:
      duration: 5
      color: |-
        {{user_data.colors[(colors.items() | 
            map(attribute='0') |  
            map('int') |  
            sort | select('>=', value_template.text ) | 
            first) | string]}}
    additional_options:
      colors:
        "0": "#00ff7f"
        "5": "#00ff2a"
        "10": "#2aff00"
        "15": "#7fff00"
        "20": "#d4ff00"
        "25": "#ffd400"
        "30": "#ff7f00"
        "-15": "#007fff"
        "-10": "#00d4ff"
        "-5": "#00ffd4"
        icon: "16701"
        text: "{{states(entity_id)|round}}"
    prefix_text: "{{ '+' if value_template.text > 0 }}"

hello,

is there a way to delete multiple all apps without sending multiple time the command with each name of each app ?

yes. reboot device :slight_smile:

alias: AWTRIX DEL ME
description: ""
use_blueprint:
  path: 10der/awtrix-simple.yaml
  input:
    app_name: awtrix_app_del_me
    app_icon: "2355"
    entity: sensor.easyweatherv1_6_4_outdoor_temperature
    awtrix_device:
      - 3135904cc76cc8342758e395c7c19c10
    prefix_text: "{{ '+' if value_template > 0 }}"
    additional_options:
      colors:
        "0": "#00ff7f"
        "5": "#00ff2a"
        "10": "#2aff00"
        "15": "#7fff00"
        "20": "#d4ff00"
        "25": "#ffd400"
        "30": "#ff7f00"
        "35": "#ff5000"
        "40": "#ff2000"
        "-15": "#007fff"
        "-10": "#00d4ff"
        "-5": "#00ffd4"
      value_template: "{{states(entity_id) | round}}"
      color: |-
        {{colors[(colors.items() | map(attribute='0') |
         map('int') | sort | select('>=', value_template) | first) | string]}}
         
    user_options:
      duration: 5
      color: "{{color}}"

awtrix (24)

btw, YAML is whitespace-sensitive* and indentation defines the structure!
i am sorry but wtf in your code?

thats not exactly the answer i was hoping for :sweat_smile:

You will not believe Me, but the same answer was from firmware author :wink:

btw, as an advertisement :smile:

Thanks, it works perfectly. But when I listen to online radio, my clock stops responding and only a button reset helps. I investigated and found out that “playing_percent” is the culprit, because the “media_duration” attribute is 0, it is calculated incorrectly, which causes the crash. I changed the code by adding another condition where I check that “media_duration” is not equal to 0 and then call the application as standard, otherwise I remove “playing_percent”

blueprint:
  name: AWTRIX playing now
  description: Show the current playing track
  domain: automation
  input:
    media_player:
      name: Media player
      description: Media player what you want to control.
      selector:
        entity:
          filter:
            - domain: media_player
          multiple: false

    awtrix_device:
      name: AWTRIX device
      description: The AWTRIX device for show playing status.
      selector:
        device:
          integration: mqtt
          manufacturer: Blueforcer
          model: AWTRIX Light
          multiple: false

trigger:
  - platform: state
    entity_id: !input media_player
    id: player

  - platform: time_pattern
    seconds: '/10'
    id: timer

condition:
  - condition: or
    conditions:
      - condition: trigger
        id:
          - player
      - condition: and
        conditions:
          - condition: trigger
            id:
              - timer
          - condition: template
            value_template: "{{ states(media_player_device) == 'playing' }}"

variables:
  awtrix: !input awtrix_device
  awtrix_device_name: "{{ iif( device_attr(awtrix, 'name_by_user') != none, device_attr(awtrix, 'name_by_user'), device_attr(awtrix, 'name') ) }}"
  media_player_device: !input media_player

action:
  - variables:
      duration: "{{ state_attr(media_player_device, 'media_duration') }}"
      playing_state: "{{ states(media_player_device) }}"
      title_template: "{{ state_attr(media_player_device, 'media_title') }}"
      album_template: "{{ state_attr(media_player_device, 'media_album_name') }}"
      artist_template: "{{ state_attr(media_player_device, 'media_artist') }}"
      playing_percent: "{{ (100 - ((state_attr(media_player_device, 'media_duration') | default(0, true) - (state_attr(media_player_device, 'media_position') | default(0, true) + as_timestamp(now()) - as_timestamp(state_attr(media_player_device, 'media_position_updated_at') | default(now(), true)))) / 60) * 100 / (state_attr(media_player_device, 'media_duration') | default(1, true)  / 60)) | int }}"

  - if:
      - condition: template
        value_template: "{{ playing_state != 'playing' }}"
    then:
      - service: awtrix.{{awtrix_device_name}}_push_app_data
        data:
          name: sonos
          data: {}
    else:
      - if:
          - condition: template
            value_template: "{{ duration != 0 }}"
        then:
          - service: awtrix.{{awtrix_device_name}}_push_app_data
            data:
              name: sonos
              data:
                rainbow: false
                repeat: 2
                pushIcon: 0
                textCase: 0
                progress: "{{playing_percent}}"
                progressC: "18B04C"
                progressBC: "#333333"
                text: >-
                  {{ playing_state~': '~(artist_template ~ ' - ' if artist_template else '') ~ (title_template if title_template else '-') ~ (' ÷ ' ~ album_template ~ ' ÷ ' if album_template else '') }}
                icon: >-
                  /9j/4AAQSkZJRgABAgEASABIAAD/4QDKRXhpZgAATU0AKgAAAAgABgESAAMAAAABAAEAAAEaAAUAAAABAAAAVgEbAAUAAAABAAAAXgEoAAMAAAABAAIAAAITAAMAAAABAAEAAIdpAAQAAAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAeQAAAHAAAABDAyMjGRAQAHAAAABAECAwCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAAAigAwAEAAAAAQAAAAikBgADAAAAAQAAAAAAAAAAAAD/wAARCAAIAAgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9sAQwABAQEBAQECAQECAwICAgMEAwMDAwQGBAQEBAQGBwYGBgYGBgcHBwcHBwcHCAgICAgICQkJCQkLCwsLCwsLCwsL/9sAQwECAgIDAwMFAwMFCwgGCAsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsL/90ABAAB/9oADAMBAAIRAxEAPwD8R/2bvjdd/sOeKvhP+zJqHjTwH8P9Obw7b+NfHviPT7aPVtQ1VPtF/fQ6O93AsscjyafLAISAHAbNrNKHhjn/AF+/4fO/8E1f+ikf+UfVf/kOv42v2vf+Sr6T/wBiT4H/APUc02vl6v5qxnA+Azmnh82xLcataCnO0KTvKUpNu86c5dbJc1lFJLY/Z8NxPi8tnWwFFXp05csbyqKyikkrRnFeb01bbe5//9k=
                lifetime: 900
        else:
          - service: awtrix.{{awtrix_device_name}}_push_app_data
            data:
              name: sonos
              data:
                rainbow: false
                repeat: 2
                pushIcon: 0
                textCase: 0
                text: >-
                  {{ playing_state~': '~(artist_template ~ ' - ' if artist_template else '') ~ (title_template if title_template else '-') ~ (' ÷ ' ~ album_template ~ ' ÷ ' if album_template else '') }}
                icon: >-
                  /9j/4AAQSkZJRgABAgEASABIAAD/4QDKRXhpZgAATU0AKgAAAAgABgESAAMAAAABAAEAAAEaAAUAAAABAAAAVgEbAAUAAAABAAAAXgEoAAMAAAABAAIAAAITAAMAAAABAAEAAIdpAAQAAAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAeQAAAHAAAABDAyMjGRAQAHAAAABAECAwCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAAAigAwAEAAAAAQAAAAikBgADAAAAAQAAAAAAAAAAAAD/wAARCAAIAAgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9sAQwABAQEBAQECAQECAwICAgMEAwMDAwQGBAQEBAQGBwYGBgYGBgcHBwcHBwcHCAgICAgICQkJCQkLCwsLCwsLCwsL/9sAQwECAgIDAwMFAwMFCwgGCAsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsL/90ABAAB/9oADAMBAAIRAxEAPwD8R/2bvjdd/sOeKvhP+zJqHjTwH8P9Obw7b+NfHviPT7aPVtQ1VPtF/fQ6O93AsscjyafLAISAHAbNrNKHhjn/AF+/4fO/8E1f+ikf+UfVf/kOv42v2vf+Sr6T/wBiT4H/APUc02vl6v5qxnA+Azmnh82xLcataCnO0KTvKUpNu86c5dbJc1lFJLY/Z8NxPi8tnWwFFXp05csbyqKyikkrRnFeb01bbe5//9k=
                lifetime: 900

Thank you for getting rid of the MQTT dependency, really cool, love it!! :smile:

1 Like

no “media_duration” :frowning:

for example

btw
instead of if else just use

progress: "{{playing_percent if  duration != 0 else 0}}"
1 Like
"{{states(entity_id)|round}}"
1 Like

i have another question, i have several automations to display different entities, the automation launches well, but the display always stays on the same one. If I deactivate/reactivate the automation, I get the display for 10 sec and then it’s stuck on a different entity. an idea ?

Blocked automation / entity

alias: Awtrix 3
description: ""
use_blueprint:
  path: 10der/awtrix-simple.yaml
  input:
    prefix_text: ""
    entity: sensor.eau_consommation_jour
    suffix_text: L
    boolean_time_update: true
    awtrix_device:
      - 73652c7c45bf5f0097247243076252a6
    user_options:
      duration: 10
    additional_conditions: []
    app_icon: "12989"
    update_frequency: /1
    additional_options:
      value_template: "{{states(entity_id) | round}}"

One of the automations that only works if I trigger manually

alias: Awtrix 1
description: ""
use_blueprint:
  path: 10der/awtrix-simple.yaml
  input:
    prefix_text: ""
    entity: sensor.solaire_quotidien
    suffix_text: KWh {{states('sensor.pourcentage_energie_solaire')}}%
    boolean_time_update: true
    awtrix_device:
      - 73652c7c45bf5f0097247243076252a6
    user_options:
      duration: 10
    additional_conditions: []
    app_icon: "37515"
    additional_options:
      value_template: "{{ states('sensor.solaire_quotidien') | float | round(2) }}"

My crystal ball :crystal_ball: saying about app_name

Indeed! Thanks ! :slight_smile:

1 Like

Hey All,

I’m really struggling with Dynamic icons!
Basically, i’m making a simple solar import / export page

I’m using the multiple text colours list from the temperature example - this works great

BUT, I can’t get the icon to change…
I’d like one icon if the value is negative, and another if positive…

icon_template: “{{ ‘52715’ if value_template > 0 else ‘52648’ }}”
or
icon: “{{ ‘52715’ if value_template > 0 else ‘52648’ }}”

doesn’t seem to work

This example more than clear as for me

1 Like