From afc70fda5044025bf4e35971b69ed31ab8961094 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 2 Nov 2018 12:31:45 +0100 Subject: [PATCH 01/13] Bump frontend to 20181026.2 --- homeassistant/components/frontend/__init__.py | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index d2b671df8b0..05c178765ef 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -24,7 +24,7 @@ from homeassistant.core import callback from homeassistant.helpers.translation import async_get_translations from homeassistant.loader import bind_hass -REQUIREMENTS = ['home-assistant-frontend==20181026.1'] +REQUIREMENTS = ['home-assistant-frontend==20181026.2'] DOMAIN = 'frontend' DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log', diff --git a/requirements_all.txt b/requirements_all.txt index caaadd4c6f0..9d69fd41cf4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -466,7 +466,7 @@ hole==0.3.0 holidays==0.9.8 # homeassistant.components.frontend -home-assistant-frontend==20181026.1 +home-assistant-frontend==20181026.2 # homeassistant.components.homekit_controller # homekit==0.10 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index d7a7c761b4b..5b9574fb35f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -97,7 +97,7 @@ hdate==0.6.5 holidays==0.9.8 # homeassistant.components.frontend -home-assistant-frontend==20181026.1 +home-assistant-frontend==20181026.2 # homeassistant.components.homematicip_cloud homematicip==0.9.8 From 5910161202bec39bc62c6d047d5445603b34d7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Hellstr=C3=B6m?= Date: Tue, 30 Oct 2018 10:44:07 +0100 Subject: [PATCH 02/13] fix naming bug (#17976) --- homeassistant/components/weather/smhi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/weather/smhi.py b/homeassistant/components/weather/smhi.py index 3bbaab3f8ec..41ac1571339 100644 --- a/homeassistant/components/weather/smhi.py +++ b/homeassistant/components/weather/smhi.py @@ -19,7 +19,7 @@ from homeassistant.const import ( CONF_NAME, TEMP_CELSIUS) from homeassistant.core import HomeAssistant from homeassistant.helpers import aiohttp_client -from homeassistant.util import dt, Throttle +from homeassistant.util import dt, slugify, Throttle from homeassistant.components.weather import ( WeatherEntity, ATTR_FORECAST_CONDITION, ATTR_FORECAST_TEMP, @@ -73,11 +73,11 @@ async def async_setup_entry(hass: HomeAssistant, config_entries) -> bool: """Add a weather entity from map location.""" location = config_entry.data - name = location[CONF_NAME] + name = slugify(location[CONF_NAME]) session = aiohttp_client.async_get_clientsession(hass) - entity = SmhiWeather(name, location[CONF_LATITUDE], + entity = SmhiWeather(location[CONF_NAME], location[CONF_LATITUDE], location[CONF_LONGITUDE], session=session) entity.entity_id = ENTITY_ID_SENSOR_FORMAT.format(name) From 6f8ac7f5c9669810ca5d63662b118b70190793cc Mon Sep 17 00:00:00 2001 From: Nate Clark Date: Wed, 31 Oct 2018 02:42:33 -0400 Subject: [PATCH 03/13] Konnected: Pass hass_config to load_platform (#18027) --- homeassistant/components/konnected.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/konnected.py b/homeassistant/components/konnected.py index 21e2fbba4c7..a6fe4be65fa 100644 --- a/homeassistant/components/konnected.py +++ b/homeassistant/components/konnected.py @@ -156,7 +156,7 @@ async def async_setup(hass, config): # Initialize devices specified in the configuration on boot for device in cfg.get(CONF_DEVICES): - ConfiguredDevice(hass, device).save_data() + ConfiguredDevice(hass, device, config).save_data() discovery.async_listen( hass, @@ -172,10 +172,11 @@ async def async_setup(hass, config): class ConfiguredDevice: """A representation of a configured Konnected device.""" - def __init__(self, hass, config): + def __init__(self, hass, config, hass_config): """Initialize the Konnected device.""" self.hass = hass self.config = config + self.hass_config = hass_config @property def device_id(self): @@ -237,11 +238,11 @@ class ConfiguredDevice: self.hass.data[DOMAIN][CONF_DEVICES][self.device_id] = device_data discovery.load_platform( - self.hass, 'binary_sensor', - DOMAIN, {'device_id': self.device_id}) + self.hass, 'binary_sensor', DOMAIN, + {'device_id': self.device_id}, self.hass_config) discovery.load_platform( self.hass, 'switch', DOMAIN, - {'device_id': self.device_id}) + {'device_id': self.device_id}, self.hass_config) class DiscoveredDevice: From 602b59aed886ab3b99b50db868feda880d44e00a Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Wed, 31 Oct 2018 04:52:21 -0700 Subject: [PATCH 04/13] Change cv.string to [cv.string] (#18050) --- homeassistant/components/nest/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/nest/__init__.py b/homeassistant/components/nest/__init__.py index c66abf1a8bd..bb0e6247de3 100644 --- a/homeassistant/components/nest/__init__.py +++ b/homeassistant/components/nest/__init__.py @@ -55,7 +55,7 @@ SENSOR_SCHEMA = vol.Schema({ AWAY_SCHEMA = vol.Schema({ vol.Required(ATTR_HOME_MODE): vol.In([HOME_MODE_AWAY, HOME_MODE_HOME]), - vol.Optional(ATTR_STRUCTURE): vol.All(cv.ensure_list, cv.string), + vol.Optional(ATTR_STRUCTURE): vol.All(cv.ensure_list, [cv.string]), vol.Optional(ATTR_TRIP_ID): cv.string, vol.Optional(ATTR_ETA): cv.time_period, vol.Optional(ATTR_ETA_WINDOW): cv.time_period @@ -65,7 +65,7 @@ CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Required(CONF_CLIENT_ID): cv.string, vol.Required(CONF_CLIENT_SECRET): cv.string, - vol.Optional(CONF_STRUCTURE): vol.All(cv.ensure_list, cv.string), + vol.Optional(CONF_STRUCTURE): vol.All(cv.ensure_list, [cv.string]), vol.Optional(CONF_SENSORS): SENSOR_SCHEMA, vol.Optional(CONF_BINARY_SENSORS): SENSOR_SCHEMA }) From 5a802c1069a8a142f5e1cbac9d5d6db13e46c260 Mon Sep 17 00:00:00 2001 From: cdce8p <30130371+cdce8p@users.noreply.github.com> Date: Thu, 1 Nov 2018 19:35:02 +0100 Subject: [PATCH 05/13] Revert HomeKit update to 2.2.2 (#18069) --- homeassistant/components/homekit/__init__.py | 2 +- homeassistant/components/homekit/type_switches.py | 7 +++++-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/homekit/test_type_locks.py | 1 - tests/components/homekit/test_type_media_players.py | 1 - 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index d4d8fe0216c..1c30de918e3 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -29,7 +29,7 @@ from .const import ( from .util import ( show_setup_message, validate_entity_config, validate_media_player_features) -REQUIREMENTS = ['HAP-python==2.3.0'] +REQUIREMENTS = ['HAP-python==2.2.2'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/homekit/type_switches.py b/homeassistant/components/homekit/type_switches.py index 839abe5a580..288da65a4af 100644 --- a/homeassistant/components/homekit/type_switches.py +++ b/homeassistant/components/homekit/type_switches.py @@ -2,8 +2,7 @@ import logging from pyhap.const import ( - CATEGORY_FAUCET, CATEGORY_OUTLET, CATEGORY_SHOWER_HEAD, - CATEGORY_SPRINKLER, CATEGORY_SWITCH) + CATEGORY_OUTLET, CATEGORY_SWITCH) from homeassistant.components.switch import DOMAIN from homeassistant.const import ( @@ -19,6 +18,10 @@ from .const import ( _LOGGER = logging.getLogger(__name__) +CATEGORY_SPRINKLER = 28 +CATEGORY_FAUCET = 29 +CATEGORY_SHOWER_HEAD = 30 + VALVE_TYPE = { TYPE_FAUCET: (CATEGORY_FAUCET, 3), TYPE_SHOWER: (CATEGORY_SHOWER_HEAD, 2), diff --git a/requirements_all.txt b/requirements_all.txt index 9d69fd41cf4..427bed112d3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -34,7 +34,7 @@ Adafruit-SHT31==1.0.2 DoorBirdPy==0.1.3 # homeassistant.components.homekit -HAP-python==2.3.0 +HAP-python==2.2.2 # homeassistant.components.notify.mastodon Mastodon.py==1.3.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 5b9574fb35f..24304103050 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -19,7 +19,7 @@ requests_mock==1.5.2 # homeassistant.components.homekit -HAP-python==2.3.0 +HAP-python==2.2.2 # homeassistant.components.sensor.rmvtransport PyRMVtransport==0.1.3 diff --git a/tests/components/homekit/test_type_locks.py b/tests/components/homekit/test_type_locks.py index 8132099bd3e..e7e52c65559 100644 --- a/tests/components/homekit/test_type_locks.py +++ b/tests/components/homekit/test_type_locks.py @@ -82,7 +82,6 @@ async def test_no_code(hass, hk_driver, config, events): # Set from HomeKit call_lock = async_mock_service(hass, DOMAIN, 'lock') - acc.char_target_state.value = 0 await hass.async_add_job(acc.char_target_state.client_update_value, 1) await hass.async_block_till_done() assert call_lock diff --git a/tests/components/homekit/test_type_media_players.py b/tests/components/homekit/test_type_media_players.py index 745e4c162bc..6b23b3cc58e 100644 --- a/tests/components/homekit/test_type_media_players.py +++ b/tests/components/homekit/test_type_media_players.py @@ -64,7 +64,6 @@ async def test_media_player_set_state(hass, hk_driver, events): call_media_stop = async_mock_service(hass, DOMAIN, 'media_stop') call_toggle_mute = async_mock_service(hass, DOMAIN, 'volume_mute') - acc.chars[FEATURE_ON_OFF].value = False await hass.async_add_job(acc.chars[FEATURE_ON_OFF] .client_update_value, True) await hass.async_block_till_done() From dce6a9f88279191c22555d44e9ae0bd49ef15335 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Fri, 2 Nov 2018 12:32:41 +0100 Subject: [PATCH 06/13] Fix time zone for flux switch (#18102) --- homeassistant/components/switch/flux.py | 10 ++-- tests/components/switch/test_flux.py | 64 ++++++++++++------------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/switch/flux.py b/homeassistant/components/switch/flux.py index 00388822be1..b7585588f0a 100644 --- a/homeassistant/components/switch/flux.py +++ b/homeassistant/components/switch/flux.py @@ -25,7 +25,7 @@ from homeassistant.util import slugify from homeassistant.util.color import ( color_temperature_to_rgb, color_RGB_to_xy_brightness, color_temperature_kelvin_to_mired) -from homeassistant.util.dt import now as dt_now +from homeassistant.util.dt import utcnow as dt_utcnow, as_local _LOGGER = logging.getLogger(__name__) @@ -195,10 +195,12 @@ class FluxSwitch(SwitchDevice): self.schedule_update_ha_state() - def flux_update(self, now=None): + def flux_update(self, utcnow=None): """Update all the lights using flux.""" - if now is None: - now = dt_now() + if utcnow is None: + utcnow = dt_utcnow() + + now = as_local(utcnow) sunset = get_astral_event_date(self.hass, 'sunset', now.date()) start_time = self.find_start_time(now) diff --git a/tests/components/switch/test_flux.py b/tests/components/switch/test_flux.py index cb5207adb3e..34b37639cd1 100644 --- a/tests/components/switch/test_flux.py +++ b/tests/components/switch/test_flux.py @@ -87,7 +87,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=10, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=10, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -96,7 +96,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.util.dt.now', return_value=test_time): + with patch('homeassistant.util.dt.utcnow', return_value=test_time): with patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): assert setup_component(self.hass, switch.DOMAIN, { @@ -128,7 +128,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=2, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=2, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -137,7 +137,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.util.dt.now', return_value=test_time): + with patch('homeassistant.util.dt.utcnow', return_value=test_time): with patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): assert setup_component(self.hass, switch.DOMAIN, { @@ -174,7 +174,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=8, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -183,7 +183,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -221,7 +221,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=17, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -230,7 +230,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -269,7 +269,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=23, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=23, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -278,7 +278,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.util.dt.now', return_value=test_time): + with patch('homeassistant.util.dt.utcnow', return_value=test_time): with patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): assert setup_component(self.hass, switch.DOMAIN, { @@ -315,7 +315,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=17, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -324,7 +324,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -366,7 +366,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=2, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=2, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -375,7 +375,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -418,7 +418,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=8, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -427,7 +427,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -469,7 +469,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=23, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=23, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -478,7 +478,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.util.dt.now', return_value=test_time): + with patch('homeassistant.util.dt.utcnow', return_value=test_time): with patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): assert setup_component(self.hass, switch.DOMAIN, { @@ -519,7 +519,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=00, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=00, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -528,7 +528,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -570,7 +570,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=2, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=2, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -579,7 +579,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -618,7 +618,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=17, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -627,7 +627,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -668,7 +668,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=17, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -677,7 +677,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -729,7 +729,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertIsNone(state.attributes.get('xy_color')) self.assertIsNone(state.attributes.get('brightness')) - test_time = dt_util.now().replace(hour=12, minute=0, second=0) + test_time = dt_util.utcnow().replace(hour=12, minute=0, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -740,7 +740,7 @@ class TestSwitchFlux(unittest.TestCase): print('sunset {}'.format(sunset_time)) return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -784,7 +784,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertEqual(STATE_ON, state.state) self.assertIsNone(state.attributes.get('color_temp')) - test_time = dt_util.now().replace(hour=8, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -793,7 +793,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): @@ -829,7 +829,7 @@ class TestSwitchFlux(unittest.TestCase): self.assertEqual(STATE_ON, state.state) self.assertIsNone(state.attributes.get('color_temp')) - test_time = dt_util.now().replace(hour=8, minute=30, second=0) + test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0) sunset_time = test_time.replace(hour=17, minute=0, second=0) sunrise_time = test_time.replace(hour=5, minute=0, second=0) @@ -838,7 +838,7 @@ class TestSwitchFlux(unittest.TestCase): return sunrise_time return sunset_time - with patch('homeassistant.components.switch.flux.dt_now', + with patch('homeassistant.components.switch.flux.dt_utcnow', return_value=test_time), \ patch('homeassistant.helpers.sun.get_astral_event_date', side_effect=event_date): From 2e169320a4a841cc076180794f5b43895866e64c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 2 Nov 2018 12:33:02 +0100 Subject: [PATCH 07/13] Bumped version to 0.81.3 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 70d6eb18f1f..4c4ca84b7c7 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 81 -PATCH_VERSION = '2' +PATCH_VERSION = '3' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3) From 94f24e6d499528ea92898866b0c7e97027d41fa4 Mon Sep 17 00:00:00 2001 From: Diogo Gomes Date: Tue, 30 Oct 2018 20:25:12 +0000 Subject: [PATCH 08/13] Upgrade pyipma (#17992) * bump dependency version * Add more context to debug message Co-Authored-By: dgomes * shorten debug messages --- homeassistant/components/weather/ipma.py | 8 +++++--- requirements_all.txt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/weather/ipma.py b/homeassistant/components/weather/ipma.py index 02d94e47558..7fecfbcd074 100644 --- a/homeassistant/components/weather/ipma.py +++ b/homeassistant/components/weather/ipma.py @@ -20,7 +20,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers import config_validation as cv from homeassistant.util import Throttle -REQUIREMENTS = ['pyipma==1.1.3'] +REQUIREMENTS = ['pyipma==1.1.4'] _LOGGER = logging.getLogger(__name__) @@ -71,8 +71,8 @@ async def async_setup_platform(hass, config, async_add_entities, station = await Station.get(websession, float(latitude), float(longitude)) - _LOGGER.debug("Initializing ipma weather: coordinates %s, %s", - latitude, longitude) + _LOGGER.debug("Initializing for coordinates %s, %s -> station %s", + latitude, longitude, station.local) async_add_entities([IPMAWeather(station, config)], True) @@ -93,6 +93,8 @@ class IPMAWeather(WeatherEntity): """Update Condition and Forecast.""" with async_timeout.timeout(10, loop=self.hass.loop): self._condition = await self._station.observation() + _LOGGER.debug("Updating station %s, condition %s", + self._station.local, self._condition) self._forecast = await self._station.forecast() self._description = self._forecast[0].description diff --git a/requirements_all.txt b/requirements_all.txt index 427bed112d3..a2c53514dd6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -929,7 +929,7 @@ pyialarm==0.2 pyicloud==0.9.1 # homeassistant.components.weather.ipma -pyipma==1.1.3 +pyipma==1.1.4 # homeassistant.components.sensor.irish_rail_transport pyirishrail==0.0.2 From 1895e03874ad0225809fb5e5e267a32842a491a3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 2 Nov 2018 14:06:49 +0100 Subject: [PATCH 09/13] Frontend bump to 20181026.3 --- homeassistant/components/frontend/__init__.py | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index 05c178765ef..c669e804d9d 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -24,7 +24,7 @@ from homeassistant.core import callback from homeassistant.helpers.translation import async_get_translations from homeassistant.loader import bind_hass -REQUIREMENTS = ['home-assistant-frontend==20181026.2'] +REQUIREMENTS = ['home-assistant-frontend==20181026.3'] DOMAIN = 'frontend' DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log', diff --git a/requirements_all.txt b/requirements_all.txt index a2c53514dd6..018072210a4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -466,7 +466,7 @@ hole==0.3.0 holidays==0.9.8 # homeassistant.components.frontend -home-assistant-frontend==20181026.2 +home-assistant-frontend==20181026.3 # homeassistant.components.homekit_controller # homekit==0.10 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 24304103050..096884db304 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -97,7 +97,7 @@ hdate==0.6.5 holidays==0.9.8 # homeassistant.components.frontend -home-assistant-frontend==20181026.2 +home-assistant-frontend==20181026.3 # homeassistant.components.homematicip_cloud homematicip==0.9.8 From 91b7d56aa616d11dff55ea01c697bd41bdf85c86 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 2 Nov 2018 14:07:02 +0100 Subject: [PATCH 10/13] Bumped version to 0.81.4 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 4c4ca84b7c7..8133916a660 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 81 -PATCH_VERSION = '3' +PATCH_VERSION = '4' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3) From 73ed2ab16407f7817c3c76b099b8b7614d528b7a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 2 Nov 2018 20:09:12 +0100 Subject: [PATCH 11/13] bump frontend to 20181026.4 --- homeassistant/components/frontend/__init__.py | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index c669e804d9d..17fa7a249ee 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -24,7 +24,7 @@ from homeassistant.core import callback from homeassistant.helpers.translation import async_get_translations from homeassistant.loader import bind_hass -REQUIREMENTS = ['home-assistant-frontend==20181026.3'] +REQUIREMENTS = ['home-assistant-frontend==20181026.4'] DOMAIN = 'frontend' DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log', diff --git a/requirements_all.txt b/requirements_all.txt index 018072210a4..2ffd2ad6b21 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -466,7 +466,7 @@ hole==0.3.0 holidays==0.9.8 # homeassistant.components.frontend -home-assistant-frontend==20181026.3 +home-assistant-frontend==20181026.4 # homeassistant.components.homekit_controller # homekit==0.10 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 096884db304..e7d00f75799 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -97,7 +97,7 @@ hdate==0.6.5 holidays==0.9.8 # homeassistant.components.frontend -home-assistant-frontend==20181026.3 +home-assistant-frontend==20181026.4 # homeassistant.components.homematicip_cloud homematicip==0.9.8 From 255607f3a5325b93da09e099815aeeab6a1cf718 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Sat, 3 Nov 2018 06:36:22 -0500 Subject: [PATCH 12/13] Remove FFmpeg input tests (#18131) * Remove FFmpeg input tests * Not needed here * Removing tests for removed functionality * Minor lint * Fix tests to reflect removed config option * Remove async service registration by request * More lint * Unused imports * Make it a non-breaking change * Update ffmpeg.py --- .../components/binary_sensor/ffmpeg_motion.py | 4 - .../components/binary_sensor/ffmpeg_noise.py | 4 - homeassistant/components/camera/ffmpeg.py | 2 - homeassistant/components/camera/onvif.py | 7 +- homeassistant/components/ffmpeg.py | 31 +------ tests/components/binary_sensor/test_ffmpeg.py | 6 -- tests/components/test_ffmpeg.py | 88 +++---------------- 7 files changed, 15 insertions(+), 127 deletions(-) diff --git a/homeassistant/components/binary_sensor/ffmpeg_motion.py b/homeassistant/components/binary_sensor/ffmpeg_motion.py index df811d47e56..d0e597e13c0 100644 --- a/homeassistant/components/binary_sensor/ffmpeg_motion.py +++ b/homeassistant/components/binary_sensor/ffmpeg_motion.py @@ -49,10 +49,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the FFmpeg binary motion sensor.""" manager = hass.data[DATA_FFMPEG] - - if not await manager.async_run_test(config.get(CONF_INPUT)): - return - entity = FFmpegMotion(hass, manager, config) async_add_entities([entity]) diff --git a/homeassistant/components/binary_sensor/ffmpeg_noise.py b/homeassistant/components/binary_sensor/ffmpeg_noise.py index a2625c3de8d..3c2397d692b 100644 --- a/homeassistant/components/binary_sensor/ffmpeg_noise.py +++ b/homeassistant/components/binary_sensor/ffmpeg_noise.py @@ -46,10 +46,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the FFmpeg noise binary sensor.""" manager = hass.data[DATA_FFMPEG] - - if not await manager.async_run_test(config.get(CONF_INPUT)): - return - entity = FFmpegNoise(hass, manager, config) async_add_entities([entity]) diff --git a/homeassistant/components/camera/ffmpeg.py b/homeassistant/components/camera/ffmpeg.py index dfbcc4d70bc..6bd68b05bb5 100644 --- a/homeassistant/components/camera/ffmpeg.py +++ b/homeassistant/components/camera/ffmpeg.py @@ -32,8 +32,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up a FFmpeg camera.""" - if not await hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_INPUT)): - return async_add_entities([FFmpegCamera(hass, config)]) diff --git a/homeassistant/components/camera/onvif.py b/homeassistant/components/camera/onvif.py index 2576dfa7f92..722577fed39 100644 --- a/homeassistant/components/camera/onvif.py +++ b/homeassistant/components/camera/onvif.py @@ -74,9 +74,6 @@ SERVICE_PTZ_SCHEMA = vol.Schema({ def setup_platform(hass, config, add_entities, discovery_info=None): """Set up a ONVIF camera.""" - if not hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_HOST)): - return - def handle_ptz(service): """Handle PTZ service call.""" pan = service.data.get(ATTR_PAN, None) @@ -93,8 +90,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None): for camera in target_cameras: camera.perform_ptz(pan, tilt, zoom) - hass.services.async_register(DOMAIN, SERVICE_PTZ, handle_ptz, - schema=SERVICE_PTZ_SCHEMA) + hass.services.register(DOMAIN, SERVICE_PTZ, handle_ptz, + schema=SERVICE_PTZ_SCHEMA) add_entities([ONVIFHassCamera(hass, config)]) diff --git a/homeassistant/components/ffmpeg.py b/homeassistant/components/ffmpeg.py index f28dbd52336..791f6d29175 100644 --- a/homeassistant/components/ffmpeg.py +++ b/homeassistant/components/ffmpeg.py @@ -40,12 +40,11 @@ CONF_OUTPUT = 'output' CONF_RUN_TEST = 'run_test' DEFAULT_BINARY = 'ffmpeg' -DEFAULT_RUN_TEST = True CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Optional(CONF_FFMPEG_BIN, default=DEFAULT_BINARY): cv.string, - vol.Optional(CONF_RUN_TEST, default=DEFAULT_RUN_TEST): cv.boolean, + vol.Optional(CONF_RUN_TEST): cv.boolean, }), }, extra=vol.ALLOW_EXTRA) @@ -60,8 +59,7 @@ async def async_setup(hass, config): manager = FFmpegManager( hass, - conf.get(CONF_FFMPEG_BIN, DEFAULT_BINARY), - conf.get(CONF_RUN_TEST, DEFAULT_RUN_TEST) + conf.get(CONF_FFMPEG_BIN, DEFAULT_BINARY) ) # Register service @@ -95,40 +93,17 @@ async def async_setup(hass, config): class FFmpegManager: """Helper for ha-ffmpeg.""" - def __init__(self, hass, ffmpeg_bin, run_test): + def __init__(self, hass, ffmpeg_bin): """Initialize helper.""" self.hass = hass self._cache = {} self._bin = ffmpeg_bin - self._run_test = run_test @property def binary(self): """Return ffmpeg binary from config.""" return self._bin - async def async_run_test(self, input_source): - """Run test on this input. TRUE is deactivate or run correct. - - This method must be run in the event loop. - """ - from haffmpeg import Test - - if self._run_test: - # if in cache - if input_source in self._cache: - return self._cache[input_source] - - # run test - ffmpeg_test = Test(self.binary, loop=self.hass.loop) - success = await ffmpeg_test.run_test(input_source) - if not success: - _LOGGER.error("FFmpeg '%s' test fails!", input_source) - self._cache[input_source] = False - return False - self._cache[input_source] = True - return True - class FFmpegBase(Entity): """Interface object for FFmpeg.""" diff --git a/tests/components/binary_sensor/test_ffmpeg.py b/tests/components/binary_sensor/test_ffmpeg.py index 4e6629c0afd..2c17207af32 100644 --- a/tests/components/binary_sensor/test_ffmpeg.py +++ b/tests/components/binary_sensor/test_ffmpeg.py @@ -15,9 +15,6 @@ class TestFFmpegNoiseSetup: self.hass = get_test_home_assistant() self.config = { - 'ffmpeg': { - 'run_test': False, - }, 'binary_sensor': { 'platform': 'ffmpeg_noise', 'input': 'testinputvideo', @@ -80,9 +77,6 @@ class TestFFmpegMotionSetup: self.hass = get_test_home_assistant() self.config = { - 'ffmpeg': { - 'run_test': False, - }, 'binary_sensor': { 'platform': 'ffmpeg_motion', 'input': 'testinputvideo', diff --git a/tests/components/test_ffmpeg.py b/tests/components/test_ffmpeg.py index 774bb471f57..f11611ece75 100644 --- a/tests/components/test_ffmpeg.py +++ b/tests/components/test_ffmpeg.py @@ -1,6 +1,6 @@ """The tests for Home Assistant ffmpeg.""" import asyncio -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock import homeassistant.components.ffmpeg as ffmpeg from homeassistant.components.ffmpeg import ( @@ -10,7 +10,7 @@ from homeassistant.core import callback from homeassistant.setup import setup_component, async_setup_component from tests.common import ( - get_test_home_assistant, assert_setup_component, mock_coro) + get_test_home_assistant, assert_setup_component) @callback @@ -85,14 +85,14 @@ class TestFFmpegSetup: def test_setup_component(self): """Set up ffmpeg component.""" - with assert_setup_component(2): + with assert_setup_component(1): setup_component(self.hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) assert self.hass.data[ffmpeg.DATA_FFMPEG].binary == 'ffmpeg' def test_setup_component_test_service(self): """Set up ffmpeg component test services.""" - with assert_setup_component(2): + with assert_setup_component(1): setup_component(self.hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) assert self.hass.services.has_service(ffmpeg.DOMAIN, 'start') @@ -103,7 +103,7 @@ class TestFFmpegSetup: @asyncio.coroutine def test_setup_component_test_register(hass): """Set up ffmpeg component test register.""" - with assert_setup_component(2): + with assert_setup_component(1): yield from async_setup_component( hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) @@ -118,7 +118,7 @@ def test_setup_component_test_register(hass): @asyncio.coroutine def test_setup_component_test_register_no_startup(hass): """Set up ffmpeg component test register without startup.""" - with assert_setup_component(2): + with assert_setup_component(1): yield from async_setup_component( hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) @@ -133,7 +133,7 @@ def test_setup_component_test_register_no_startup(hass): @asyncio.coroutine def test_setup_component_test_service_start(hass): """Set up ffmpeg component test service start.""" - with assert_setup_component(2): + with assert_setup_component(1): yield from async_setup_component( hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) @@ -149,7 +149,7 @@ def test_setup_component_test_service_start(hass): @asyncio.coroutine def test_setup_component_test_service_stop(hass): """Set up ffmpeg component test service stop.""" - with assert_setup_component(2): + with assert_setup_component(1): yield from async_setup_component( hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) @@ -165,7 +165,7 @@ def test_setup_component_test_service_stop(hass): @asyncio.coroutine def test_setup_component_test_service_restart(hass): """Set up ffmpeg component test service restart.""" - with assert_setup_component(2): + with assert_setup_component(1): yield from async_setup_component( hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) @@ -182,7 +182,7 @@ def test_setup_component_test_service_restart(hass): @asyncio.coroutine def test_setup_component_test_service_start_with_entity(hass): """Set up ffmpeg component test service start.""" - with assert_setup_component(2): + with assert_setup_component(1): yield from async_setup_component( hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) @@ -194,71 +194,3 @@ def test_setup_component_test_service_start_with_entity(hass): assert ffmpeg_dev.called_start assert ffmpeg_dev.called_entities == ['test.ffmpeg_device'] - - -@asyncio.coroutine -def test_setup_component_test_run_test_false(hass): - """Set up ffmpeg component test run_test false.""" - with assert_setup_component(2): - yield from async_setup_component( - hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: { - 'run_test': False, - }}) - - manager = hass.data[ffmpeg.DATA_FFMPEG] - with patch('haffmpeg.Test.run_test', return_value=mock_coro(False)): - yield from manager.async_run_test("blabalblabla") - - assert len(manager._cache) == 0 - - -@asyncio.coroutine -def test_setup_component_test_run_test(hass): - """Set up ffmpeg component test run_test.""" - with assert_setup_component(2): - yield from async_setup_component( - hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) - - manager = hass.data[ffmpeg.DATA_FFMPEG] - - with patch('haffmpeg.Test.run_test', return_value=mock_coro(True)) \ - as mock_test: - yield from manager.async_run_test("blabalblabla") - - assert mock_test.called - assert mock_test.call_count == 1 - assert len(manager._cache) == 1 - assert manager._cache['blabalblabla'] - - yield from manager.async_run_test("blabalblabla") - - assert mock_test.called - assert mock_test.call_count == 1 - assert len(manager._cache) == 1 - assert manager._cache['blabalblabla'] - - -@asyncio.coroutine -def test_setup_component_test_run_test_test_fail(hass): - """Set up ffmpeg component test run_test.""" - with assert_setup_component(2): - yield from async_setup_component( - hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) - - manager = hass.data[ffmpeg.DATA_FFMPEG] - - with patch('haffmpeg.Test.run_test', return_value=mock_coro(False)) \ - as mock_test: - yield from manager.async_run_test("blabalblabla") - - assert mock_test.called - assert mock_test.call_count == 1 - assert len(manager._cache) == 1 - assert not manager._cache['blabalblabla'] - - yield from manager.async_run_test("blabalblabla") - - assert mock_test.called - assert mock_test.call_count == 1 - assert len(manager._cache) == 1 - assert not manager._cache['blabalblabla'] From 6d3167fcd461d5857ac0ccc87d99f1f845cc987a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 3 Nov 2018 12:36:51 +0100 Subject: [PATCH 13/13] Bumped version to 0.81.5 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 8133916a660..66153dcaf46 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 81 -PATCH_VERSION = '4' +PATCH_VERSION = '5' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3)