mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Timeout and Constant added
This commit is contained in:
parent
e89aa6b2d6
commit
d09dcc4b03
@ -13,6 +13,7 @@ import voluptuous as vol
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService)
|
ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService)
|
||||||
|
from homeassistant.const import CONTENT_TYPE_JSON
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ class FacebookNotificationService(BaseNotificationService):
|
|||||||
targets = kwargs.get(ATTR_TARGET)
|
targets = kwargs.get(ATTR_TARGET)
|
||||||
|
|
||||||
if not targets:
|
if not targets:
|
||||||
_LOGGER.info("At least 1 target is required")
|
_LOGGER.error("At least 1 target is required")
|
||||||
return
|
return
|
||||||
|
|
||||||
for target in targets:
|
for target in targets:
|
||||||
@ -53,7 +54,8 @@ class FacebookNotificationService(BaseNotificationService):
|
|||||||
import json
|
import json
|
||||||
resp = requests.post(BASE_URL, data=json.dumps(body),
|
resp = requests.post(BASE_URL, data=json.dumps(body),
|
||||||
params=payload,
|
params=payload,
|
||||||
headers={'Content-Type': 'application/json'})
|
headers={'Content-Type': CONTENT_TYPE_JSON},
|
||||||
|
timeout=10)
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
obj = resp.json()
|
obj = resp.json()
|
||||||
error_message = obj['error']['message']
|
error_message = obj['error']['message']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user