AWTRIX 3 - Blueprint for creating simple apps for dummies

last step just copy this file homeassistant-custom_components-awtrix/awtrix-simple.yaml at 2fd9a528d3e78de641009c34d2015fa910b493f9 · 10der/homeassistant-custom_components-awtrix · GitHub
as
to HASS path as blueprints/automation/10der/awtrix-simple.yaml

Hint: You can’t directly import his blueprint in HA via the blueprint import function, because it is not marked as yaml in the first post.

If you mark it as yaml in the post, it could be added more easily via he UI

1 Like

Fixed and THANK YOU!

Here is a link copy

2 Likes

for UA :ukraine: guys!
:pray:

awtrix

alias: "AWTRIX: alert UA map"
description: ""
use_blueprint:
  path: 10der/awtrix-simple.yaml
  input:
    pre_actions:
      - action: rest_command.ukraine_alerts
        data: {}
        response_variable: alerts
      - action: rest_command.ukraine_alerts_drones
        data: {}
        response_variable: alerts_drones
      - action: rest_command.ukraine_alerts_rockets
        data: {}
        response_variable: alerts_rockets
    entity: binary_sensor.m_dnipro_ta_dniprovska_teritorialna_gromada_air
    additional_options:
      region_data: |-
        {% set regions = { 
           "м. Київ": [80],
           "Івано-Франківська область": [107],
           "Волинська область": [43, 44],
           "Одеська область": [174, 175, 207, 238],
           "Полтавська область": [82, 83, 114],
           "Кіровоградська область": [144, 145, 146],
           "Сумська область": [18, 50, 51],
           "Автономна Республіка Крим": [209, 210, 211, 242],
           "Донецька область": [117, 149, 150],
           "Черкаська область": [112, 113],
           "Закарпатська область": [106, 138, 139],
           "Вінницька область": [110, 111, 142, 143],
           "Рівненська область": [45],
           "Тернопільська область": [108],
           "Київська область": [48, 81],
           "Чернігівська область": [17, 49],
           "Чернівецька область": [140, 141],
           "Миколаївська область": [176, 177],
           "Херсонська область": [178, 179],
           "Луганська область": [86, 118, 119],
           "Львівська область": [75, 76],
           "Хмельницька область": [77, 109],
           "Харківська область": [84, 85, 116],
           "Житомирська область": [46, 47, 78, 79],
           "Запорізька область": [180, 181],
           "Дніпропетровська область": [115, 147, 148]
        } %}
        {{regions}}
      my_region: Дніпропетровська область
      my_alerts: >-
        {% set value_drones = alerts_drones.content.states.get(my_region) %}  {%
        set value_drones = value_drones if value_drones else 999999999 %} {% set
        value_rockets = alerts_rockets.content.states.get(my_region) %} {% set
        value_rockets = value_rockets if value_rockets else 999999999 %}        

        {% set known_alert = true %}

        {% if (value_drones > 3600 and value_rockets > 3600) %}
          {% set known_alert = false %}
        {% endif %}

        {% if known_alert %}
          {{ 'd' if value_drones < value_rockets else 'r' }}
        {% else %}
           'x'
        {%endif%}
      now_alerts: |-
        {% set ns = namespace(result=[]) -%}
        {% for v in alerts.content.states -%}
          {% if alerts.content.states[v] -%} 
            {% set ns.result = ns.result + [v] %} 
          {% endif -%} 
        {% endfor -%}
        {{ns.result}}
      draw_payload: >-
        {% set ns = namespace(result=[]) -%}

        {% for key, value in region_data.items() -%}
          {% if key in now_alerts -%}
             {% set color = "#FF0000" %}
          {% else -%}
             {% set color = "#00FF00" -%}
          {% endif -%}
           {% for item in value -%}
            {% set ns.result = ns.result + [{"dp": [item % 32, item // 32, color]}] -%} 
           {% endfor -%}
        {% endfor %}

        {% set shahed = [{"dl":[25, 7,  29, 7, "#FF0000"]}, {"dl":[26, 6,  28,
        6, "#FF0000"]}, {"dl":[27, 5,  27, 5, "#FF0000"]}] %}

        {% set missile = [{"dl":[27, 7,  27, 1, "#FF0000"]}, {"dl":[26, 4,  28,
        4, "#FF0000"]}] %}

        {% if alerts.content.states.get(my_region) %}
          {% set warning = [] %}
          {% if my_alerts == 'd' %}
          {% set warning = shahed %}
          {% elif my_alerts == 'r' %}
          {% set warning = missile %}
          {% endif -%}
          {% set ns.result = ns.result + warning -%}
        {% endif -%} {{ns.result}}
    additional_conditions:
      - condition: state
        entity_id: binary_sensor.m_dnipro_ta_dniprovska_teritorialna_gromada_air
        state: "on"
    app_name: awtrix_alarm_map
    user_options:
      duration: 10
      draw: "{{draw_payload}}"
      text: ""
    app_icon: "16701"
    awtrix_device:
      - 3135904cc76cc8342758e395c7c19c10
1 Like

Sorry, no beep

Are just put text in the action or home assistant build it?

switch to UI mode


from action choose rtttl and device

key text two_short:d=4,o=5,b=100:16e6,16e6

press perfom action

Any idea why this temperature app is not updating/pushing to the clock?

it only shows on the clock if y press run actions in the automation

1

variables:
  entity_id: sensor.temp_lux_living_room_temperature
  app_name: awtrix_app
  app_icon: "96"
  additional_conditions: []
triggers:
  - entity_id: sensor.temp_lux_living_room_temperature
    id: update
    trigger: state
  - event: start
    id: update
    trigger: homeassistant
  - event_type: automation_reloaded
    id: update
    trigger: event
  - triggers: null
conditions: []
actions:
  - choose: []
    default: null
  - alias: Variable Entity
    variables: {}
  - variables:
      alias: Variable Entity
      variables: {}
      device_ids:
        - 03aba72f131fdb43986935299709c57d
      user_data: {}
      value_template: "{{ user_data.get('value_template', states(entity_id)) }}"
      icon_template: "{{ user_data.get('icon_template', app_icon) }}"
      prefix_text: ""
      suffix_text: C
      user_options:
        duration: 5
      payload: |-
        {
          {{('"icon"' if icon_template) ~ (":" if icon_template) ~ ('"' ~ icon_template ~ '"' if icon_template) }}
          {{"," if icon_template}} "text":"{{prefix_text~value_template~suffix_text}}"
        }
  - repeat:
      for_each: "{{ device_ids }}"
      sequence:
        - variables:
            awtrix_device_name: >-
              {{ iif( device_attr(repeat.item, 'name_by_user') != none,
              device_attr(repeat.item, 'name_by_user'), device_attr(repeat.item,
              'name') ) }}
        - if: []
          then:
            - data:
                name: "{{app_name}}"
                data: "{{ dict(payload, **user_options) }}"
              action: awtrix.{{awtrix_device_name}}_push_app_data
          else:
            - data:
                name: "{{app_name}}"
                data: {}
              action: awtrix.{{awtrix_device_name}}_push_app_data
alias: AWTRIX Living room temp
description: ""

| round

also i can recommend to look samples

round fixed it.

Used the code from examples for home temperature, but like pasted above it does not show up on the clock, only if I press run automation but then never again

Strange. it must work without triggers! at all!

STOP! you do NOT use blueprint.
sorry.

Sorry but don’t understand…

I made it through the blueprint, I copied the code so you could maybe see where the error is. Anyway like I said somehow it doesn’t show the temperature sensor info on the clock…

The energy sensor works fine, but temperature one just never shows up, no matter the temperature sensor I chose.

On this pic is blueprint, right
On previous- no.

For understanding what happens please click a button trace

Here you have the Trace.

It executes once when creating the app, but then never again ( tried with like 6 different temp senors of HA )

It only shows again on the clock if I press “run actions” button


idk. Maybe I can’t help you here.

it’s my automation

alias: AWTRIX - HOME_TEMPERATURE
description: ""
use_blueprint:
  path: 10der/awtrix-simple.yaml
  input:
    app_name: awtrix_app_home
    entity: sensor.home_temperature
    suffix_text: °
    awtrix_device:
      - 3135904cc76cc8342758e395c7c19c10
      - cba036557ec6a93c46e1772448fac471
    app_icon: "96"
    value_template: null
    user_options:
      duration: 5
      pos: 3
      color: |-
        {{user_data.colors[(colors.items() | 
            map(attribute='0') |  
            map('int') |  
            sort | select('>=', value_template ) | 
            first) | string]}} 
    additional_options:
      colors:
        "0": "#00ff7f"
        "5": "#00ff2a"
        "10": "#2aff00"
        "15": "#7fff00"
        "20": "#d4ff00"
        "25": "#ffd400"
        "30": "#ff7f00"
        "35": "#ff5f00"
        "-15": "#007fff"
        "-10": "#00d4ff"
        "-5": "#00ffd4"
      value_template: "{{states(entity_id) | round(0, 'floor', 0) }}"
    prefix_text: "{{ '+' if value_template > 0 }}"

works like a charm without manual triggering at all:

some history

Thank you.

I have been observing the temperature app created in my HA. So basically the temperature only shows on the clock if the temperature sensor has a state change. So for example when temp changes from 20 to 21 it will show but if it never changes from 21 for example, it will not show again.

1 Like

Hello,

The blueprint used for weather forecast was working for couple of week and since couple of days now it is reporting an error in the Execution History: UndefinedError: ‘value_template’ is undefined.
I have tried to troubleshoot with the prior messages of this forum around the weather forecast but I do not see what went wrong.
I would appreciate any advice.

alias: Awtrix - Meteo
description: ""
use_blueprint:
  path: 10der/awtrix-simple.yaml
  input:
    entity: sensor.station_meteo_ecowitt_outdoor_temperature
    awtrix_device:
      - 1891c4f45bf8d39f11232c53dc46b77b
    additional_action:
      - variables:
          icons:
            clear-night: a12181
            cloudy: a2283
            exceptional: a2364
            fog: "17056"
            hail: a2441
            lightning: a630
            lightning-rainy: a49299
            partlycloudy: a2286
            pouring: a49300
            rainy: a2284
            snowy: a2289
            snowy-rainy: a49301
            sunny: a2282
            windy: a15618
            windy-variant: a15618
            unavailable: "52176"
    user_options:
      duration: 5
      pos: 0
      text: ""
      icon: "{{icons[states('weather.aussonne')]}}"
      draw: |
        {%- macro draw_forecast_lines() %}
          {%- set hours = 24 %}
          {%- for hour in range(hours) %}
            {"dp": [{{8 + hour}}, 7, "{{colors[(colors.items() | map(attribute='0') |
         map('int') | sort | select('>=', forcast_temp[hour]) | first) | string]}}"]}
            {%- if hour+1 != hours %},{%endif%}
          {%- endfor %}
        {%- endmacro %} [
          {{draw_forecast_lines()}},
          {"dt": ["{{13 if value_template > 9 else 15}}", 1, "{{'+' if value_template > 0}}{{value_template}}°", "{{color}}"]}
        ]
    additional_options:
      icons:
        clear-night: a12181
        cloudy: a2283
        exceptional: a2364
        fog: "17056"
        hail: a2441
        lightning: a630
        lightning-rainy: a49299
        partlycloudy: a2286
        pouring: a49300
        rainy: a2284
        snowy: a2289
        snowy-rainy: a49301
        sunny: a2282
        windy: a15618
        windy-variant: a15618
        full_moon: "2314"
        waning_gibbous: "2315"
        last_quarter: "2316"
        waning_crescent: "2317"
        new_moon: "2318"
        waxing_crescent: "2320"
        first_quarter: "2320"
        waxing_gibbous: "36234"
        home: "96"
        sunrise: "485"
        sunset: "486"
        unavailable: "52176"
      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"
      color: |-
        {{colors[(colors.items() | map(attribute='0') |
         map('int') | sort | select('>=', value_template) | first) | string]}}
      value_template: "{{states(entity_id) | round }}"
      prefix_text: "{{ '+' if value_template > 0 }}"
      forcast_temp: |-
        {{(forecast[forecast.keys() | first]).forecast | 
          map(attribute="temperature") | 
          map('round') |
          list}}
    pre_actions:
      - data:
          type: hourly
        response_variable: forecast
        action: weather.get_forecasts
        target:
          entity_id:
            - weather.forecast_home
    app_name: meteo
    app_icon: "2355"

let me check.

u r trying to use variable before declare.

please swap lines:

value_template: "{{states(entity_id) | round }}"
color: |-
  {{colors[(colors.items() | map(attribute='0') |
   map('int') | sort | select('>=', value_template) | first) | string]}}

was working for couple of week and since couple of days

meme:
No, no, I didn’t touch anything!