Переделал вариант получения погоды с weatherapi.com на прогноз, а не текущую погоду.
Т.к. мне хотелось с утра получать в телегу текущую погоду, рассвет/закат и прогноз на день.

Custom-устройство:
{
"exposes": [
"lastUpdated",
"locationName",
"locationRegion",
"condition",
"temperature",
"humidity",
"feelsLike",
"dewPoint",
"pressure",
"windSpeed",
"windDirection",
"precipitation",
"uvIndex",
"forecastDate",
"conditionForecast",
"sunrise",
"sunset",
"moonrise",
"moonset",
"moonPhase",
"minTempc",
"maxTempc",
"maxWindKph"
],
"real": true,
"options": {
"maxWindKph": {
"round": 1
},
"pressure": {
"unit": "mmHg"
},
"windSpeed": {
"round": 1
}
},
"bindings": {
"condition": {
"inPattern": "{{ json.current.condition.text }}",
"inTopic": "weatherapiforecast"
},
"conditionForecast": {
"inPattern": "{{ json.forecast.forecastday[0].day.condition.text }}",
"inTopic": "weatherapiforecast"
},
"dewPoint": {
"inPattern": "{{ json.current.dewpoint_c }}",
"inTopic": "weatherapiforecast"
},
"feelsLike": {
"inPattern": "{{ json.current.feelslike_c }}",
"inTopic": "weatherapiforecast"
},
"forecastDate": {
"inPattern": "{{ json.forecast.forecastday[0].date }}",
"inTopic": "weatherapiforecast"
},
"humidity": {
"inPattern": "{{ json.current.humidity }}",
"inTopic": "weatherapiforecast"
},
"lastUpdated": {
"inPattern": "{{ json.current.last_updated }}",
"inTopic": "weatherapiforecast"
},
"locationName": {
"inPattern": "{{ json.location.name}}",
"inTopic": "weatherapiforecast"
},
"locationRegion": {
"inPattern": "{{ json.location.region}}",
"inTopic": "weatherapiforecast"
},
"maxTempc": {
"inPattern": "{{ json.forecast.forecastday[0].day.maxtemp_c }}",
"inTopic": "weatherapiforecast"
},
"maxWindKph": {
"inPattern": "{{ json.forecast.forecastday[0].day.maxwind_kph / 3.6 }}",
"inTopic": "weatherapiforecast"
},
"minTempc": {
"inPattern": "{{ json.forecast.forecastday[0].day.mintemp_c }}",
"inTopic": "weatherapiforecast"
},
"moonPhase": {
"inPattern": "{{ 'Новолуние' if json.forecast.forecastday[0].astro.moon_phase == 'New Moon' else 'Молодая Луна' if json.forecast.forecastday[0].astro.moon_phase == 'Waxing crescent' else 'Растущая Луна' if json.forecast.forecastday[0].astro.moon_phase == 'Waxing gibbous' else 'Полнолуние' if json.forecast.forecastday[0].astro.moon_phase == 'Full Moon' else 'Убывающая Луна' if json.forecast.forecastday[0].astro.moon_phase == 'Waning gibbous' else 'Последняя четверть' if json.forecast.forecastday[0].astro.moon_phase == 'Last quarter' else 'Старая Луна' if json.forecast.forecastday[0].astro.moon_phase == 'Waning Crescent' else 'Луну черти украли' }}",
"inTopic": "weatherapiforecast"
},
"moonrise": {
"inPattern": "{{ json.forecast.forecastday[0].astro.moonrise }}",
"inTopic": "weatherapiforecast"
},
"moonset": {
"inPattern": "{{ json.forecast.forecastday[0].astro.moonset }}",
"inTopic": "weatherapiforecast"
},
"precipitation": {
"inPattern": "{{ json.current.precip_mm }}",
"inTopic": "weatherapiforecast"
},
"pressure": {
"inPattern": "{{ json.current.pressure_mb / 1.33322 }}",
"inTopic": "weatherapiforecast"
},
"sunrise": {
"inPattern": "{{ json.forecast.forecastday[0].astro.sunrise }}",
"inTopic": "weatherapiforecast"
},
"sunset": {
"inPattern": "{{ json.forecast.forecastday[0].astro.sunset }}",
"inTopic": "weatherapiforecast"
},
"temperature": {
"inPattern": "{{ json.current.temp_c }}",
"inTopic": "weatherapiforecast"
},
"uvIndex": {
"inPattern": "{{ json.current.uv }}",
"inTopic": "weatherapiforecast"
},
"windDirection": {
"inPattern": "{{ 'Северный' if json.current.wind_dir == 'N' else 'Северо-Северо-Восток' if json.current.wind_dir == 'NNE' else 'Северо-Восток' if json.current.wind_dir == 'NE' else 'Востоко-Северо-Восток' if json.current.wind_dir == 'ENE' else 'Восточный' if json.current.wind_dir == 'E' else 'Востоко-Юго-Восток' if json.current.wind_dir == 'ESE' else 'Юго-Восток' if json.current.wind_dir == 'SE' else 'Юго-Юго-Восток' if json.current.wind_dir == 'SSE' else 'Южный' if json.current.wind_dir == 'S' else 'Юго-Юго-Запад' if json.current.wind_dir == 'SSW' else 'Юго-Запад' if json.current.wind_dir == 'SW' else 'Западо-Юго-Запад' if json.current.wind_dir == 'WSW' else 'Западный' if json.current.wind_dir == 'W' else 'Западо-Северо-Запад' if json.current.wind_dir == 'WNW' else 'Северо-Запад' if json.current.wind_dir == 'NW' else 'Северо-Северо-Запад' if json.current.wind_dir == 'NNW' else 'Неизвестно' }}",
"inTopic": "weatherapiforecast"
},
"windSpeed": {
"inPattern": "{{ json.current.wind_kph / 3.6 }}",
"inTopic": "weatherapiforecast"
}
}
}
Автоматизация:
{
"actions": [
{
"command": "DATA=$(curl -s \"https://api.weatherapi.com/v1/forecast.json?key=your_api_token&q=your_location&lang=ru&alerts=yes\") && echo $DATA | jq > /dev/null 2>&1 && mosquitto_pub -t \"weatherapiforecast\" -m \"$DATA\" -r -u \"homed_mqtt_user\" -P \"homed_mqtt_password\" &",
"type": "shell"
},
{
"delay": "2",
"type": "delay"
},
{
"message": "Weather from HOMEd {{ timestamp | dd.MM.yy hh:mm }}\n---- Now -----\nПоследнее обновление: {{ property | custom/weatherapiforecast | lastUpdated }}\nМестоположение: {{ property | custom/weatherapiforecast | locationName }} | {{ property | custom/weatherapiforecast | locationRegion }}\nСостояние: {{ property | custom/weatherapiforecast | condition }} \nТемпература: {{ property | custom/weatherapiforecast | temperature }} °C\nОщущается как: {{ property | custom/weatherapiforecast | feelsLike }} °C\nТочка росы: {{ property | custom/weatherapiforecast | dewPoint }} °C\nВлажность: {{ property | custom/weatherapiforecast | humidity }} %\nДавление: [[ round({{ property | custom/weatherapiforecast | pressure }} * 10) / 10 ]] мм рт. ст.\nСкорость ветра: [[ round({{ property | custom/weatherapiforecast | windSpeed }} * 10) / 10 ]] м/с\nНаправление ветра: {{ property | custom/weatherapiforecast | windDirection }} \nОсадки: {{ property | custom/weatherapiforecast | precipitation }} мм\nУФ-индекс: {{ property | custom/weatherapiforecast | uvIndex }} \n--- Astro ----\n🌞 ↑{{ property | custom/weatherapiforecast | sunrise }} ↓{{ property | custom/weatherapiforecast | sunset }}\n🌜 ↑{{ property | custom/weatherapiforecast | moonrise }} ↓{{ property | custom/weatherapiforecast | moonset }} Фаза: {{ property | custom/weatherapiforecast | moonPhase }} \n-- Forecast --\nСостояние на {{ property | custom/weatherapiforecast | forecastDate }}: {{ property | custom/weatherapiforecast | conditionForecast }}\nТемпература: min {{ property | custom/weatherapiforecast | minTempc }} °C, max {{ property | custom/weatherapiforecast | maxTempc }} °C\nМакс. ветер: [[ round({{ property | custom/weatherapiforecast | maxWindKph }} * 10) / 10 ]] м/с",
"triggerName": "reqest",
"type": "telegram"
},
{
"message": "Weather from HOMEd {{ timestamp | dd.MM.yy hh:mm }}\n---- Now -----\nПоследнее обновление: {{ property | custom/weatherapiforecast | lastUpdated }}\nМестоположение: {{ property | custom/weatherapiforecast | locationName }} | {{ property | custom/weatherapiforecast | locationRegion }}\nСостояние: {{ property | custom/weatherapiforecast | condition }} \nТемпература: {{ property | custom/weatherapiforecast | temperature }} °C\nОщущается как: {{ property | custom/weatherapiforecast | feelsLike }} °C\nТочка росы: {{ property | custom/weatherapiforecast | dewPoint }} °C\nВлажность: {{ property | custom/weatherapiforecast | humidity }} %\nДавление: [[ round({{ property | custom/weatherapiforecast | pressure }} * 10) / 10 ]] мм рт. ст.\nСкорость ветра: [[ round({{ property | custom/weatherapiforecast | windSpeed }} * 10) / 10 ]] м/с\nНаправление ветра: {{ property | custom/weatherapiforecast | windDirection }} \nОсадки: {{ property | custom/weatherapiforecast | precipitation }} мм\nУФ-индекс: {{ property | custom/weatherapiforecast | uvIndex }} \n--- Astro ----\n🌞 ↑{{ property | custom/weatherapiforecast | sunrise }} ↓{{ property | custom/weatherapiforecast | sunset }}\n🌜 ↑{{ property | custom/weatherapiforecast | moonrise }} ↓{{ property | custom/weatherapiforecast | moonset }} Фаза: {{ property | custom/weatherapiforecast | moonPhase }} \n-- Forecast --\nСостояние на {{ property | custom/weatherapiforecast | forecastDate }}: {{ property | custom/weatherapiforecast | conditionForecast }}\nТемпература: min {{ property | custom/weatherapiforecast | minTempc }} °C, max {{ property | custom/weatherapiforecast | maxTempc }} °C\nМакс. ветер: [[ round({{ property | custom/weatherapiforecast | maxWindKph }} * 10) / 10 ]] м/с",
"triggerName": "time632",
"type": "telegram"
}
],
"restart": false,
"triggers": [
{
"name": "time632",
"time": "6:32",
"type": "time"
},
{
"interval": 30,
"name": "30min",
"type": "interval"
},
{
"message": "weather",
"name": "reqest",
"type": "telegram"
}
],
"conditions": []
}
Update 24-02-2025:
Обновил приложенные файлы - добавлены все переводы и округления из коментариев.
Включены alert-ы, под них заведено отдельное custom-устройство - weatherapiforecast_alerts. Посмотрим - будут ли туда прилетать алерты о погоде, пока за выгодные в Петербурге ничего не прилетело, но и не было СМС от МЧС.
У автоматизации теперь три триггера - в 6 утра присылать погоду в Телеграм, и присылать по запросу weather
и каждые 30 минут обновлять данные сенсоров.