Skip to content

Instantly share code, notes, and snippets.

@TheGroundZero
Last active January 26, 2024 10:53
Show Gist options
  • Save TheGroundZero/aee170c693b04b79e9ebf95ffcd9004f to your computer and use it in GitHub Desktop.
Save TheGroundZero/aee170c693b04b79e9ebf95ffcd9004f to your computer and use it in GitHub Desktop.
AWTRIX Year Progress Flow using Home Assistant Automation
---
# https://flows.blueforcer.de/flow/jyNg0oGXOX6D
#
# Update the MQTT topic at the bottom of this automation.
# Don't forget to upload year.jpg to your AWTRIX clock in the ICONS folder
#
automation:
- id: awtrix_year_progress
alias: Year Progress
description: Publishes the current year progress in % to the Awtrix clock
trigger:
- platform: time_pattern
hours: "*"
minutes: 0
condition: []
action:
- service: mqtt.publish
data:
payload: >-
{# Get current timestamp #}
{%- set now = now() -%}
{# Start of current year #}
{%- set startOfYear = now.replace(year=now.year, month=1, day=1, hour=0, minute=0, second=0, microsecond=0) -%}
{# Determine end of current year #}
{%- set endOfYear = startOfYear.replace(month=12, day=31, hour=23, minute=59, second=59, microsecond=999999) -%}
{# Calculate progress #}
{%- set total = as_timestamp(endOfYear) - as_timestamp(startOfYear) -%}
{%- set current = as_timestamp(now) - as_timestamp(startOfYear) -%}
{%- set progress = ( current / total * 100 ) | round(0, "floor", 0) -%}
{# Output #}
{ "text": "{{ progress }} %", "icon": "year"}
topic: awtrix_dd2824/custom/yearprogress
qos: 0
# Setting to True so this keeps working if the clock as turned off.
# Will ensure Awtrix shows progress if turned on before the turn of the hour.
retain: true
mode: single
/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKA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DNicoIJChYXGBka
JSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SV
lpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX2
9/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAEC
dwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4
OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWm
p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQAC
EQMRAD8A/n80Txd+wX+3F+yn8M/hRc+AtO+FX7Xfgn/hM/h4PiV4nuPCGl+NvH3xP+N/xIlm/Zuv
pPiFoHi60+IXx7+HHgLSPB2gfBn4l/8ACZ/AL4lfEHwRpnxJ8M69o/iDw5oGh+P/AInXv85eAHg5
4rZb9KvMsh4j8Qatbwm8WvqeD4Hy3AT4lrcO8McS5H4cZzl2Fy7M8gfCHE+VeH0eOPFnOuH82qV+
GM+yzKMxyvAcQLFUMPjauS5fl35T9Pz6SXibmXjLw74x8EcO8aVOCqv9rcT+J+T51mNLxHnQ8MPD
nhXg3I8fkGO44xPBPD+JxXGOV8KUM04i4A4i4t404MxefR4MxuTcY5l4sccZ3hqmbf/Z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment