alias: Awtrix Ocotprint
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.octoprint_job_percentage
      - sensor.octoprint_current_state
actions:
  - action: mqtt.publish
    metadata: {}
    data:
      qos: 0
      retain: false
      topic: awtrix_978bd4/custom/octoprint
      payload: |-
        { 
         "text": "{% if is_state('sensor.octoprint_current_state', 'Printing') %}{{ states('sensor.octoprint_job_percentage') | round }}% ETA: {{ as_timestamp(states('sensor.octoprint_estimated_finish_time')) |  timestamp_custom('%-I:%M %p') }}{% else %}Idle{% endif %}",
         "icon": "37809",
         {% if is_state('sensor.octoprint_current_state', 'Printing') %}
          "progress": {{ states('sensor.octoprint_job_percentage') | round }},
          "progressC": "#00ff00",
        {% else %}
         "lifetime": 600,
        {% endif %}
         "repeat": 2,
         "duration": 5
        }
mode: single