Home Assistant Calendar from sensor
Home Assistant

Home Assistant Calendar from sensor

This automation sends the current date and day of the month to Awtrix clocks using themed colors based on the current month. It updates whenever `sensor.date` changes.
A flow by Colton Dick

Flow Details

The automation "Awtrix: Send Current Date to Awtrix Clocks with Color Themes" triggers whenever the sensor.date entity changes. It formats the current day of the month and the full date (e.g., "OCT 13") and sends this information to the Awtrix clocks (awtrix_clock_1) using MQTT. The date is displayed in a color scheme that corresponds to the current month’s theme (e.g., blue for January, pink for February, red for December). The day of the month is drawn in black, while the formatted date is colored according to the month’s theme. This ensures a visually appealing display based on seasonal events like Christmas, Halloween, or summer.

- id: "76b5be94-b91e-4765-94e9-8f43e859b5aa" alias: "Awtrix: Send Current Date to Awtrix Clocks with Color Themes" trigger: # Trigger whenever sensor.date changes - platform: state entity_id: sensor.date action: # Set the current day and date - service: mqtt.publish data: topic: "awtrix_clock_1/custom/calendar" payload: > {% set current_day = states('sensor.date')[8:10] %} {% set current_month = now().month %} {% set current_date = now().strftime('%b %d').upper() %} {% set color = { 1: '#42A5F5', 2: '#E91E63', 3: '#4CAF50', 4: '#00BCD4', 5: '#FFEB3B', 6: '#FF9800', 7: '#F44336', 8: '#00E5FF', 9: '#FFC107', 10: '#FF5722', 11: '#795548', 12: '#FF1744' }[current_month] %} { "draw": [ {"df": [0,2,9,7, "#FFFFFF"]}, {"df": [0,0,9,2, "#FF0000"]}, {"dt": [1, 2, "{{current_day}}", "#000000"]}, {"dt": [10, 1, "{{current_date}}", "{{color}}"]} ], "pos": 1 } qos: 0 retain: false
-- Flow first published on October 13, 2024.