Flow Details
Set Weather from Home Assistant Entity
This Home Assistant automation, titled "Set Weather from Home Assistant Entity", is designed to publish current weather and humidity data for Kamloops to two Awtrix clocks using MQTT. The automation runs every 15 minutes and sends the data in a JSON format, allowing the clocks to display up-to-date information about temperature, humidity, and weather conditions.
Key Features:
-
Trigger:
- The automation is set to trigger whenever the weather entity changes, ensuring that both Awtrix clocks are updated regularly with the latest weather data.
-
MQTT Publishing:
- The automation uses the
mqtt.publish
service to send MQTT messages to the topicsawtrix_clock_1/custom/weather
,awtrix_clock_2/custom/weather
,awtrix_clock_1/custom/humidity
, andawtrix_clock_2/custom/humidity
. - The payload for each message is dynamically generated based on the current weather conditions and humidity.
- The automation uses the
-
Dynamic Weather Icon Selection:
- The automation selects an appropriate icon based on the current weather conditions in Kamloops. For instance:
-
Clear sky (day) uses icon
2282
. -
Clear sky (night) uses icon
12181
. -
Partly cloudy uses icon
53384
. -
Cloudy uses icon
53802
. -
Rain uses icon
2284
. -
Lightning uses icon
49299
. -
Snow uses icon
2289
. -
Fog uses icon
17055
.
-
Clear sky (day) uses icon
- This ensures that the clocks display relevant visuals based on real-time weather data.
- The automation selects an appropriate icon based on the current weather conditions in Kamloops. For instance:
-
Temperature and Humidity:
- The temperature data is displayed alongside the weather icon in Celsius (e.g., "22°C").
- Humidity is sent as a percentage with a dedicated icon
2423
, displaying values like "45%" on the clock.
-
Multiple Clocks:
- The automation updates two separate Awtrix clocks (
awtrix_clock_1
andawtrix_clock_2
), ensuring that both devices are synchronized and show the same information.
- The automation updates two separate Awtrix clocks (
-
Customization:
- The MQTT message has fields like
repeat
,icon
, andtext
, allowing customization of the display on the Awtrix devices. Therepeat
value is set to1
, ensuring that the display information is updated regularly without excessive repetition.
- The MQTT message has fields like
Technical Overview:
- The automation relies on the
weather.kamloops
entity, which retrieves weather information for Kamloops through an integration like OpenWeatherMap. - The
mqtt.publish
service sends structured JSON payloads to the specified topics, ensuring that both temperature and humidity data are transmitted to the clocks. - With each run of the automation, both Awtrix clocks receive fresh data and update their displays accordingly, providing real-time, visually rich feedback about the current weather and environmental conditions.
This automation ensures that your Awtrix clocks stay up-to-date with weather and humidity data, providing a seamless integration with Home Assistant through MQTT.
- id: "9e9a62c9-ccaa-4b89-b6d9-c68647dfaed7"
alias: Update Awtrix Weather on Weather Change
trigger:
- platform: state
entity_id: weather.kamloops
action:
- service: mqtt.publish
data:
topic: "awtrix_clock_1/custom/weather"
payload: >
{% set temperature = state_attr('weather.kamloops', 'temperature') %}
{% set condition = states('weather.kamloops') %}
{% set color = [0, 255, 0] %}
{% if temperature > 30 %}
{% set color = [255, 0, 0] %}
{% elif temperature < 0 %}
{% set color = [0, 0, 255] %}
{% endif %}
{% set icon = 2282 %}
{% if condition == 'clear-night' %}
{% set icon = 12181 %}
{% elif condition == 'partlycloudy' %}
{% set icon = 53384 %}
{% elif condition == 'cloudy' %}
{% set icon = 53802 %}
{% elif condition == 'rainy' %}
{% set icon = 2284 %}
{% elif condition == 'lightning' %}
{% set icon = 49299 %}
{% elif condition == 'snowy' %}
{% set icon = 2289 %}
{% elif condition == 'fog' %}
{% set icon = 17055 %}
{% endif %}
{
"repeat": 1,
"icon": {{ icon }},
"text": "{{ temperature }}°C",
"color": {{ color }}
}
qos: 0
retain: false
- service: mqtt.publish
data:
topic: "awtrix_clock_2/custom/weather"
payload: >
{% set temperature = state_attr('weather.kamloops', 'temperature') %}
{% set condition = states('weather.kamloops') %}
{% set color = [0, 255, 0] %}
{% if temperature > 30 %}
{% set color = [255, 0, 0] %}
{% elif temperature < 0 %}
{% set color = [0, 0, 255] %}
{% endif %}
{% set icon = 2282 %}
{% if condition == 'clear-night' %}
{% set icon = 12181 %}
{% elif condition == 'partlycloudy' %}
{% set icon = 53384 %}
{% elif condition == 'cloudy' %}
{% set icon = 53802 %}
{% elif condition == 'rainy' %}
{% set icon = 2284 %}
{% elif condition == 'lightning' %}
{% set icon = 49299 %}
{% elif condition == 'snowy' %}
{% set icon = 2289 %}
{% elif condition == 'fog' %}
{% set icon = 17055 %}
{% endif %}
{
"repeat": 1,
"icon": {{ icon }},
"text": "{{ temperature }}°C",
"color": {{ color }}
}
qos: 0
retain: false
- service: mqtt.publish
data:
topic: "awtrix_clock_1/custom/humidity"
payload: >
{% set humidity = state_attr('weather.kamloops', 'humidity') %}
{
"repeat": 1,
"icon": 2423,
"text": "{{ humidity }}%"
}
qos: 0
retain: false
- service: mqtt.publish
data:
topic: "awtrix_clock_2/custom/humidity"
payload: >
{% set humidity = state_attr('weather.kamloops', 'humidity') %}
{
"repeat": 1,
"icon": 2423,
"text": "{{ humidity }}%"
}
qos: 0
retain: false
-- Flow first published on October 12, 2024, last updated on October 12, 2024 at 23:52.