Homeassistant Weather in Statusbar

I am using Sway as windowmanager with waybar as statusbar. In this statusbar I use wttr.in to show the current weather by calling curl "https://wttr.in/Stuttgart+Germany?format=2". Since a few months this is a bit unrealiable, so I wanted to use Homeassistant as datasource. Both wttr.in and the most used weather plugin in Homeassistant use met.no as datasource.

The weather in my statusbar looks like this with wttr.in:


I want to rebuild the same look with Homeassistant. My version of the Homeassistant template in a curl call looks like this:

curl -s -H "Authorization: Bearer YOUR_LONG_LIVED_TOKEN" \
-H "Content-Type: application/json" \
-d '{"template": "{% set w=states.weather.forecast_home.attributes.forecast[0] %}{{ {\"clear-night\": \"✨\", \"cloudy\": \"☁️\", \"exceptional\": \"✨\", \"fog\": \"🌫\", \"hail\": \"🌨\", \"lightning\": \"🌩\", \"lightning-rainy\": \"⛈\", \"partlycloudy\": \"⛅️\", \"pouring\": \"🌨\", \"rainy\": \"🌧\", \"snowy\": \"❄️\", \"snowy-rainy\": \"🌨\", \"sunny\": \"☀️\", \"windy\": \"💨\", \"windy-variant\": \"💨\"}[w.condition] }} 🌡️{{ \"%+d\"|format(w.temperature) }}°C 🌬️{{ [\"↓\", \"↙\", \"←\", \"↖\", \"↑\", \"↗\", \"→\", \"↘\"][int(((w.wind_bearing+22.5)%360)/45.0)] }}{{ w.wind_speed|round }}km/h"}' \

At the start we set a variable with the current weather and call it w. This reduces the characters needed for the following variable access. The condition emojis are based on constants in the Homeassistant code. The temperature is inserted as number with a manditory sign in front by using the format filter from Jinja2. The wind bearings are a list with 8 values accessed by the degree values from the weather plugin and transformed to values from 0 to 8. The formula is from the wttr.in code.

The result looks like this, which is pretty similar to the wttr.in-version.


I am using the weather data from Homeassistant in different places now (i.e. my kindle status display) and they were pretty reliable in the last weeks.