Year progress
Home Assistant

Year progress

Shows the current progress of the year in %. You only have to update the MQTT topic.
A flow by DezeStijn

Go to automations Download flow Download assets

Flow Details

Gets the current year progress between yyyy-01-01T00:00:00.000000 and yyyy-12-31T23:59:59.999999. Reports in % (rounded down to 0 decimals).

Based on blueforcer's Node-RED flow.

https://gist.github.com/TheGroundZero/aee170c693b04b79e9ebf95ffcd9004f

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": "y2023"} topic: awtrix_dd2824/custom/yearprogress qos: 0 retain: false mode: single
/flows/jyNg0oGXOX6D/y2023.jpg
-- Flow first published on June 2, 2023, last updated on June 6, 2023 at 09:16.