Weather from different locations

Hi there,

I wonder if it is possible to get the weather from two( or more) different locations at the same time.
I want to control the light controller of my fish tank with the cloud and sunset from a location in thailand (with an offset) but also want to get my local weather for other home releated stuff.

I thought maybe i can use the zone componet for that but im pretty new to this stuff and dont know where to put my effort in.

1 Like

Since most of the weather sensors available seem to use the lat and longitude from your config file, you will probably need to use something such as a rest sensor. https://home-assistant.io/components/sensor.rest/

Pull the data from a weather api using the coordinates of where ever you want weather from, the rest sensor will poll that data periodically. Then you will need to make different sensors (template sensors maybe) to use just the cloud or sun data from the rest sensors data.

Its a bit complex if you don’t know what you’re doing really, its a bit of a shame you cant just enter a latitude and longitude and have a second weather sensor that is already built into home assistant. Maybe there is though - I didn’t check too hard.

edit: maybe this one https://home-assistant.io/components/weather.openweathermap/ seems to let you choose your coordinates

1 Like

Be advised that OWM only outputs in Centigrade. Not that there’s anything wrong with that if you live outside the US!

Old thread but I’ve successfully made Weather Underground to work with 2 locations.

I used the code from the github page (wunderground.py) - here:
https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/wunderground.py

and altered it so that all references to pws were changed to gws (in my example). Take note of uppercase and lowercase and find/replace as appropriate.

I then pasted the code into wunderground2.py in Homeassistant’s custom components folder, and added it to my config file as per the existing wunderground for the first location, albeit as wunderground2. This created new sensors in HA called sensor.gws etc. etc. which work a treat alongside the sensor.pws entries from the original code.

Example groups.yaml for the 2nd wunderground sensor:

current_weather_ih:
name: <2nd location> Current Weather
entities:
- sensor.gws_weather
- sensor.gws_station_id
- sensor.gws_location
- sensor.gws_solarradiation
- sensor.gws_weather_1d_metric
- sensor.gws_temp_high_1d_c
- sensor.gws_temp_c
- sensor.gws_relative_humidity
- sensor.gws_temp_low_1d_c
- sensor.gws_precip_1d
- sensor.gws_precip_1d_mm
- sensor.gws_wind_dir
- sensor.gws_wind_kph
- sensor.gws_wind_1d_kph
- sensor.gws_wind_string
- sensor.gws_UV
- sensor.gws_alerts
- sensor.gws_observation_time

daily_forecast_ih:
name: <2nd location> Daily Forecast
entities:
- sensor.gws_weather_1d_metric
- sensor.gws_weather_1n_metric
- sensor.gws_weather_2d_metric
- sensor.gws_weather_2n_metric
- sensor.gws_weather_3d_metric
- sensor.gws_weather_3n_metric
- sensor.gws_weather_4d_metric
- sensor.gws_weather_4n_metric

example configuration.yaml for second wu sensor:

  • platform: wunderground2
    api_key: xxxxxxxxxabcabcxxx
    latitude: XXXXX
    longitude: XXXXX
    monitored_conditions:
    • location
    • relative_humidity
    • observation_time
    • station_id
    • weather
    • solarradiation
    • weather_1d_metric
    • weather_1n_metric
    • weather_2d_metric
    • weather_2n_metric
    • weather_3d_metric
    • weather_3n_metric
    • weather_4d_metric
    • weather_4n_metric
    • temp_high_1d_c
    • wind_dir
    • temp_c
    • temp_low_1d_c
    • precip_1d
    • precip_1d_mm
    • UV
    • wind_kph
    • wind_1d_kph
    • alerts

and this is how it looks:

my wunderground.py - I placed it in /home/homeassistant/.homeassistant/custom_components AND in the ./sensor folder. (wasn’t sure at the time)

name_me_wunderground2.py_.yaml (33.3 KB)

wow, thanks a lot i will try it when i have time

you should finally give up the imperial sistem!

how you do this? Sorry I do not understand gws pws

Ok so make a copy of the .py file, name it something else and edit the copy. Change all the .pws variables to something else. I made mine gws. These are the variables that the code grabs via the API. Then use the built in component in Hass for one location and the copy you made as a custom component.

George