Skip to content

Commit

Permalink
Add user-agent to fix dwd_weather_warnings setup error (#29596)
Browse files Browse the repository at this point in the history
* Added dummy user-agent to http request to fix setup error

* Replace dummy user-agent with the user-agent of the global home assistant session

* Adjust comment and rename user-agent constant
  • Loading branch information
springstan authored and balloob committed Dec 11, 2019
1 parent 302d5d6 commit 0cb9d07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion homeassistant/components/dwd_weather_warnings/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE as HA_USER_AGENT
from homeassistant.helpers.entity import Entity
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, CONF_MONITORED_CONDITIONS
Expand Down Expand Up @@ -184,7 +185,10 @@ def __init__(self, region_name):
"jsonp=loadWarnings",
)

self._rest = RestData("GET", resource, None, None, None, True)
# a User-Agent is necessary for this rest api endpoint (#29496)
headers = {"User-Agent": HA_USER_AGENT}

self._rest = RestData("GET", resource, None, headers, None, True)
self.region_name = region_name
self.region_id = None
self.region_state = None
Expand Down

0 comments on commit 0cb9d07

Please sign in to comment.