Awtrix Light Timer Modification

I am not completely sure where to post this, i hope this is ok. I have an Ulanzi Awtrix flashed with Awtrix Light connected to my HA via mqtt and on occasion i use this custom flow to display timers: AWTRIX Flows
Now, i tried modifing it so it only displays hours and minutes (HH:mm) instead of hours, minutes and seconds (HH:mm:ss). But i was unsuccessfull so far. Maybe someone can help me out?

If you don’t like clicking links, here’s the code:

alias: ⏳AWTRIX Timer
description: ""
trigger:
  - platform: state
    entity_id:
      - timer.awtrix_timer
    to: active
    id: start
  - platform: state
    entity_id:
      - timer.awtrix_timer
    to: idle
    id: stop
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - start
        sequence:
          - parallel:
              - repeat:
                  sequence:
                    - service: mqtt.publish
                      data:
                        qos: 0
                        retain: false
                        topic: awtrix_a8ba90/custom/timer
                        payload: >
                          {% set duration =
                          as_timedelta(state_attr('timer.awtrix_timer',
                          'duration')).total_seconds() %} {% set remaining =
                          as_datetime(state_attr(trigger.entity_id,
                          'finishes_at')) - now().replace(microsecond=0) %} {%
                          set passed = duration - remaining.total_seconds() %}
                          {% set progress = ((passed/duration) * 100) | round(0)
                          | int %} {{
                            dict(
                                  icon = '42893',
                                  text = remaining | string,
                                  progress = progress,
                                  progressC = '#ff0000',
                                  progressBC = '#000000'
                                )
                          }}
                    - delay:
                        hours: 0
                        minutes: 0
                        seconds: 1
                        milliseconds: 0
                  while:
                    - condition: state
                      entity_id: timer.awtrix_timer
                      state: active
              - service: mqtt.publish
                data:
                  qos: 0
                  retain: false
                  topic: awtrix_a8ba90/settings
                  payload: "{\"ATRANS\": false}"
              - repeat:
                  count: 1
                  sequence:
                    - service: mqtt.publish
                      data:
                        qos: 0
                        retain: false
                        topic: awtrix_a8ba90/switch
                        payload: "{\"name\":\"timer\"}"
      - conditions:
          - condition: trigger
            id:
              - stop
        sequence:
          - service: mqtt.publish
            data:
              qos: 0
              retain: false
              topic: awtrix_a8ba90/sound
              payload: "{\"sound\":\"short\"}"
          - delay:
              hours: 0
              minutes: 0
              seconds: 1
              milliseconds: 0
          - parallel:
              - service: mqtt.publish
                data:
                  qos: 0
                  retain: false
                  topic: awtrix_a8ba90/custom/timer
              - service: mqtt.publish
                data:
                  qos: 0
                  retain: false
                  topic: awtrix_a8ba90/settings
                  payload: "{\"ATRANS\": true}"
mode: restart
2 Likes

Well, i managed it, finally:

payload: >
  {% set duration = as_timedelta(state_attr('timer.awtrix_timer', 'duration')).total_seconds() %}
  {% set remaining = as_datetime(state_attr(trigger.entity_id, 'finishes_at')) - now().replace(microsecond=0) %}
  {% set remaining_seconds = remaining.total_seconds() %}
  {% set remaining_hours = (remaining_seconds // 3600) | int %}
  {% set remaining_minutes = ((remaining_seconds % 3600) // 60) | int %}
  {% set remaining_time = '%d:%02d' | format(remaining_hours, remaining_minutes) %}
  {% set passed = duration - remaining.total_seconds() %}
  {% set progress = ((passed/duration) * 100) | round(0) | int %}
  {{ dict(
      icon = '42893',
      text = remaining_time,
      progress = progress,
      progressC = '#ff0000',
      progressBC = '#000000'
  ) }}
1 Like

I made another modification so that when the timer is less than 1 hour, it only displays minutes and seconds.

alias: ⏳AWTRIX Timer
description: ""
trigger:
  - platform: state
    entity_id:
      - timer.awtrix_timer
    to: active
    id: start
  - platform: state
    entity_id:
      - timer.awtrix_timer
    to: idle
    id: stop
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - start
        sequence:
          - parallel:
              - repeat:
                  sequence:
                    - service: mqtt.publish
                      data:
                        qos: 0
                        retain: false
                        topic: awtrix_a8ba90/custom/timer
                        payload: >
                          {% set duration =
                          as_timedelta(state_attr('timer.awtrix_timer',
                          'duration')).total_seconds() %} {% set remaining =
                          as_datetime(state_attr(trigger.entity_id,
                          'finishes_at')) - now().replace(microsecond=0) %} {%
                          set remaining_seconds = remaining.total_seconds() %}
                          {% set remaining_hours = (remaining_seconds // 3600) |
                          int %} {% set remaining_minutes = ((remaining_seconds
                          % 3600) // 60) | int %} {% if remaining_hours >= 1 %}
                          {% set remaining_time = '%d:%02d' |
                          format(remaining_hours, remaining_minutes) %} {% else
                          %} {% set remaining_time = '%02d:%02d' |
                          format(remaining_minutes, remaining_seconds % 60) %}
                          {% endif %} {% set passed = duration -
                          remaining.total_seconds() %} {% set progress =
                          ((passed/duration) * 100) | round(0) | int %} {{ dict(
                              icon = '42893',
                              text = remaining_time,
                              progress = progress,
                              progressC = '#ff0000',
                              progressBC = '#000000'
                          ) }}
                    - delay:
                        hours: 0
                        minutes: 0
                        seconds: 1
                        milliseconds: 0
                  while:
                    - condition: state
                      entity_id: timer.awtrix_timer
                      state: active
              - service: mqtt.publish
                data:
                  qos: 0
                  retain: false
                  topic: awtrix_a8ba90/settings
                  payload: "{\"ATRANS\": false}"
              - repeat:
                  count: 1
                  sequence:
                    - service: mqtt.publish
                      data:
                        qos: 0
                        retain: false
                        topic: awtrix_a8ba90/switch
                        payload: "{\"name\":\"timer\"}"
      - conditions:
          - condition: trigger
            id:
              - stop
        sequence:
          - service: mqtt.publish
            data:
              qos: 0
              retain: false
              topic: awtrix_a8ba90/sound
              payload: "{\"sound\":\"short\"}"
            enabled: false
          - delay:
              hours: 0
              minutes: 0
              seconds: 1
              milliseconds: 0
            enabled: false
          - parallel:
              - service: mqtt.publish
                data:
                  qos: 0
                  retain: false
                  topic: awtrix_a8ba90/custom/timer
              - service: mqtt.publish
                data:
                  qos: 0
                  retain: false
                  topic: awtrix_a8ba90/settings
                  payload: "{\"ATRANS\": true}"
                enabled: false
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.minecraft
mode: restart
1 Like

Thanks for that. Already using it a few days. First saw it on discord.
Now i have a timer for my my mealbreak and another when my Pizza is ready :slight_smile:

awesome! I was searching for a way to display my home assistant timers both on my Google display and on my awtrix (as the google home integration where home asisstant can see the timers from my google display doesn’t work anymore)

The ony thing is that the dosplay has a slight flash every time it updates, and sometimes, it seems to reboot, show MQTT… and then the ip address.