From e01c36c906427f469797cdc7a21d82cc873a06b2 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 24 Apr 2017 20:34:56 -0700 Subject: [PATCH 1/7] Version bump to 0.43.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 5cc08642299..52d5f5abcde 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 43 -PATCH_VERSION = '0' +PATCH_VERSION = '1' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2) From 79c6467797c6b4b462934d3d77defe9b79b1484d Mon Sep 17 00:00:00 2001 From: John Arild Berentsen Date: Sat, 22 Apr 2017 16:23:39 +0200 Subject: [PATCH 2/7] Zwave cover workaround for graber shades. (#7204) * wierd pylint complaint * Workaround for Graber csz1 shades * logging * Try direct * Try direct * Use workaround * Review changes and tests * test * reset test * Use Bright and Dim also as open and close is --- homeassistant/components/zwave/discovery_schemas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zwave/discovery_schemas.py b/homeassistant/components/zwave/discovery_schemas.py index f6e56ce79c8..17c37556aea 100644 --- a/homeassistant/components/zwave/discovery_schemas.py +++ b/homeassistant/components/zwave/discovery_schemas.py @@ -81,12 +81,12 @@ DISCOVERY_SCHEMAS = [ }, 'open': { const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_SWITCH_MULTILEVEL], - const.DISC_LABEL: ['Open', 'Up'], + const.DISC_LABEL: ['Open', 'Up', 'Bright'], const.DISC_OPTIONAL: True, }, 'close': { 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_COMPONENT: 'cover', # Garage Door From c8404cb29999284cc4c1e6a49f865f956b9a38e0 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 23 Apr 2017 09:25:34 +0200 Subject: [PATCH 3/7] Upgrade paho-mqtt to 1.2.3 (#7214) --- homeassistant/components/mqtt/__init__.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 2b6774939da..458c5952a69 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -28,7 +28,7 @@ from homeassistant.const import ( CONF_PASSWORD, CONF_PORT, CONF_PROTOCOL, CONF_PAYLOAD) 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__) diff --git a/requirements_all.txt b/requirements_all.txt index e98df3bf99b..c6d14431017 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -419,7 +419,7 @@ openhomedevice==0.2.1 orvibo==1.1.1 # homeassistant.components.mqtt -paho-mqtt==1.2.2 +paho-mqtt==1.2.3 # homeassistant.components.media_player.panasonic_viera panasonic_viera==0.2 From 6c594e20f6465f151d833af96f7926a13e9222cd Mon Sep 17 00:00:00 2001 From: Greg Dowling Date: Mon, 24 Apr 2017 07:18:43 +0100 Subject: [PATCH 4/7] Workround for wemo subscription bug. (#7245) --- homeassistant/components/switch/wemo.py | 2 ++ homeassistant/components/wemo.py | 2 +- requirements_all.txt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index c92523ad705..700d9d25b5a 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -76,6 +76,8 @@ class WemoSwitch(SwitchDevice): @property def should_poll(self): """No polling needed with subscriptions.""" + if self._model_name == 'Insight': + return True return False @property diff --git a/homeassistant/components/wemo.py b/homeassistant/components/wemo.py index a4b6674af74..98eefbc42d8 100644 --- a/homeassistant/components/wemo.py +++ b/homeassistant/components/wemo.py @@ -14,7 +14,7 @@ from homeassistant.helpers import config_validation as cv from homeassistant.const import EVENT_HOMEASSISTANT_STOP -REQUIREMENTS = ['pywemo==0.4.18'] +REQUIREMENTS = ['pywemo==0.4.19'] DOMAIN = 'wemo' diff --git a/requirements_all.txt b/requirements_all.txt index c6d14431017..461423f1ce7 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -678,7 +678,7 @@ pyvera==0.2.26 pywebpush==0.6.1 # homeassistant.components.wemo -pywemo==0.4.18 +pywemo==0.4.19 # homeassistant.components.zabbix pyzabbix==0.7.4 From 1b55dbeb44d6b9c1a02cbe3238db577fb02140b4 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Mon, 24 Apr 2017 08:20:04 +0200 Subject: [PATCH 5/7] Fix telegram webhooks (#7236) * Always register the view if a webhook exists. * Return True if platform is set up succesfully, False otherwise. * Remove the webhook when home assistant stops. Webhooks and long polling are mutually excklusive. If a webhook is left after home assistant is stopped, a polling telegram bot is unable to be set up, on next start of home assistant. --- .../components/telegram_bot/__init__.py | 12 ++++----- .../components/telegram_bot/webhooks.py | 25 ++++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index 92a87153d99..1cd77491c51 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -50,7 +50,7 @@ def async_setup(hass, config): _LOGGER.error("Unknown notification service specified") return - _LOGGER.info("Setting up1 %s.%s", DOMAIN, p_type) + _LOGGER.info("Setting up %s.%s", DOMAIN, p_type) try: if hasattr(platform, 'async_setup_platform'): @@ -73,8 +73,6 @@ def async_setup(hass, config): _LOGGER.exception('Error setting up platform %s', p_type) return - return True - setup_tasks = [async_setup_platform(p_type, p_config) for p_type, p_config 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.""" data = data.get('message') - if (not data - or 'from' not in data - or 'text' not in data - or data['from'].get('id') not in self.allowed_chat_ids): + if (not data or + 'from' not in data or + 'text' not in data or + data['from'].get('id') not in self.allowed_chat_ids): # Message is not correct. _LOGGER.error("Incoming message does not have required data.") return False diff --git a/homeassistant/components/telegram_bot/webhooks.py b/homeassistant/components/telegram_bot/webhooks.py index 3ffc03780bd..9fddf18d278 100644 --- a/homeassistant/components/telegram_bot/webhooks.py +++ b/homeassistant/components/telegram_bot/webhooks.py @@ -11,9 +11,8 @@ from ipaddress import ip_network import voluptuous as vol - from homeassistant.const import ( - HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED) + EVENT_HOMEASSISTANT_STOP, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED) import homeassistant.helpers.config_validation as cv from homeassistant.components.http import HomeAssistantView 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__) TELEGRAM_HANDLER_URL = '/api/telegram_webhooks' +REMOVE_HANDLER_URL = '' CONF_TRUSTED_NETWORKS = '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]) current_status = bot.getWebhookInfo() - handler_url = "{0}{1}".format(hass.config.api.base_url, - TELEGRAM_HANDLER_URL) + handler_url = '{0}{1}'.format( + hass.config.api.base_url, TELEGRAM_HANDLER_URL) if current_status and current_status['url'] != handler_url: if bot.setWebhook(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: _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): @@ -71,7 +72,7 @@ class BotPushReceiver(HomeAssistantView, BaseTelegramBotEntity): requires_auth = False url = TELEGRAM_HANDLER_URL - name = "telegram_webhooks" + name = 'telegram_webhooks' def __init__(self, hass, allowed_chat_ids, trusted_networks): """Initialize the class.""" From 41a803a7be07dea4358a641618ae91ed38c3ec32 Mon Sep 17 00:00:00 2001 From: Klaas Hoekema Date: Mon, 24 Apr 2017 02:58:17 -0400 Subject: [PATCH 6/7] Work around bad content-type in Hook api response (#7267) --- homeassistant/components/switch/hook.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/switch/hook.py b/homeassistant/components/switch/hook.py index 58d3813f6fa..00fb7fdd909 100644 --- a/homeassistant/components/switch/hook.py +++ b/homeassistant/components/switch/hook.py @@ -47,7 +47,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): data={ 'username': username, '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: _LOGGER.error("Failed authentication API call: %s", error) return False @@ -63,7 +65,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): response = yield from websession.get( '{}{}'.format(HOOK_ENDPOINT, 'device'), params={"token": token}) - data = yield from response.json() + data = yield from response.json(content_type=None) except (asyncio.TimeoutError, aiohttp.ClientError) as error: _LOGGER.error("Failed getting devices: %s", error) return False @@ -110,7 +112,7 @@ class HookSmartHome(SwitchDevice): with async_timeout.timeout(TIMEOUT, loop=self.hass.loop): response = yield from websession.get( 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: _LOGGER.error("Failed setting state: %s", error) From 166bcc06875a09c6bbe9b687492776d97afa2f94 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 24 Apr 2017 20:51:03 -0700 Subject: [PATCH 7/7] Recorder: Check for ENTITY_ID key that contains None value (#7287) --- homeassistant/components/recorder/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index 7e31523f7d1..04322646f80 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -246,8 +246,8 @@ class Recorder(threading.Thread): self.queue.task_done() continue - if ATTR_ENTITY_ID in event.data: - entity_id = event.data[ATTR_ENTITY_ID] + entity_id = event.data.get(ATTR_ENTITY_ID) + if entity_id is not None: domain = split_entity_id(entity_id)[0] # Exclude entities OR