Timeout and Constant added

This commit is contained in:
Gopal 2017-01-04 18:23:29 +05:30
parent e89aa6b2d6
commit d09dcc4b03

View File

@ -13,6 +13,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.notify import (
ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService)
from homeassistant.const import CONTENT_TYPE_JSON
_LOGGER = logging.getLogger(__name__)
@ -42,7 +43,7 @@ class FacebookNotificationService(BaseNotificationService):
targets = kwargs.get(ATTR_TARGET)
if not targets:
_LOGGER.info("At least 1 target is required")
_LOGGER.error("At least 1 target is required")
return
for target in targets:
@ -53,7 +54,8 @@ class FacebookNotificationService(BaseNotificationService):
import json
resp = requests.post(BASE_URL, data=json.dumps(body),
params=payload,
headers={'Content-Type': 'application/json'})
headers={'Content-Type': CONTENT_TYPE_JSON},
timeout=10)
if resp.status_code != 200:
obj = resp.json()
error_message = obj['error']['message']