alias: Awtrix Uptime Kuma
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.uptimekuma_192_168_178_117
condition: []
action:
  - variables:
      awtrix_text: >-
        {{ state_attr('sensor.uptimekuma_192_168_178_117', 'monitors_up') ~ '/'
        ~ state_attr('sensor.uptimekuma_192_168_178_117', 'monitors') }}
      sensors:
        - sensor: sensor.uptimekuma_awtrix_light_webinterface
          dp: 9
        - sensor: sensor.uptimekuma_bitwarden
          dp: 11
        - sensor: sensor.uptimekuma_esphome
          dp: 13
        - sensor: sensor.uptimekuma_mosquitto
          dp: 15
        - sensor: sensor.uptimekuma_home_assistant
          dp: 17
  - service: mqtt.publish
    data:
      qos: 0
      retain: false
      topic: awtrix_a8ba90/custom/uptimekuma
      payload: |-
        {
          "topText": true,
          "textOffset": -1,
          "icon": "uptimekuma",
          "text": "{{ awtrix_text }}",
          "color": "{% if is_state('sensor.uptimekuma_192_168_178_117', 'up') %}#6ed228{% else %}#ff0000{% endif %}",
          "draw":[
            {%- for sensor in sensors -%}
            {"dp":[{{ sensor.dp }},7,"{% if is_state(sensor.sensor, 'up') %}#6ed228{% else %}#ff0000{% endif %}"]}{% if not loop.last %},{% endif %}
            {%- endfor -%}
          ]
        }
mode: restart