where do you put what you listed?
I get the current weather but I have a PWS weather station and already get that. I need help with the future forecast. Can anyone assist with this?
I do recommend to take your weather station data directly from the station. You can get it i json format.
My Wunderground seems to have broke a few weeks ago and I’m not sure why. I did update the URL as mentioned above but I still am showing “Entity not available: sensor.pws_[whatever]” on all of my Custom Button Cards. I tried to do just a plain Entity love lace card and it also shows the same.
When I manually paste the URL from the wunderground_url in my browser I do get the data.
What am I missing?
Here’s a snippet of my configuration.yaml:
# weatherunderground
sensor:
- platform: rest
name: pws_report
json_attributes:
- observations
value_template: '{{ value_json["observations"][0]["obsTimeLocal"].title() }}'
resource: !secret wunderground_url
scan_interval: 300
- platform: template
sensors:
pws_location:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].neighborhood }}'
friendly_name: Location
pws_station_id:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].stationID }}'
friendly_name: Staion ID
pws_type:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].softwareType }}'
friendly_name: Station Type
pws_wind_dir:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].winddir }}'
friendly_name: Wind Direction
unit_of_measurement: "°"
pws_wind_gust:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].imperial.windGust }}'
friendly_name: Wind Gust
unit_of_measurement: "MPH"
pws_wind_speed:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].imperial.windSpeed }}'
friendly_name: Wind Speed
unit_of_measurement: "MPH"
pws_humidity:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].humidity }}'
friendly_name: Humidity
unit_of_measurement: "%"
pws_precip_total:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].imperial.precipTotal }}'
friendly_name: Rain Total
unit_of_measurement: "in"
pws_precip_rate:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].imperial.precipRate }}'
friendly_name: Rain Rate
unit_of_measurement: "in"
pws_temp:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].imperial.temp }}'
friendly_name: Temp
unit_of_measurement: "°F"
pws_solar:
value_template: '{{ states.sensor.pws_report.attributes.observations[0].solarRadiation }}'
This is weird!
If I log in with my APIKEY and STATIONID and specify the lat and long from Bamako Airport in Mali, Africa, I get my local temperature and precipitation, but today summary is Bamako’s one.
I’m not a py man, but sensor.py says:
if pws_id is None:
unique_id_base = f"@{longitude:06f},{latitude:06f}"
else:
# Manually specified weather station, use that for unique_id
unique_id_base = pws_id
pws_id can’t be omitted, this result in a config errror, setting pws_id to none returns nothing. Hardcoding the lat and long in sensor.py gives the same result, Bamako summary and my temp
Anyway, question is: How to retrieve other station weather, if at all possible?
if this would be possible on a Home Assistant OS installation, this would be the perfect solution!
But i don’t think so
Works perfect for me thanks a lot for your work, but i have questtion to add addtional Sensors from PWS Report. i want to add uv and solarRadiation cahnge the Sensor to:
pws_uv:
value_template: ‘{{ states.sensor.pws_report.attributes.observations[0].metric.uv }}’
friendly_name: UV Index
unit_of_measurement: “”
pws_solarradiation:
value_template: ‘{{ states.sensor.pws_report.attributes.observations[0].metric.solarradiation }}’
friendly_name: Solarleistung
unit_of_measurement: “Watt/m²”
but i do get the values from the report, i got only “0” but in the report the values are correct.
can you tell me whats wrong pls^^
I’ve followed instructions and tips provided by @wuench and @paulrafu and now have my PWS data displayed on my dashboard. Very rudimentary card, lots or room to improve it!
Maybe obvious, but nobody’s mentioned “Add new entities to a new card on the dashboard” in the instructions. There might be a “right” way to do this, but my quick-n-dirty method was to edit the dashboard, list unused entities, mark all the PWS related ones and add to a new card.
Looking forward to working out how to get forecast data displayed too - I had it working but a corrupt config caused me to rebuild from scratch.
Question: are the directories to be copied (per GitHub - cytech/Home-Assistant-wundergroundpws: Home Assistant custom component sensor for Weather) required using this method? I’ve loaded them, found the config wouldn’t work on my RPi4, and reverted to the above. Can I safely delete?
You don’t need any custom components, integrations, etc with this method.
Great - thanks.
I have tried both hass.io integration as well as url
I am getting all the data in the browser, no problem, but data is not being passed to ha. Tried both metric and imperial, no difference.
I also avoided !secret just to make sure there is no errors there and have hard coded the url
Running on raspberry pi4, Debian 10, docker (supervised)
Can anyone advise where to look next?
Thanks wuench, this worked like a charm.
I am also trying to get the history, but this requires a date. Obviously I’d like this to be “yesterday” and set up an automation or script, however, the date has to be imbedded in the URL. I can’t work out how to make the URL dynamic.
URL Construction
Atomic API URL Examples:
Request by PWS Station ID: Required Parameters: stationId, format, units, date, apiKey | Optional Parameter: numericPrecision
https://api.weather.com/v2/pws/history/hourly?stationId=<stationId>&format=<format>&units=<units>&date=<date>&apiKey=<apiKey>
https://api.weather.com/v2/pws/history/hourly?stationId=KCAOAKLA44&format=json&units=m&date=20181001&apiKey=yourApiKey
Valid Parameter Definitions
Parameter Name - Valid Parameter Value - Description
stationId - KCAOAKLA44 - Any valid PWS Station ID. To be used as location query parameter
date - YYYYMMDD - The date parameter is used to call the specific date request, using format “YYYYMMDD”
numericPrecision - decimal - Optional parameter. Set to ‘decimal’ to ensure data is returned in decimal format when needed. Will return integers if this value is not used.
It looks like the REST sensor supports variable resources, you have to use resource_template instead of resource.
Not sure now to do the time math. You can use {{ now() }} to get the current year, month, day, but somehow you would need to subtract one day.
Actually, looking at the output for the URL, the DailySummary (for 7 days) is perfect for me. I also want to get the forecast for my location.
However, since I’m a newbie I’m struggling with the formatting of the Rest correctly, particular adding the History and Forecast, in addition to the current state. The two things I don’t know how to do is format the rest platform to include the calls for history and forecast, and the parsing of the results.
The URL for the 7-day history is
https://api.weather.com/v2/pws/dailysummary/7day?stationId=<myStationID>&format=json&units=m&apiKey=<myAPIkey&numericPrecision=decimal
The result is
{"summaries":[{"stationID":"IALCAB23","tz":"Europe/Lisbon","obsTimeUtc":"2021-09-09T22:59:49Z","obsTimeLocal":"2021-09-09 23:59:49","epoch":1631228389,"lat":38.754702,"lon":-9.445613,"solarRadiationHigh":453.0,"uvHigh":4.0,"winddirAvg":19,"humidityHigh":70.0,"humidityLow":50.0,"humidityAvg":65.9,"qcStatus":0,"metric":{"tempHigh":29.4,"tempLow":24.2,"tempAvg":25.3,"windspeedHigh":11.1,"windspeedLow":0.0,"windspeedAvg":0.0,"windgustHigh":14.8,"windgustLow":0.0,"windgustAvg":0.1,"dewptHigh":19.4,"dewptLow":17.1,"dewptAvg":18.5,"windchillHigh":29.4,"windchillLow":24.2,"windchillAvg":25.3,"heatindexHigh":30.3,"heatindexLow":24.4,"heatindexAvg":25.7,"pressureMax":1013.61,"pressureMin":1012.12,"pressureTrend":0.09,"precipRate":0.00,"precipTotal":0.79}},{"stationID":"IALCAB23","tz":"Europe/Lisbon","obsTimeUtc":"2021-09-10T22:59:47Z","obsTimeLocal":"2021-09-10 23:59:47","epoch":1631314787,"lat":38.754702,"lon":-9.445613,"solarRadiationHigh":899.3,"uvHigh":8.0,"winddirAvg":233,"humidityHigh":87.0,"humidityLow":40.0,"humidityAvg":69.0,"qcStatus":0,"metric":{"tempHigh":31.8,"tempLow":20.3,"tempAvg":24.1,"windspeedHigh":9.0,"windspeedLow":0.0,"windspeedAvg":0.7,"windgustHigh":13.0,"windgustLow":0.0,"windgustAvg":1.2,"dewptHigh":19.4,"dewptLow":13.9,"dewptAvg":17.8,"windchillHigh":31.8,"windchillLow":20.3,"windchillAvg":24.1,"heatindexHigh":32.5,"heatindexLow":20.3,"heatindexAvg":24.4,"pressureMax":1014.22,"pressureMin":1011.72,"pressureTrend":0.00,"precipRate":3.00,"precipTotal":0.51}},{"stationID":"IALCAB23","tz":"Europe/Lisbon","obsTimeUtc":"2021-09-11T22:59:44Z","obsTimeLocal":"2021-09-11 23:59:44","epoch":1631401184,"lat":38.754702,"lon":-9.445613,"solarRadiationHigh":1243.2,"uvHigh":12.0,"winddirAvg":327,"humidityHigh":94.0,"humidityLow":48.0,"humidityAvg":74.9,"qcStatus":0,"metric":{"tempHigh":30.0,"tempLow":17.6,"tempAvg":22.6,"windspeedHigh":14.8,"windspeedLow":0.0,"windspeedAvg":1.6,"windgustHigh":18.3,"windgustLow":0.0,"windgustAvg":2.5,"dewptHigh":19.4,"dewptLow":15.6,"dewptAvg":17.5,"windchillHigh":30.0,"windchillLow":17.6,"windchillAvg":22.6,"heatindexHigh":31.0,"heatindexLow":17.6,"heatindexAvg":22.8,"pressureMax":1013.34,"pressureMin":1008.33,"pressureTrend":-0.20,"precipRate":0.00,"precipTotal":0.00}},{"stationID":"IALCAB23","tz":"Europe/Lisbon","obsTimeUtc":"2021-09-12T12:30:07Z","obsTimeLocal":"2021-09-12 13:30:07","epoch":1631449807,"lat":38.754702,"lon":-9.445613,"solarRadiationHigh":755.1,"uvHigh":7.0,"winddirAvg":16,"humidityHigh":97.0,"humidityLow":56.0,"humidityAvg":86.9,"qcStatus":1,"metric":{"tempHigh":27.7,"tempLow":17.9,"tempAvg":20.4,"windspeedHigh":12.2,"windspeedLow":0.0,"windspeedAvg":1.4,"windgustHigh":18.3,"windgustLow":0.0,"windgustAvg":2.3,"dewptHigh":19.6,"dewptLow":16.2,"dewptAvg":17.9,"windchillHigh":27.7,"windchillLow":17.9,"windchillAvg":20.4,"heatindexHigh":28.9,"heatindexLow":17.9,"heatindexAvg":20.5,"pressureMax":1008.74,"pressureMin":1005.62,"pressureTrend":-0.22,"precipRate":0.00,"precipTotal":0.00}}]}
The URL for the forecast is
https://api.weather.com/v3/wx/forecast/daily/5day?geocode=38.754702,-9.445613&format=json&units=m&language=en-US&apiKey=<myAPIkey>
The result is
{"calendarDayTemperatureMax":[24,22,22,22,23,23],"calendarDayTemperatureMin":[19,19,19,18,19,19],"dayOfWeek":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"],"expirationTimeUtc":[1631451439,1631451439,1631451439,1631451439,1631451439,1631451439],"moonPhase":["Waxing Crescent","First Quarter","Waxing Gibbous","Waxing Gibbous","Waxing Gibbous","Waxing Gibbous"],"moonPhaseCode":["WXC","FQ","WXG","WXG","WXG","WXG"],"moonPhaseDay":[6,7,8,9,10,11],"moonriseTimeLocal":["2021-09-12T13:21:45+0100","2021-09-13T14:34:41+0100","2021-09-14T15:42:25+0100","2021-09-15T16:43:29+0100","2021-09-16T17:34:33+0100","2021-09-17T18:17:34+0100"],"moonriseTimeUtc":[1631449305,1631540081,1631630545,1631720609,1631810073,1631899054],"moonsetTimeLocal":["2021-09-12T23:18:02+0100","","2021-09-14T00:05:14+0100","2021-09-15T01:00:31+0100","2021-09-16T02:03:29+0100","2021-09-17T03:11:03+0100"],"moonsetTimeUtc":[1631485082,null,1631574314,1631664031,1631754209,1631844663],"narrative":["Mix of sun and clouds. Highs 22 to 24C and lows 17 to 19C.","Thunderstorms. Highs 21 to 23C and lows 18 to 20C.","Thunderstorms. Highs 21 to 23C and lows 17 to 19C.","Showers. Highs 21 to 23C and lows 18 to 20C.","A few clouds. Highs 22 to 24C and lows 18 to 20C.","A few clouds. Highs 21 to 23C and lows 17 to 19C."],"qpf":[4.4,18.31,6.9,1.46,0.0,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0],"sunriseTimeLocal":["2021-09-12T07:16:27+0100","2021-09-13T07:17:19+0100","2021-09-14T07:18:12+0100","2021-09-15T07:19:05+0100","2021-09-16T07:19:58+0100","2021-09-17T07:20:51+0100"],"sunriseTimeUtc":[1631427387,1631513839,1631600292,1631686745,1631773198,1631859651],"sunsetTimeLocal":["2021-09-12T19:50:29+0100","2021-09-13T19:48:53+0100","2021-09-14T19:47:16+0100","2021-09-15T19:45:40+0100","2021-09-16T19:44:03+0100","2021-09-17T19:42:26+0100"],"sunsetTimeUtc":[1631472629,1631558933,1631645236,1631731540,1631817843,1631904146],"temperatureMax":[23,22,22,22,23,23],"temperatureMin":[19,19,18,19,19,18],"validTimeLocal":["2021-09-12T07:00:00+0100","2021-09-13T07:00:00+0100","2021-09-14T07:00:00+0100","2021-09-15T07:00:00+0100","2021-09-16T07:00:00+0100","2021-09-17T07:00:00+0100"],"validTimeUtc":[1631426400,1631512800,1631599200,1631685600,1631772000,1631858400],"daypart":[{"cloudCover":[46,84,84,83,83,68,51,29,29,18,30,26],"dayOrNight":["D","N","D","N","D","N","D","N","D","N","D","N"],"daypartName":["Today","Tonight","Tomorrow","Tomorrow night","Tuesday","Tuesday night","Wednesday","Wednesday night","Thursday","Thursday night","Friday","Friday night"],"iconCode":[30,4,4,4,4,4,11,29,34,33,34,33],"iconCodeExtend":[3000,7200,400,400,400,400,1100,2900,3400,3300,3400,3300],"narrative":["A mix of clouds and sun. High 23C. Winds S at 10 to 15 km/h.","Cloudy skies this evening followed by thunderstorms late. Low 18C. Winds S at 15 to 25 km/h. Chance of rain 80%.","Thunderstorms likely. Not as hot. High 22C. Winds SSE at 15 to 30 km/h. Chance of rain 90%.","Thunderstorms likely. Low 19C. Winds S at 15 to 25 km/h. Chance of rain 90%.","Thunderstorms likely. High 22C. Winds S at 15 to 25 km/h. Chance of rain 90%.","Thunderstorms. Low 18C. Winds light and variable. Chance of rain 80%.","Light rain early...then remaining cloudy with showers in the afternoon. High 22C. Winds NNE at 10 to 15 km/h. Chance of rain 60%.","Partly cloudy skies. Low 19C. Winds N at 10 to 15 km/h.","Sun and a few passing clouds. High 23C. Winds N at 15 to 30 km/h.","Mostly clear. Low 19C. Winds NNW at 15 to 30 km/h.","A few clouds early, otherwise mostly sunny. High 22C. Winds NNW at 15 to 30 km/h. Winds could occasionally gust over 65 km/h.","Mostly clear skies. Low 18C. Winds NNW at 15 to 30 km/h."],"precipChance":[2,84,92,91,87,75,63,24,24,17,12,6],"precipType":["rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],"qpf":[0.0,4.4,11.28,7.03,4.85,2.05,1.46,0.0,0.0,0.0,0.0,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"qualifierCode":[null,null,"Q765",null,null,null,null,null,null,null,"Q1021",null],"qualifierPhrase":[null,null,"Not as hot.",null,null,null,null,null,null,null,"Winds could occasionally gust over 65 km/h.",null],"relativeHumidity":[73,90,86,90,85,88,80,85,79,85,76,83],"snowRange":["","","","","","","","","","","",""],"temperature":[23,19,22,19,22,18,22,19,23,19,23,18],"temperatureHeatIndex":[23,22,23,22,22,21,22,22,23,22,23,21],"temperatureWindChill":[22,20,19,19,19,19,18,19,19,19,19,19],"thunderCategory":["No thunder","Thunder expected","Thunder expected","Thunder expected","Thunder expected","Thunder expected","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder"],"thunderIndex":[0,2,2,2,2,2,0,0,0,0,0,0],"uvDescription":["High","Low","Moderate","Low","Moderate","Low","High","Low","High","Low","High","Low"],"uvIndex":[7,0,5,0,5,0,7,0,7,0,7,0],"windDirection":[189,170,157,174,171,161,31,352,349,345,344,348],"windDirectionCardinal":["S","S","SSE","S","S","SSE","NNE","N","N","NNW","NNW","NNW"],"windPhrase":["Winds S at 10 to 15 km/h.","Winds S at 15 to 25 km/h.","Winds SSE at 15 to 30 km/h.","Winds S at 15 to 25 km/h.","Winds S at 15 to 25 km/h.","Winds light and variable.","Winds NNE at 10 to 15 km/h.","Winds N at 10 to 15 km/h.","Winds N at 15 to 30 km/h.","Winds NNW at 15 to 30 km/h.","Winds NNW at 15 to 30 km/h.","Winds NNW at 15 to 30 km/h."],"windSpeed":[15,18,22,17,20,9,17,16,24,25,27,26],"wxPhraseLong":["Partly Cloudy","Thunderstorms Late","Thunderstorms","Thunderstorms","Thunderstorms","Thunderstorms","Showers","Partly Cloudy","Mostly Sunny","Mostly Clear","Mostly Sunny","Mostly Clear"],"wxPhraseShort":["P Cloudy","T-Storms","T-Storms","T-Storms","T-Storms","T-Storms","Showers","P Cloudy","M Sunny","M Clear","M Sunny","M Clear"]}]}
Just an FYI, straight from the manual:
Of course some math will be required to get “yesterday”, but it should be easy enough in the template using the time_date platform.
https://www.home-assistant.io/integrations/history_stats/
This is the best integration, for me anyway. Could not get cytech working.
Question though, how did you determine your units of measure? Is there a document you used? I want to add pressure.
Going to try and add a daily forcast
Good job, thanks
The unit of measure is just what text you want appended to the value displayed. So it can be anything you want. The value the API will give you is based on your selection of imperial, metric, or hybrid. For imperial pressure is in inches.
There is forecast API but I don’t know how to make it work with the Lovelace weather object.
works also for me, THX for share.
has anyone already integrated brightness and soil moisture ?
Thanks for this! I’m just getting started with HA (coming from Hubitat) and this was my first cut & paste customization. Much to learn and looking forward to it.
Thank you so much good sir… i basically copied the two lots of code, swapped in my API key and ID and BAM… up and running…
only question is i would like mm/h for rain… not L/h… how???