mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add timeout to requests (#4398)
This commit is contained in:
parent
c6f5a5443f
commit
5d8a465c18
@ -26,8 +26,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
def get_service(hass, config):
|
||||
"""Get the NMA notification service."""
|
||||
response = requests.get(_RESOURCE + 'verify',
|
||||
params={"apikey": config[CONF_API_KEY]})
|
||||
parameters = {
|
||||
'apikey': config[CONF_API_KEY],
|
||||
}
|
||||
response = requests.get(
|
||||
'{}{}'.format(_RESOURCE, 'verify'), params=parameters, timeout=5)
|
||||
tree = ET.fromstring(response.content)
|
||||
|
||||
if tree[0].tag == 'error':
|
||||
@ -47,14 +50,15 @@ class NmaNotificationService(BaseNotificationService):
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a user."""
|
||||
data = {
|
||||
"apikey": self._api_key,
|
||||
"application": 'home-assistant',
|
||||
"event": kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
|
||||
"description": message,
|
||||
"priority": 0,
|
||||
'apikey': self._api_key,
|
||||
'application': 'home-assistant',
|
||||
'event': kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
|
||||
'description': message,
|
||||
'priority': 0,
|
||||
}
|
||||
|
||||
response = requests.get(_RESOURCE + 'notify', params=data)
|
||||
response = requests.get(
|
||||
'{}{}'.format(_RESOURCE, 'notify'), params=data, timeout=5)
|
||||
tree = ET.fromstring(response.content)
|
||||
|
||||
if tree[0].tag == 'error':
|
||||
|
Loading…
x
Reference in New Issue
Block a user