alias: "- AWTRIX - SELF - STATS - APP -"
description: "- WIFI Strenght - Battery - Free Ram - Uptime -"
trigger:
  - platform: time_pattern
    minutes: /1
condition: []
action:
  - service: mqtt.publish
    data:
      qos: 0
      retain: false
      topic: awtrix_XXXXXX/custom/self-stats
      payload_template: >-
        {

        "text":"·      WIFI STRENGTH {{
        states('sensor.awtrix_XXXXXX_wifi_strength') }} dB      ·      BATTERY  
        {{ states('sensor.awtrix_XXXXXX_battery') }} %      ·       FREE RAM  
        {{ states('sensor.awtrix_XXXXXX_free_ram') }} Byte      ·      
        UPTIME    {% set s =  states('sensor.awtrix_XXXXXX_uptime') | int(0)
        %}{% set seconds = s % 60 %}{% set minutes = ((s % 3600) / 60) | int
        %}{% set hours = ((s % 86400) / 3600) | int %}{% set days = (s / 86400)
        | int %}

        {%- if days > 0 -%}
          {%- if days == 1 -%}
          · 1 DAY
          {%- else -%}
          · {{ days }} DAYS
          {%- endif -%}
          {{ ' ' }}
        {%- endif -%}

        {%- if hours > 0 -%}
          {%- if hours == 1 -%}
          · 1 HOUR
          {%- else -%}
          · {{ hours }} HOURS
          {%- endif -%}
          {{ ' ' }}
        {%- endif -%}

        {%- if minutes > 0 -%}
          {%- if minutes == 1 -%}
          · 1 MINUTE
          {%- else -%}
          · {{ minutes }} MINUTES
          {%- endif -%}
        {%- endif -%}
          {{ ' ' }}
        {%- if seconds > 0 -%}
          {%- if seconds == 1 -%}
          · 1 SECOND
          {%- else -%}
          · {{ seconds }} SECONDS
          {%- endif -%}
        {%- endif -%}
          {{ '  ·' }}      VERSION {{ states('sensor.awtrix_XXXXXX_version') }}                                         ",
        "textOffset": 34,

        "repeat": 1,

        "color": [160,160,0],
          "effect":"TwinklingStars",
          "effectSettings":{
            "speed": -4,
            "palette":["220000",
                            "330000",
                            "550000",
                            "770000",
                            "990000",
                            "BB0000",
                            "DD0000",
                            "FF0000",
                            "FF0000",
                            "DD0000",
                            "BB0000",
                            "990000",
                            "770000",
                            "550000",
                            "330000",
                            "220000"],
            "blend":true
          }
        }
mode: single