Dynamic position weather forecast and templates

Hi

I have an RV in wich I am running HA and we are moving almost every 3-4 days and I am trying to build a “dynamic position” weather card that would reflect weather and forecast for the real position of the RV without having to modify the integrations with lat/long everytime we move.

I have a GPS providing real time lat/long to my system so all I miss is a way to get the weather data.

I have read so many thread were people are also looking for a solution, but have not yet found a solution for this.

I am guessing this will have to go throught a rest API call that would populate a Weather template but I can’t find any detailed documentation that would show the basics of how to achieve all this process.

Hopefully someone have found a solution and would be willing to share how they achieved this and preferably with a step by step procedure (I am quite new to HA ans I am not a programmer)

thanks for any help on this

This would be a 2 stage project I guess.

1st stage would be to get your home assistant instance to update its HOME location based on your location. This but should be fairly simple by creating an automation to update your home location based on any gps sensor you have in HA.

Something like this maybe:

alias: Set Location
description: ''
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - service: homeassistant.set_location
    data_template:
      latitude: |
        {{ states("sensor.gps_latitude") }}
      longitude: |
        {{ states("sensor.gps_longitude") }}
mode: single

Then 2nd stage would be to utilise a weather integration that uses your home location.

I don’t currently use any wether integrations so can’t really comment on that aspect.

We are planning on building our next camper van soon that I will be splattering with tech using HA as the heart of the system so following with interest.

There are a few API that are free or not too expensive allowing to use lat/lon, e.g. openweather visualcrossing… you should first try to find out which is acceptable for you.
Then, in the REST call you can use a template using the lat and lon of one of your device_trackers, could be your phone or anything else. If you provide your choice of the source, I can try to help you with the follow-up

EDIT, this would then not require to bring HA-server along on your trip. The benefit of @rossk solution is that it would take care of timezone related issues so if you cross them a lot then this may still be a valid choice

Coïncidentaaly via another post…this one seesm 100% free but no clue if it covers your needs wrt output

https://api.met.no/weatherapi/locationforecast/2.0?lat=59.93&lon=10.72&altitude=90

@rossk & @vingerha thanks a lot for the informations provided, I actullay already have an automation that sets my HOME location pretty much the way you suggested, the only difference that I will fix is that actually, HOME changes every time either lat or long changes, wich can be every minutes or so since the GPS devices often fix it’s position, you are right, I should make sure to lower the burden on the system and only update it every 15 minutes or so.

The other problem I have is that both weather integration I would like to use; Environnement Canada and OpenWeather are using hard coded lat/long and not HOME to get their weather forecast so I need to find THE way to create/modify the REST call those integrations are using so they get wether forecast for my “actual” HOME location.

My final goal is to get some local sensors (temperature, pressure, altitude, humidity) and forecast from integrations into the new weather-chart-card Weather-Chart-Card, I have been able to get the card to work with my local sensor and get the openweather forecast in it but at this time, forecats is bind to the lat/long that was entered at the time of adding the integration and it is not “Dynamic”

@vingerha, definitly your help would be greatly appreciate on this, I have been scratching my head on this for the last few days. I have learned a lot along the way but I still can’t figure this one out. I have find the API call structure for OpenWeather and I can call and get the JSON results but what and where do I mofify the REST call of the integrations to use a template with lat/long so it gets in the weather-chart-card ???

thanks for any help on this it is GREATLY appreciated

HI, as I donot have this ready at hand and I am not sure which source you want (and …Openweathermap does (!) have a api with lat/lon)…
it would work a bit like this… you can use a command_line or a rest. The command_line will probably be where you are going as you would need to decipher the json with jq…probbaly, again… as long as you donot identify a source or send a json, I can not provide something detailed
Below is a sample that provides the address of a device_tracker person.XYX, similarly this would work with a weather api e.g. met.no as I wrote above but met.no output needs to be parsed a bit.
So, I need source and to know if you need forecast or just current weather data

command_line: 
  - sensor:
        name: Location Dynamic ABC
        unique_id: location_dynamic_abc
        scan_interval: 3600
        command: >
            curl "https://geocode.maps.co/reverse?lat={{state_attr('person.XYZ','latitude')}}&lon={{state_attr('person.XYZ','longitude')}}&api_key=123456789"  
        value_template: {{ "OK" }}       
        json_attributes:
          - address

@vingerha fist, I am looking at both, weather AND forecast, below you will find both API calls and response, my problem is how do I integrate these response into a weather template that can be used by the weather chart card ? (quite easy and straightforward to template the weather values into sensors but how do I manage to get forecast in a way that weather card can get the data)

Is there anyway to “jailbeark” the OpenWeather integration so everytime it gets it’s data it gets it from a template lat/long instead of what was configured at installation time ?

with the following API call: “https://api.openweathermap.org/data/2.5/weather?lat=´{MY-LAT}&lon={MY-LONG}&APPID={MY-API-KEY}” i get the weather in the following Json response:

Blockquote
{
“coord”: {
“lon”: -74.1199,
“lat”: 45.77
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04d”
}
],
“base”: “stations”,
“main”: {
“temp”: 277.21,
“feels_like”: 274.88,
“temp_min”: 276.16,
“temp_max”: 278.54,
“pressure”: 1012,
“humidity”: 67
},
“visibility”: 10000,
“wind”: {
“speed”: 2.57,
“deg”: 10
},
“clouds”: {
“all”: 75
},
“dt”: 1712411897,
“sys”: {
“type”: 1,
“id”: 861,
“country”: “CA”,
“sunrise”: 1712399160,
“sunset”: 1712446264
},
“timezone”: -14400,
“id”: 6137745,
“name”: “Sainte-Anne-des-Lacs”,
“cod”: 200
}
Blockquote

and from the following API Call with the following API call: “https://api.openweathermap.org/data/2.5/weather/forecast?lat=´{MY-LAT}&lon={MY-LONG}&APPID={MY-API-KEY}” i get the forcast in the following Json response:

Blockquote
{
“cod”: “200”,
“message”: 0,
“cnt”: 40,
“list”: [
{
“dt”: 1712415600,
“main”: {
“temp”: 277.37,
“feels_like”: 273.46,
“temp_min”: 277.37,
“temp_max”: 277.47,
“pressure”: 1012,
“sea_level”: 1012,
“grnd_level”: 993,
“humidity”: 68,
“temp_kf”: -0.1
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 75
},
“wind”: {
“speed”: 5.11,
“deg”: 27,
“gust”: 8.39
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-06 15:00:00”
},
{
“dt”: 1712426400,
“main”: {
“temp”: 277.72,
“feels_like”: 274.42,
“temp_min”: 277.72,
“temp_max”: 278.43,
“pressure”: 1013,
“sea_level”: 1013,
“grnd_level”: 994,
“humidity”: 71,
“temp_kf”: -0.71
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10d”
}
],
“clouds”: {
“all”: 80
},
“wind”: {
“speed”: 4.11,
“deg”: 30,
“gust”: 7.71
},
“visibility”: 1406,
“pop”: 0.2,
“rain”: {
“3h”: 0.55
},
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-06 18:00:00”
},
{
“dt”: 1712437200,
“main”: {
“temp”: 278.86,
“feels_like”: 275.92,
“temp_min”: 278.86,
“temp_max”: 279.61,
“pressure”: 1013,
“sea_level”: 1013,
“grnd_level”: 994,
“humidity”: 70,
“temp_kf”: -0.75
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10d”
}
],
“clouds”: {
“all”: 91
},
“wind”: {
“speed”: 3.94,
“deg”: 25,
“gust”: 6.93
},
“visibility”: 10000,
“pop”: 0.46,
“rain”: {
“3h”: 0.23
},
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-06 21:00:00”
},
{
“dt”: 1712448000,
“main”: {
“temp”: 275.51,
“feels_like”: 272.21,
“temp_min”: 275.51,
“temp_max”: 275.51,
“pressure”: 1016,
“sea_level”: 1016,
“grnd_level”: 996,
“humidity”: 81,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10n”
}
],
“clouds”: {
“all”: 91
},
“wind”: {
“speed”: 3.35,
“deg”: 5,
“gust”: 9.47
},
“visibility”: 10000,
“pop”: 0.2,
“rain”: {
“3h”: 0.14
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-07 00:00:00”
},
{
“dt”: 1712458800,
“main”: {
“temp”: 274.92,
“feels_like”: 271.79,
“temp_min”: 274.92,
“temp_max”: 274.92,
“pressure”: 1018,
“sea_level”: 1018,
“grnd_level”: 997,
“humidity”: 88,
“temp_kf”: 0
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 58
},
“wind”: {
“speed”: 2.98,
“deg”: 28,
“gust”: 8.18
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-07 03:00:00”
},
{
“dt”: 1712469600,
“main”: {
“temp”: 273.34,
“feels_like”: 269.94,
“temp_min”: 273.34,
“temp_max”: 273.34,
“pressure”: 1019,
“sea_level”: 1019,
“grnd_level”: 998,
“humidity”: 89,
“temp_kf”: 0
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 68
},
“wind”: {
“speed”: 2.93,
“deg”: 20,
“gust”: 7.66
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-07 06:00:00”
},
{
“dt”: 1712480400,
“main”: {
“temp”: 271.07,
“feels_like”: 267.67,
“temp_min”: 271.07,
“temp_max”: 271.07,
“pressure”: 1021,
“sea_level”: 1021,
“grnd_level”: 1000,
“humidity”: 89,
“temp_kf”: 0
},
“weather”: [
{
“id”: 801,
“main”: “Clouds”,
“description”: “few clouds”,
“icon”: “02n”
}
],
“clouds”: {
“all”: 11
},
“wind”: {
“speed”: 2.49,
“deg”: 355,
“gust”: 8.12
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-07 09:00:00”
},
{
“dt”: 1712491200,
“main”: {
“temp”: 274.45,
“feels_like”: 271.24,
“temp_min”: 274.45,
“temp_max”: 274.45,
“pressure”: 1022,
“sea_level”: 1022,
“grnd_level”: 1002,
“humidity”: 79,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“clouds”: {
“all”: 9
},
“wind”: {
“speed”: 2.97,
“deg”: 26,
“gust”: 8.32
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-07 12:00:00”
},
{
“dt”: 1712502000,
“main”: {
“temp”: 279.14,
“feels_like”: 276.63,
“temp_min”: 279.14,
“temp_max”: 279.14,
“pressure”: 1022,
“sea_level”: 1022,
“grnd_level”: 1002,
“humidity”: 60,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“clouds”: {
“all”: 7
},
“wind”: {
“speed”: 3.32,
“deg”: 52,
“gust”: 5.58
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-07 15:00:00”
},
{
“dt”: 1712512800,
“main”: {
“temp”: 282.7,
“feels_like”: 281.41,
“temp_min”: 282.7,
“temp_max”: 282.7,
“pressure”: 1022,
“sea_level”: 1022,
“grnd_level”: 1002,
“humidity”: 52,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“clouds”: {
“all”: 7
},
“wind”: {
“speed”: 2.54,
“deg”: 50,
“gust”: 4.57
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-07 18:00:00”
},
{
“dt”: 1712523600,
“main”: {
“temp”: 284.14,
“feels_like”: 282.63,
“temp_min”: 284.14,
“temp_max”: 284.14,
“pressure”: 1021,
“sea_level”: 1021,
“grnd_level”: 1001,
“humidity”: 51,
“temp_kf”: 0
},
“weather”: [
{
“id”: 801,
“main”: “Clouds”,
“description”: “few clouds”,
“icon”: “02d”
}
],
“clouds”: {
“all”: 12
},
“wind”: {
“speed”: 2.26,
“deg”: 32,
“gust”: 4.2
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-07 21:00:00”
},
{
“dt”: 1712534400,
“main”: {
“temp”: 278.86,
“feels_like”: 278.02,
“temp_min”: 278.86,
“temp_max”: 278.86,
“pressure”: 1021,
“sea_level”: 1021,
“grnd_level”: 1001,
“humidity”: 77,
“temp_kf”: 0
},
“weather”: [
{
“id”: 801,
“main”: “Clouds”,
“description”: “few clouds”,
“icon”: “02n”
}
],
“clouds”: {
“all”: 11
},
“wind”: {
“speed”: 1.41,
“deg”: 326,
“gust”: 1.26
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-08 00:00:00”
},
{
“dt”: 1712545200,
“main”: {
“temp”: 276.89,
“feels_like”: 275.69,
“temp_min”: 276.89,
“temp_max”: 276.89,
“pressure”: 1021,
“sea_level”: 1021,
“grnd_level”: 1001,
“humidity”: 82,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01n”
}
],
“clouds”: {
“all”: 1
},
“wind”: {
“speed”: 1.48,
“deg”: 317,
“gust”: 1.32
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-08 03:00:00”
},
{
“dt”: 1712556000,
“main”: {
“temp”: 276.1,
“feels_like”: 274.79,
“temp_min”: 276.1,
“temp_max”: 276.1,
“pressure”: 1021,
“sea_level”: 1021,
“grnd_level”: 1001,
“humidity”: 81,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01n”
}
],
“clouds”: {
“all”: 0
},
“wind”: {
“speed”: 1.48,
“deg”: 322,
“gust”: 1.3
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-08 06:00:00”
},
{
“dt”: 1712566800,
“main”: {
“temp”: 275.38,
“feels_like”: 273.97,
“temp_min”: 275.38,
“temp_max”: 275.38,
“pressure”: 1022,
“sea_level”: 1022,
“grnd_level”: 1001,
“humidity”: 80,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01n”
}
],
“clouds”: {
“all”: 0
},
“wind”: {
“speed”: 1.48,
“deg”: 302,
“gust”: 1.33
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-08 09:00:00”
},
{
“dt”: 1712577600,
“main”: {
“temp”: 277.81,
“feels_like”: 277.81,
“temp_min”: 277.81,
“temp_max”: 277.81,
“pressure”: 1022,
“sea_level”: 1022,
“grnd_level”: 1001,
“humidity”: 75,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“clouds”: {
“all”: 0
},
“wind”: {
“speed”: 1.18,
“deg”: 273,
“gust”: 1.89
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-08 12:00:00”
},
{
“dt”: 1712588400,
“main”: {
“temp”: 284.69,
“feels_like”: 283.23,
“temp_min”: 284.69,
“temp_max”: 284.69,
“pressure”: 1020,
“sea_level”: 1020,
“grnd_level”: 1000,
“humidity”: 51,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“clouds”: {
“all”: 0
},
“wind”: {
“speed”: 1.35,
“deg”: 268,
“gust”: 2.44
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-08 15:00:00”
},
{
“dt”: 1712599200,
“main”: {
“temp”: 287.35,
“feels_like”: 285.9,
“temp_min”: 287.35,
“temp_max”: 287.35,
“pressure”: 1018,
“sea_level”: 1018,
“grnd_level”: 999,
“humidity”: 41,
“temp_kf”: 0
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“clouds”: {
“all”: 2
},
“wind”: {
“speed”: 2.56,
“deg”: 284,
“gust”: 3.21
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-08 18:00:00”
},
{
“dt”: 1712610000,
“main”: {
“temp”: 287.29,
“feels_like”: 285.88,
“temp_min”: 287.29,
“temp_max”: 287.29,
“pressure”: 1017,
“sea_level”: 1017,
“grnd_level”: 997,
“humidity”: 43,
“temp_kf”: 0
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 70
},
“wind”: {
“speed”: 2.99,
“deg”: 277,
“gust”: 4.09
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-08 21:00:00”
},
{
“dt”: 1712620800,
“main”: {
“temp”: 281.33,
“feels_like”: 279.72,
“temp_min”: 281.33,
“temp_max”: 281.33,
“pressure”: 1017,
“sea_level”: 1017,
“grnd_level”: 998,
“humidity”: 74,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 85
},
“wind”: {
“speed”: 2.64,
“deg”: 288,
“gust”: 4.56
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-09 00:00:00”
},
{
“dt”: 1712631600,
“main”: {
“temp”: 280.13,
“feels_like”: 278.54,
“temp_min”: 280.13,
“temp_max”: 280.13,
“pressure”: 1017,
“sea_level”: 1017,
“grnd_level”: 997,
“humidity”: 72,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 2.32,
“deg”: 308,
“gust”: 1.98
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-09 03:00:00”
},
{
“dt”: 1712642400,
“main”: {
“temp”: 278.69,
“feels_like”: 277.41,
“temp_min”: 278.69,
“temp_max”: 278.69,
“pressure”: 1018,
“sea_level”: 1018,
“grnd_level”: 998,
“humidity”: 76,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 1.75,
“deg”: 17,
“gust”: 1.69
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-09 06:00:00”
},
{
“dt”: 1712653200,
“main”: {
“temp”: 277.37,
“feels_like”: 275.61,
“temp_min”: 277.37,
“temp_max”: 277.37,
“pressure”: 1019,
“sea_level”: 1019,
“grnd_level”: 999,
“humidity”: 78,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 2,
“deg”: 38,
“gust”: 3.63
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-09 09:00:00”
},
{
“dt”: 1712664000,
“main”: {
“temp”: 278.31,
“feels_like”: 275.52,
“temp_min”: 278.31,
“temp_max”: 278.31,
“pressure”: 1019,
“sea_level”: 1019,
“grnd_level”: 999,
“humidity”: 70,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 95
},
“wind”: {
“speed”: 3.48,
“deg”: 57,
“gust”: 7.96
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-09 12:00:00”
},
{
“dt”: 1712674800,
“main”: {
“temp”: 281.77,
“feels_like”: 279.61,
“temp_min”: 281.77,
“temp_max”: 281.77,
“pressure”: 1021,
“sea_level”: 1021,
“grnd_level”: 1001,
“humidity”: 55,
“temp_kf”: 0
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 69
},
“wind”: {
“speed”: 3.7,
“deg”: 78,
“gust”: 3.92
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-09 15:00:00”
},
{
“dt”: 1712685600,
“main”: {
“temp”: 283.9,
“feels_like”: 282.31,
“temp_min”: 283.9,
“temp_max”: 283.9,
“pressure”: 1019,
“sea_level”: 1019,
“grnd_level”: 1000,
“humidity”: 49,
“temp_kf”: 0
},
“weather”: [
{
“id”: 803,
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 84
},
“wind”: {
“speed”: 3.3,
“deg”: 84,
“gust”: 3.31
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-09 18:00:00”
},
{
“dt”: 1712696400,
“main”: {
“temp”: 283.88,
“feels_like”: 282.24,
“temp_min”: 283.88,
“temp_max”: 283.88,
“pressure”: 1018,
“sea_level”: 1018,
“grnd_level”: 999,
“humidity”: 47,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3.6,
“deg”: 80,
“gust”: 4.14
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-09 21:00:00”
},
{
“dt”: 1712707200,
“main”: {
“temp”: 280.21,
“feels_like”: 277.61,
“temp_min”: 280.21,
“temp_max”: 280.21,
“pressure”: 1018,
“sea_level”: 1018,
“grnd_level”: 998,
“humidity”: 59,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3.86,
“deg”: 55,
“gust”: 9.12
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-10 00:00:00”
},
{
“dt”: 1712718000,
“main”: {
“temp”: 278.46,
“feels_like”: 274.92,
“temp_min”: 278.46,
“temp_max”: 278.46,
“pressure”: 1018,
“sea_level”: 1018,
“grnd_level”: 998,
“humidity”: 64,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 4.9,
“deg”: 52,
“gust”: 11.51
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-10 03:00:00”
},
{
“dt”: 1712728800,
“main”: {
“temp”: 277.33,
“feels_like”: 273.19,
“temp_min”: 277.33,
“temp_max”: 277.33,
“pressure”: 1016,
“sea_level”: 1016,
“grnd_level”: 996,
“humidity”: 68,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 5.58,
“deg”: 54,
“gust”: 12.49
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-10 06:00:00”
},
{
“dt”: 1712739600,
“main”: {
“temp”: 275.99,
“feels_like”: 271.42,
“temp_min”: 275.99,
“temp_max”: 275.99,
“pressure”: 1015,
“sea_level”: 1015,
“grnd_level”: 994,
“humidity”: 81,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 5.75,
“deg”: 56,
“gust”: 10.8
},
“visibility”: 10000,
“pop”: 1,
“rain”: {
“3h”: 0.66
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-10 09:00:00”
},
{
“dt”: 1712750400,
“main”: {
“temp”: 275.59,
“feels_like”: 271.36,
“temp_min”: 275.59,
“temp_max”: 275.59,
“pressure”: 1014,
“sea_level”: 1014,
“grnd_level”: 994,
“humidity”: 94,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10d”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 4.86,
“deg”: 58,
“gust”: 9.62
},
“visibility”: 10000,
“pop”: 1,
“rain”: {
“3h”: 2.87
},
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-10 12:00:00”
},
{
“dt”: 1712761200,
“main”: {
“temp”: 276.57,
“feels_like”: 273.26,
“temp_min”: 276.57,
“temp_max”: 276.57,
“pressure”: 1015,
“sea_level”: 1015,
“grnd_level”: 995,
“humidity”: 99,
“temp_kf”: 0
},
“weather”: [
{
“id”: 501,
“main”: “Rain”,
“description”: “moderate rain”,
“icon”: “10d”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3.69,
“deg”: 75,
“gust”: 8.19
},
“pop”: 1,
“rain”: {
“3h”: 6.15
},
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-10 15:00:00”
},
{
“dt”: 1712772000,
“main”: {
“temp”: 278.6,
“feels_like”: 276.17,
“temp_min”: 278.6,
“temp_max”: 278.6,
“pressure”: 1015,
“sea_level”: 1015,
“grnd_level”: 995,
“humidity”: 95,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10d”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3.03,
“deg”: 111,
“gust”: 7.3
},
“visibility”: 10000,
“pop”: 1,
“rain”: {
“3h”: 0.72
},
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-10 18:00:00”
},
{
“dt”: 1712782800,
“main”: {
“temp”: 279.28,
“feels_like”: 277.01,
“temp_min”: 279.28,
“temp_max”: 279.28,
“pressure”: 1015,
“sea_level”: 1015,
“grnd_level”: 995,
“humidity”: 93,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04d”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3,
“deg”: 70,
“gust”: 5.75
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-10 21:00:00”
},
{
“dt”: 1712793600,
“main”: {
“temp”: 279.15,
“feels_like”: 276.83,
“temp_min”: 279.15,
“temp_max”: 279.15,
“pressure”: 1016,
“sea_level”: 1016,
“grnd_level”: 996,
“humidity”: 93,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3.04,
“deg”: 61,
“gust”: 5.72
},
“visibility”: 10000,
“pop”: 0.2,
“rain”: {
“3h”: 0.2
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-11 00:00:00”
},
{
“dt”: 1712804400,
“main”: {
“temp”: 278.35,
“feels_like”: 275.53,
“temp_min”: 278.35,
“temp_max”: 278.35,
“pressure”: 1016,
“sea_level”: 1016,
“grnd_level”: 996,
“humidity”: 91,
“temp_kf”: 0
},
“weather”: [
{
“id”: 804,
“main”: “Clouds”,
“description”: “overcast clouds”,
“icon”: “04n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 3.54,
“deg”: 79,
“gust”: 6.74
},
“visibility”: 10000,
“pop”: 0,
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-11 03:00:00”
},
{
“dt”: 1712815200,
“main”: {
“temp”: 277.95,
“feels_like”: 274.5,
“temp_min”: 277.95,
“temp_max”: 277.95,
“pressure”: 1014,
“sea_level”: 1014,
“grnd_level”: 994,
“humidity”: 91,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 4.48,
“deg”: 88,
“gust”: 9.56
},
“visibility”: 10000,
“pop”: 0.2,
“rain”: {
“3h”: 0.31
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-11 06:00:00”
},
{
“dt”: 1712826000,
“main”: {
“temp”: 277.56,
“feels_like”: 273.74,
“temp_min”: 277.56,
“temp_max”: 277.56,
“pressure”: 1013,
“sea_level”: 1013,
“grnd_level”: 993,
“humidity”: 94,
“temp_kf”: 0
},
“weather”: [
{
“id”: 500,
“main”: “Rain”,
“description”: “light rain”,
“icon”: “10n”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 5.02,
“deg”: 77,
“gust”: 10.4
},
“visibility”: 9349,
“pop”: 0.88,
“rain”: {
“3h”: 0.54
},
“sys”: {
“pod”: “n”
},
“dt_txt”: “2024-04-11 09:00:00”
},
{
“dt”: 1712836800,
“main”: {
“temp”: 277.43,
“feels_like”: 273.5,
“temp_min”: 277.43,
“temp_max”: 277.43,
“pressure”: 1011,
“sea_level”: 1011,
“grnd_level”: 991,
“humidity”: 98,
“temp_kf”: 0
},
“weather”: [
{
“id”: 501,
“main”: “Rain”,
“description”: “moderate rain”,
“icon”: “10d”
}
],
“clouds”: {
“all”: 100
},
“wind”: {
“speed”: 5.17,
“deg”: 82,
“gust”: 11
},
“visibility”: 558,
“pop”: 1,
“rain”: {
“3h”: 4.71
},
“sys”: {
“pod”: “d”
},
“dt_txt”: “2024-04-11 12:00:00”
}
],
“city”: {
“id”: 6137745,
“name”: “Sainte-Anne-des-Lacs”,
“coord”: {
“lat”: 45.77,
“lon”: -74.1199
},
“country”: “CA”,
“population”: 0,
“timezone”: -14400,
“sunrise”: 1712399160,
“sunset”: 1712446264
}
}

Blockquote

OK…in the meantime I built something based on met.no… I also wated something for my travelling family

command_line:
  - sensor:
        name: Weather Dynamic ABC
        unique_id: weather_dynamic_abc
        scan_interval: 3600
        command: >
            curl "https://api.met.no/weatherapi/locationforecast/2.0?lat={{state_attr('zone.home','latitude')}}&lon={{state_attr('zone.home','longitude')}}" | jq '{ latitude: .geometry.coordinates[1], longitude: .geometry.coordinates[0], forecast: . | [ .properties.timeseries[] | {datetime: .time, temperature: .data.instant.details.air_temperature, wind_speed: .data.instant.details.wind_speed, wind_bearing: .data.instant.details.wind_from_direction , precipitation: .data.next_1_hours.details.precipitation_amount, precipitation_probability: .data.next_1_hours.details.probability_of_precipitation  }]}'
        value_template: "{{ value_json.properties.meta.updated_at }}"       
        json_attributes:
          - latitude
          - longitude
          - forecast 

I will try to add soemthing for above too

And here is the ‘simple’ one… I hope this give you sufficient material to build it further

command_line:
  - sensor:
        name: Weather Dynamic OWM
        unique_id: weather_dynamic_owm
        scan_interval: 3600
        command: >
            curl "https://api.openweathermap.org/data/2.5/weather?lat={{state_attr('zone.home','latitude')}}&lon={{state_attr('zone.home','longitude')}}&APPID=12345678" | jq '{ latitude: .coord.lat, longitude: .coord.lon, temperature: .main.temp, wind_speed: .wind.speed, wind_bearing: .wind.deg, humidity: .main.humidity, datetime: .dt }'
        value_template: "{{ as_datetime(value_json.datetime) }}" 
        json_attributes:
          - latitude
          - longitude
          - humidity
          - wind_bearing
          - wind_speed
          - temperature

as part of the data is nested, you need jq to get that out to flatten it and use the same naming for use in cards…I do agree jq is a bit daunting and esp. the first one is tricky with building dict/list/etc.

@vingerha thanks for all this work, I already had been able to create the sensor for the weather API.

I am probably missing something as I definitly don’t have a programmers understanding of all HA but what I understand here is that I have to build the sensors and parse all data from the https://api.openweathermap.org/data/2.5/weather/forecast?lat=´{MY-LAT}&lon={MY-LONG}&APPID={MY-API-KEY} and then create a template weather provider ?

There is no way to use the already existing OpenWeather integration and just “push” the HOME location for the integration to use instead of the hard coded lat/long ?

I think i’ll have to pass on this, thanks for your help but this is way over my capabilities, for now, I’ll have to wait for an integration that will offer a dynamic position.

thanks a lot for your time

Correct, as the output is different per provider and usually does not match the naming convention used in HA cards, you have to parse it through jq. There is an alternative but then you first need to load the whole output and then sensor per sensor get the data out. REST does not allow to dig into embedded json too.

That is what @rossk suggests and if you want your server to completely follow you then this is fine. For me, my server is fixed on one location and with the above examples I can have forecast for each object/person/zone in my household, wherever they are.

I understand that this is a challenge, for now I have not seen any dynamic integration. I may build one myself overtime but the relatively simple (for me) solution above is sufficient already

The problem with @rossk solution is that it DOES NOT work for the OpenWeather integration, this integration DOES NOT take the home location to get forecast, it gets it’s forecast from lat/long that is entered manually in the integration at installation time and won’t change even if you change HOME

thanks for this again,I’ll try to find a way to request that the OpenWeather integration be modified to use HOME Or lat/long

You can try but that may take a while :slight_smile: From a architectural pov, HA is not setup to be used in a ‘moving’ situation. And if you want a moving prediction then it has to be per-provider…not saying it is impossible but someone has to see a benefit vs. implementation effort.

EDIT : @rossk solution may work for met.no or accuweather as these seems to take HA location

Update-----

Neither Accuweather, Openweathermap, tommorow,io use dynamic HOME location when they get the forecast, ONLY the included met.no does dynamicaly change it’s data if your HOME location change.

Altough it does not seem as precise as other, I guess I’ll stick with this one for now

As of recent changes in how the weather integration works, now I’m moving completetly out of ot, to fully controllable by me setup. I’m using Weatherbit.io for this, as from my experience it provides the most accurate data for my location. The key is shell command that writes JSON files with forecast and current conditions to local HA folder:

shell_command:
  get_weatherbit_forecast: curl 'https://api.weatherbit.io/v2.0/forecast/daily?lat=52.31115340273245&lon=21.16118870150636&lang=en&units=M&key=___redasted___' | sed 's/pop/popp/g' > www/weatherbit_forecast.json
  get_weatherbit_current: curl 'https://api.weatherbit.io/v2.0/current?lat=52.31115340273245&lon=21.16118870150636&lang=en&units=M&key=___redacted___' > www/weatherbit_current.json


automation:
  - id: "update_weather_forecast"
    alias: Update Weather Forecast
    initial_state: true
    trigger:
      platform: time_pattern
      hours: '/04'
    action:
      service: shell_command.get_weatherbit_forecast

  - id: "update_weather_current"
    alias: Update Weather Current
    initial_state: true
    trigger:
      platform: time_pattern
      hours: '/01'
    action:
      service: shell_command.get_weatherbit_current

As long as you can provide GPS coordinates, you can modify the script to obtain data for specific location, chaning at every service call. The rest is just set of REST sensors reading from JSON files written to HA folder, so any sensor can be created out of available data (either current conditions or forecast, depending on need). Tricky part is limit of 50 calls per day in free plan. Currentl;y I’m calling forecast every 4h and current conditions every 1h, which consumes 30 calls in total. Works perfectly fine.

1 Like

I’m not seeing this (nor how to tell it to use current home location versus static coordinates on setup of the integration).

met.no is the base weather provider included at installation time so there is no configuration to be made not integrations to be installed, it takes all it’s information from current HOME Lat/long.

If you install a brand new HA system and install no weather integration, you could put a weather card on a dashboard and get the forecast from the weather.forecast_{YOUR_SYSTEM_NAME}

I long ago deleted the integration that was included at installation. Adding it back unfortunately doesn’t have the option to use the home location, only a hard-coded lat/long like all the other weather integrations.

have you tried installing it and leave lat/long field empty ? It might configures itself using the HOME location ?

You can’t leave it empty and it just auto-fills with your current position. I’m remembering that this is an issue (it only follows home if you use it as it’s setup during first install) when I first went down this path a year ago.