Year progress
Shows the current progress of the year in %. You only have to update the MQTT topic.
About this flow
| System | Home Assistant |
|---|---|
| AWTRIX version | AWTRIX 3 |
| Topic | Miscellaneous |
| Built by | DezeStijn |
| File | jyNg0oGXOX6D.yaml · 1.2 KB |
| Icons | 1 |
| Published | 2 Jun 2023 · updated 6 Jun 2023 |
| Downloads | 45 |
Is this your flow?
If you created this flow, open your saved edit link to add it to your account. You can then manage it whenever you sign in. Adding it to your account replaces the edit link.
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
jyNg0oGXOX6D.yaml
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
This flow uses the following icons. Add them to your AWTRIX along with the flow.
8×8 px
More flows for Home Assistant or Miscellaneous
Something wrong with this flow? Report it.