mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
commit
758aed07e8
@ -28,7 +28,7 @@ from homeassistant.const import (
|
|||||||
CONF_PASSWORD, CONF_PORT, CONF_PROTOCOL, CONF_PAYLOAD)
|
CONF_PASSWORD, CONF_PORT, CONF_PROTOCOL, CONF_PAYLOAD)
|
||||||
from homeassistant.components.mqtt.server import HBMQTT_CONFIG_SCHEMA
|
from homeassistant.components.mqtt.server import HBMQTT_CONFIG_SCHEMA
|
||||||
|
|
||||||
REQUIREMENTS = ['paho-mqtt==1.2.2']
|
REQUIREMENTS = ['paho-mqtt==1.2.3']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -246,8 +246,8 @@ class Recorder(threading.Thread):
|
|||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if ATTR_ENTITY_ID in event.data:
|
entity_id = event.data.get(ATTR_ENTITY_ID)
|
||||||
entity_id = event.data[ATTR_ENTITY_ID]
|
if entity_id is not None:
|
||||||
domain = split_entity_id(entity_id)[0]
|
domain = split_entity_id(entity_id)[0]
|
||||||
|
|
||||||
# Exclude entities OR
|
# Exclude entities OR
|
||||||
|
@ -47,7 +47,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
data={
|
data={
|
||||||
'username': username,
|
'username': username,
|
||||||
'password': password})
|
'password': password})
|
||||||
data = yield from response.json()
|
# The Hook API returns JSON but calls it 'text/html'. Setting
|
||||||
|
# content_type=None disables aiohttp's content-type validation.
|
||||||
|
data = yield from response.json(content_type=None)
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
||||||
_LOGGER.error("Failed authentication API call: %s", error)
|
_LOGGER.error("Failed authentication API call: %s", error)
|
||||||
return False
|
return False
|
||||||
@ -63,7 +65,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
response = yield from websession.get(
|
response = yield from websession.get(
|
||||||
'{}{}'.format(HOOK_ENDPOINT, 'device'),
|
'{}{}'.format(HOOK_ENDPOINT, 'device'),
|
||||||
params={"token": token})
|
params={"token": token})
|
||||||
data = yield from response.json()
|
data = yield from response.json(content_type=None)
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
||||||
_LOGGER.error("Failed getting devices: %s", error)
|
_LOGGER.error("Failed getting devices: %s", error)
|
||||||
return False
|
return False
|
||||||
@ -110,7 +112,7 @@ class HookSmartHome(SwitchDevice):
|
|||||||
with async_timeout.timeout(TIMEOUT, loop=self.hass.loop):
|
with async_timeout.timeout(TIMEOUT, loop=self.hass.loop):
|
||||||
response = yield from websession.get(
|
response = yield from websession.get(
|
||||||
url, params={"token": self._token})
|
url, params={"token": self._token})
|
||||||
data = yield from response.json()
|
data = yield from response.json(content_type=None)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
||||||
_LOGGER.error("Failed setting state: %s", error)
|
_LOGGER.error("Failed setting state: %s", error)
|
||||||
|
@ -76,6 +76,8 @@ class WemoSwitch(SwitchDevice):
|
|||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""No polling needed with subscriptions."""
|
"""No polling needed with subscriptions."""
|
||||||
|
if self._model_name == 'Insight':
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -50,7 +50,7 @@ def async_setup(hass, config):
|
|||||||
_LOGGER.error("Unknown notification service specified")
|
_LOGGER.error("Unknown notification service specified")
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.info("Setting up1 %s.%s", DOMAIN, p_type)
|
_LOGGER.info("Setting up %s.%s", DOMAIN, p_type)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if hasattr(platform, 'async_setup_platform'):
|
if hasattr(platform, 'async_setup_platform'):
|
||||||
@ -73,8 +73,6 @@ def async_setup(hass, config):
|
|||||||
_LOGGER.exception('Error setting up platform %s', p_type)
|
_LOGGER.exception('Error setting up platform %s', p_type)
|
||||||
return
|
return
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
setup_tasks = [async_setup_platform(p_type, p_config) for p_type, p_config
|
setup_tasks = [async_setup_platform(p_type, p_config) for p_type, p_config
|
||||||
in config_per_platform(config, DOMAIN)]
|
in config_per_platform(config, DOMAIN)]
|
||||||
|
|
||||||
@ -103,10 +101,10 @@ class BaseTelegramBotEntity:
|
|||||||
"""Check for basic message rules and fire an event if message is ok."""
|
"""Check for basic message rules and fire an event if message is ok."""
|
||||||
data = data.get('message')
|
data = data.get('message')
|
||||||
|
|
||||||
if (not data
|
if (not data or
|
||||||
or 'from' not in data
|
'from' not in data or
|
||||||
or 'text' not in data
|
'text' not in data or
|
||||||
or data['from'].get('id') not in self.allowed_chat_ids):
|
data['from'].get('id') not in self.allowed_chat_ids):
|
||||||
# Message is not correct.
|
# Message is not correct.
|
||||||
_LOGGER.error("Incoming message does not have required data.")
|
_LOGGER.error("Incoming message does not have required data.")
|
||||||
return False
|
return False
|
||||||
|
@ -11,9 +11,8 @@ from ipaddress import ip_network
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED)
|
EVENT_HOMEASSISTANT_STOP, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.components.telegram_bot import CONF_ALLOWED_CHAT_IDS, \
|
from homeassistant.components.telegram_bot import CONF_ALLOWED_CHAT_IDS, \
|
||||||
@ -27,6 +26,7 @@ REQUIREMENTS = ['python-telegram-bot==5.3.0']
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
TELEGRAM_HANDLER_URL = '/api/telegram_webhooks'
|
TELEGRAM_HANDLER_URL = '/api/telegram_webhooks'
|
||||||
|
REMOVE_HANDLER_URL = ''
|
||||||
|
|
||||||
CONF_TRUSTED_NETWORKS = 'trusted_networks'
|
CONF_TRUSTED_NETWORKS = 'trusted_networks'
|
||||||
DEFAULT_TRUSTED_NETWORKS = [
|
DEFAULT_TRUSTED_NETWORKS = [
|
||||||
@ -50,20 +50,21 @@ def setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
bot = telegram.Bot(config[CONF_API_KEY])
|
bot = telegram.Bot(config[CONF_API_KEY])
|
||||||
|
|
||||||
current_status = bot.getWebhookInfo()
|
current_status = bot.getWebhookInfo()
|
||||||
handler_url = "{0}{1}".format(hass.config.api.base_url,
|
handler_url = '{0}{1}'.format(
|
||||||
TELEGRAM_HANDLER_URL)
|
hass.config.api.base_url, TELEGRAM_HANDLER_URL)
|
||||||
if current_status and current_status['url'] != handler_url:
|
if current_status and current_status['url'] != handler_url:
|
||||||
if bot.setWebhook(handler_url):
|
if bot.setWebhook(handler_url):
|
||||||
_LOGGER.info("set new telegram webhook %s", handler_url)
|
_LOGGER.info("set new telegram webhook %s", handler_url)
|
||||||
|
|
||||||
hass.http.register_view(
|
|
||||||
BotPushReceiver(
|
|
||||||
hass,
|
|
||||||
config[CONF_ALLOWED_CHAT_IDS],
|
|
||||||
config[CONF_TRUSTED_NETWORKS]))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("set telegram webhook failed %s", handler_url)
|
_LOGGER.error("set telegram webhook failed %s", handler_url)
|
||||||
|
return False
|
||||||
|
|
||||||
|
hass.bus.listen_once(
|
||||||
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
lambda event: bot.setWebhook(REMOVE_HANDLER_URL))
|
||||||
|
hass.http.register_view(BotPushReceiver(
|
||||||
|
hass, config[CONF_ALLOWED_CHAT_IDS], config[CONF_TRUSTED_NETWORKS]))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class BotPushReceiver(HomeAssistantView, BaseTelegramBotEntity):
|
class BotPushReceiver(HomeAssistantView, BaseTelegramBotEntity):
|
||||||
@ -71,7 +72,7 @@ class BotPushReceiver(HomeAssistantView, BaseTelegramBotEntity):
|
|||||||
|
|
||||||
requires_auth = False
|
requires_auth = False
|
||||||
url = TELEGRAM_HANDLER_URL
|
url = TELEGRAM_HANDLER_URL
|
||||||
name = "telegram_webhooks"
|
name = 'telegram_webhooks'
|
||||||
|
|
||||||
def __init__(self, hass, allowed_chat_ids, trusted_networks):
|
def __init__(self, hass, allowed_chat_ids, trusted_networks):
|
||||||
"""Initialize the class."""
|
"""Initialize the class."""
|
||||||
|
@ -14,7 +14,7 @@ from homeassistant.helpers import config_validation as cv
|
|||||||
|
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
|
|
||||||
REQUIREMENTS = ['pywemo==0.4.18']
|
REQUIREMENTS = ['pywemo==0.4.19']
|
||||||
|
|
||||||
DOMAIN = 'wemo'
|
DOMAIN = 'wemo'
|
||||||
|
|
||||||
|
@ -81,12 +81,12 @@ DISCOVERY_SCHEMAS = [
|
|||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_SWITCH_MULTILEVEL],
|
const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_SWITCH_MULTILEVEL],
|
||||||
const.DISC_LABEL: ['Open', 'Up'],
|
const.DISC_LABEL: ['Open', 'Up', 'Bright'],
|
||||||
const.DISC_OPTIONAL: True,
|
const.DISC_OPTIONAL: True,
|
||||||
},
|
},
|
||||||
'close': {
|
'close': {
|
||||||
const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_SWITCH_MULTILEVEL],
|
const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_SWITCH_MULTILEVEL],
|
||||||
const.DISC_LABEL: ['Close', 'Down'],
|
const.DISC_LABEL: ['Close', 'Down', 'Dim'],
|
||||||
const.DISC_OPTIONAL: True,
|
const.DISC_OPTIONAL: True,
|
||||||
}})},
|
}})},
|
||||||
{const.DISC_COMPONENT: 'cover', # Garage Door
|
{const.DISC_COMPONENT: 'cover', # Garage Door
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""Constants used by Home Assistant components."""
|
"""Constants used by Home Assistant components."""
|
||||||
MAJOR_VERSION = 0
|
MAJOR_VERSION = 0
|
||||||
MINOR_VERSION = 43
|
MINOR_VERSION = 43
|
||||||
PATCH_VERSION = '0'
|
PATCH_VERSION = '1'
|
||||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||||
REQUIRED_PYTHON_VER = (3, 4, 2)
|
REQUIRED_PYTHON_VER = (3, 4, 2)
|
||||||
|
@ -419,7 +419,7 @@ openhomedevice==0.2.1
|
|||||||
orvibo==1.1.1
|
orvibo==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.mqtt
|
# homeassistant.components.mqtt
|
||||||
paho-mqtt==1.2.2
|
paho-mqtt==1.2.3
|
||||||
|
|
||||||
# homeassistant.components.media_player.panasonic_viera
|
# homeassistant.components.media_player.panasonic_viera
|
||||||
panasonic_viera==0.2
|
panasonic_viera==0.2
|
||||||
@ -678,7 +678,7 @@ pyvera==0.2.26
|
|||||||
pywebpush==0.6.1
|
pywebpush==0.6.1
|
||||||
|
|
||||||
# homeassistant.components.wemo
|
# homeassistant.components.wemo
|
||||||
pywemo==0.4.18
|
pywemo==0.4.19
|
||||||
|
|
||||||
# homeassistant.components.zabbix
|
# homeassistant.components.zabbix
|
||||||
pyzabbix==0.7.4
|
pyzabbix==0.7.4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user