From abc5c3e1284b080caa20a91d0a18e9e02278c6fa Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 13 Jul 2017 10:19:59 -0700 Subject: [PATCH 01/27] Fix iFrame panel test --- tests/components/test_panel_iframe.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/components/test_panel_iframe.py b/tests/components/test_panel_iframe.py index ec1e5bf3650..5f9cdcfa57c 100644 --- a/tests/components/test_panel_iframe.py +++ b/tests/components/test_panel_iframe.py @@ -53,9 +53,7 @@ class TestPanelIframe(unittest.TestCase): }, }) - # 5 dev tools + map are automatically loaded + 2 iframe panels - assert len(self.hass.data[frontend.DATA_PANELS]) == 8 - assert self.hass.data[frontend.DATA_PANELS]['router'] == { + assert self.hass.data[frontend.DATA_PANELS].get('router') == { 'component_name': 'iframe', 'config': {'url': 'http://192.168.1.1'}, 'icon': 'mdi:network-wireless', @@ -64,7 +62,7 @@ class TestPanelIframe(unittest.TestCase): 'url_path': 'router' } - assert self.hass.data[frontend.DATA_PANELS]['weather'] == { + assert self.hass.data[frontend.DATA_PANELS].get('weather') == { 'component_name': 'iframe', 'config': {'url': 'https://www.wunderground.com/us/ca/san-diego'}, 'icon': 'mdi:weather', From af9a0e8fea6ed9350a900372a6ea2ea850f95ebc Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Fri, 14 Jul 2017 04:38:36 +0200 Subject: [PATCH 02/27] LIFX: support for multizone (#8399) * Make aiolifx modules easily available * Use aiolifx features_map for deciding bulb features Also move the feature detection out of Light so it is available even during the initial detection. * Move each LIFX light type to a separate class * Simplify AwaitAioLIFX This has become possible with recent aiolifx that calls the callback even when a message is lost. Now the wrapper can be used also before a Light is added though the register callback then has to become a coroutine. * Refactor send_color * Add support for multizone This lets lifx_set_state work on individual zones. Also update to aiolifx_effects 0.1.1 that restores the state for individual zones. --- homeassistant/components/light/lifx.py | 269 ++++++++++++------- homeassistant/components/light/services.yaml | 4 + requirements_all.txt | 2 +- 3 files changed, 181 insertions(+), 94 deletions(-) diff --git a/homeassistant/components/light/lifx.py b/homeassistant/components/light/lifx.py index 0c5535ea8ea..a32aa0c4a6b 100644 --- a/homeassistant/components/light/lifx.py +++ b/homeassistant/components/light/lifx.py @@ -33,7 +33,7 @@ import homeassistant.util.color as color_util _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['aiolifx==0.5.2', 'aiolifx_effects==0.1.0'] +REQUIREMENTS = ['aiolifx==0.5.2', 'aiolifx_effects==0.1.1'] UDP_BROADCAST_PORT = 56700 @@ -53,10 +53,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ SERVICE_LIFX_SET_STATE = 'lifx_set_state' ATTR_INFRARED = 'infrared' +ATTR_ZONES = 'zones' ATTR_POWER = 'power' LIFX_SET_STATE_SCHEMA = LIGHT_TURN_ON_SCHEMA.extend({ ATTR_INFRARED: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)), + ATTR_ZONES: vol.All(cv.ensure_list, [cv.positive_int]), ATTR_POWER: cv.boolean, }) @@ -112,11 +114,21 @@ LIFX_EFFECT_STOP_SCHEMA = vol.Schema({ }) +def aiolifx(): + """Return the aiolifx module.""" + import aiolifx as aiolifx_module + return aiolifx_module + + +def aiolifx_effects(): + """Return the aiolifx_effects module.""" + import aiolifx_effects as aiolifx_effects_module + return aiolifx_effects_module + + @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the LIFX platform.""" - import aiolifx - if sys.platform == 'win32': _LOGGER.warning("The lifx platform is known to not work on Windows. " "Consider using the lifx_legacy platform instead") @@ -124,7 +136,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): server_addr = config.get(CONF_SERVER) lifx_manager = LIFXManager(hass, async_add_devices) - lifx_discovery = aiolifx.LifxDiscovery( + lifx_discovery = aiolifx().LifxDiscovery( hass.loop, lifx_manager, discovery_interval=DISCOVERY_INTERVAL, @@ -145,6 +157,16 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): return True +def lifxwhite(device): + """Return whether this is a white-only bulb.""" + return not aiolifx().products.features_map[device.product]["color"] + + +def lifxmultizone(device): + """Return whether this is a multizone bulb/strip.""" + return aiolifx().products.features_map[device.product]["multizone"] + + def find_hsbk(**kwargs): """Find the desired color from a number of possible inputs.""" hue, saturation, brightness, kelvin = [None]*4 @@ -187,11 +209,10 @@ class LIFXManager(object): def __init__(self, hass, async_add_devices): """Initialize the light.""" - import aiolifx_effects self.entities = {} self.hass = hass self.async_add_devices = async_add_devices - self.effects_conductor = aiolifx_effects.Conductor(loop=hass.loop) + self.effects_conductor = aiolifx_effects().Conductor(loop=hass.loop) descriptions = load_yaml_config_file( path.join(path.dirname(__file__), 'services.yaml')) @@ -245,11 +266,10 @@ class LIFXManager(object): @asyncio.coroutine def start_effect(self, entities, service, **kwargs): """Start a light effect on entities.""" - import aiolifx_effects devices = list(map(lambda l: l.device, entities)) if service == SERVICE_EFFECT_PULSE: - effect = aiolifx_effects.EffectPulse( + effect = aiolifx_effects().EffectPulse( power_on=kwargs.get(ATTR_POWER_ON), period=kwargs.get(ATTR_PERIOD), cycles=kwargs.get(ATTR_CYCLES), @@ -264,7 +284,7 @@ class LIFXManager(object): if ATTR_BRIGHTNESS in kwargs: brightness = convert_8_to_16(kwargs[ATTR_BRIGHTNESS]) - effect = aiolifx_effects.EffectColorloop( + effect = aiolifx_effects().EffectColorloop( power_on=kwargs.get(ATTR_POWER_ON), period=kwargs.get(ATTR_PERIOD), change=kwargs.get(ATTR_CHANGE), @@ -289,32 +309,39 @@ class LIFXManager(object): @callback def register(self, device): - """Handle for newly detected bulb.""" + """Handler for newly detected bulb.""" + self.hass.async_add_job(self.async_register(device)) + + @asyncio.coroutine + def async_register(self, device): + """Handler for newly detected bulb.""" if device.mac_addr in self.entities: entity = self.entities[device.mac_addr] - entity.device = device entity.registered = True _LOGGER.debug("%s register AGAIN", entity.who) - self.hass.async_add_job(entity.async_update_ha_state()) + yield from entity.async_update() + yield from entity.async_update_ha_state() else: _LOGGER.debug("%s register NEW", device.ip_addr) device.timeout = MESSAGE_TIMEOUT device.retry_count = MESSAGE_RETRIES device.unregister_timeout = UNAVAILABLE_GRACE - device.get_version(self.got_version) - @callback - def got_version(self, device, msg): - """Request current color setting once we have the product version.""" - device.get_color(self.ready) + ack = AwaitAioLIFX().wait + yield from ack(device.get_version) + yield from ack(device.get_color) - @callback - def ready(self, device, msg): - """Handle the device once all data is retrieved.""" - entity = LIFXLight(device, self.effects_conductor) - _LOGGER.debug("%s register READY", entity.who) - self.entities[device.mac_addr] = entity - self.async_add_devices([entity]) + if lifxwhite(device): + entity = LIFXWhite(device, self.effects_conductor) + elif lifxmultizone(device): + yield from ack(partial(device.get_color_zones, start_index=0)) + entity = LIFXStrip(device, self.effects_conductor) + else: + entity = LIFXColor(device, self.effects_conductor) + + _LOGGER.debug("%s register READY", entity.who) + self.entities[device.mac_addr] = entity + self.async_add_devices([entity]) @callback def unregister(self, device): @@ -329,9 +356,8 @@ class LIFXManager(object): class AwaitAioLIFX: """Wait for an aiolifx callback and return the message.""" - def __init__(self, light): + def __init__(self): """Initialize the wrapper.""" - self.light = light self.device = None self.message = None self.event = asyncio.Event() @@ -373,15 +399,8 @@ class LIFXLight(Light): self.device = device self.effects_conductor = effects_conductor self.registered = True - self.product = device.product self.postponed_update = None - @property - def lifxwhite(self): - """Return whether this is a white-only bulb.""" - # https://lan.developer.lifx.com/docs/lifx-products - return self.product in [10, 11, 18] - @property def available(self): """Return the availability of the device.""" @@ -397,14 +416,6 @@ class LIFXLight(Light): """Return a string identifying the device.""" return "%s (%s)" % (self.device.ip_addr, self.name) - @property - def rgb_color(self): - """Return the RGB value.""" - hue, sat, bri, _ = self.device.color - - return color_util.color_hsv_to_RGB( - hue, convert_16_to_8(sat), convert_16_to_8(bri)) - @property def brightness(self): """Return the brightness of this light between 0..255.""" @@ -421,26 +432,6 @@ class LIFXLight(Light): _LOGGER.debug("color_temp: %d", temperature) return temperature - @property - def min_mireds(self): - """Return the coldest color_temp that this light supports.""" - # The 3 LIFX "White" products supported a limited temperature range - if self.lifxwhite: - kelvin = 6500 - else: - kelvin = 9000 - return math.floor(color_util.color_temperature_kelvin_to_mired(kelvin)) - - @property - def max_mireds(self): - """Return the warmest color_temp that this light supports.""" - # The 3 LIFX "White" products supported a limited temperature range - if self.lifxwhite: - kelvin = 2700 - else: - kelvin = 2500 - return math.ceil(color_util.color_temperature_kelvin_to_mired(kelvin)) - @property def is_on(self): """Return true if device is on.""" @@ -454,32 +445,6 @@ class LIFXLight(Light): return 'lifx_effect_' + effect.name return None - @property - def supported_features(self): - """Flag supported features.""" - features = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | - SUPPORT_TRANSITION | SUPPORT_EFFECT) - - if not self.lifxwhite: - features |= SUPPORT_RGB_COLOR | SUPPORT_XY_COLOR - - return features - - @property - def effect_list(self): - """Return the list of supported effects for this light.""" - if self.lifxwhite: - return [ - SERVICE_EFFECT_PULSE, - SERVICE_EFFECT_STOP, - ] - - return [ - SERVICE_EFFECT_COLORLOOP, - SERVICE_EFFECT_PULSE, - SERVICE_EFFECT_STOP, - ] - @asyncio.coroutine def update_after_transition(self, now): """Request new status after completion of the last transition.""" @@ -530,30 +495,36 @@ class LIFXLight(Light): power_on = kwargs.get(ATTR_POWER, False) power_off = not kwargs.get(ATTR_POWER, True) - hsbk = merge_hsbk(self.device.color, find_hsbk(**kwargs)) + hsbk = find_hsbk(**kwargs) # Send messages, waiting for ACK each time - ack = AwaitAioLIFX(self).wait + ack = AwaitAioLIFX().wait bulb = self.device if not self.is_on: if power_off: yield from ack(partial(bulb.set_power, False)) if hsbk: - yield from ack(partial(bulb.set_color, hsbk)) + yield from self.send_color(ack, hsbk, kwargs, duration=0) if power_on: yield from ack(partial(bulb.set_power, True, duration=fade)) else: if power_on: yield from ack(partial(bulb.set_power, True)) if hsbk: - yield from ack(partial(bulb.set_color, hsbk, duration=fade)) + yield from self.send_color(ack, hsbk, kwargs, duration=fade) if power_off: yield from ack(partial(bulb.set_power, False, duration=fade)) # Schedule an update when the transition is complete self.update_later(fade) + @asyncio.coroutine + def send_color(self, ack, hsbk, kwargs, duration): + """Send a color change to the device.""" + hsbk = merge_hsbk(self.device.color, hsbk) + yield from ack(partial(self.device.set_color, hsbk, duration=duration)) + @asyncio.coroutine def default_effect(self, **kwargs): """Start an effect with default parameters.""" @@ -569,5 +540,117 @@ class LIFXLight(Light): _LOGGER.debug("%s async_update", self.who) if self.available: # Avoid state ping-pong by holding off updates as the state settles - yield from asyncio.sleep(0.25) - yield from AwaitAioLIFX(self).wait(self.device.get_color) + yield from asyncio.sleep(0.3) + yield from AwaitAioLIFX().wait(self.device.get_color) + + +class LIFXWhite(LIFXLight): + """Representation of a white-only LIFX light.""" + + @property + def min_mireds(self): + """Return the coldest color_temp that this light supports.""" + return math.floor(color_util.color_temperature_kelvin_to_mired(6500)) + + @property + def max_mireds(self): + """Return the warmest color_temp that this light supports.""" + return math.ceil(color_util.color_temperature_kelvin_to_mired(2700)) + + @property + def supported_features(self): + """Flag supported features.""" + return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_TRANSITION | + SUPPORT_EFFECT) + + @property + def effect_list(self): + """Return the list of supported effects for this light.""" + return [ + SERVICE_EFFECT_PULSE, + SERVICE_EFFECT_STOP, + ] + + +class LIFXColor(LIFXLight): + """Representation of a color LIFX light.""" + + @property + def min_mireds(self): + """Return the coldest color_temp that this light supports.""" + return math.floor(color_util.color_temperature_kelvin_to_mired(9000)) + + @property + def max_mireds(self): + """Return the warmest color_temp that this light supports.""" + return math.ceil(color_util.color_temperature_kelvin_to_mired(2500)) + + @property + def supported_features(self): + """Flag supported features.""" + return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_TRANSITION | + SUPPORT_EFFECT | SUPPORT_RGB_COLOR | SUPPORT_XY_COLOR) + + @property + def effect_list(self): + """Return the list of supported effects for this light.""" + return [ + SERVICE_EFFECT_COLORLOOP, + SERVICE_EFFECT_PULSE, + SERVICE_EFFECT_STOP, + ] + + @property + def rgb_color(self): + """Return the RGB value.""" + hue, sat, bri, _ = self.device.color + + return color_util.color_hsv_to_RGB( + hue, convert_16_to_8(sat), convert_16_to_8(bri)) + + +class LIFXStrip(LIFXColor): + """Representation of a LIFX light strip with multiple zones.""" + + @asyncio.coroutine + def send_color(self, ack, hsbk, kwargs, duration): + """Send a color change to the device.""" + bulb = self.device + num_zones = len(bulb.color_zones) + + # Zone brightness is not reported when powered off + if not self.is_on and hsbk[2] is None: + yield from ack(partial(bulb.set_power, True)) + yield from self.async_update() + yield from ack(partial(bulb.set_power, False)) + + zones = kwargs.get(ATTR_ZONES, None) + if zones is None: + zones = list(range(0, num_zones)) + else: + zones = list(filter(lambda x: x < num_zones, set(zones))) + + # Send new color to each zone + for index, zone in enumerate(zones): + zone_hsbk = merge_hsbk(bulb.color_zones[zone], hsbk) + apply = 1 if (index == len(zones)-1) else 0 + set_zone = partial(bulb.set_color_zones, + start_index=zone, + end_index=zone, + color=zone_hsbk, + duration=duration, + apply=apply) + yield from ack(set_zone) + + @asyncio.coroutine + def async_update(self): + """Update strip status.""" + if self.available: + yield from super().async_update() + + ack = AwaitAioLIFX().wait + bulb = self.device + + # Each get_color_zones returns the next 8 zones + for zone in range(0, len(bulb.color_zones), 8): + yield from ack(partial(bulb.get_color_zones, start_index=zone)) diff --git a/homeassistant/components/light/services.yaml b/homeassistant/components/light/services.yaml index ef99f18fb42..782d4496442 100644 --- a/homeassistant/components/light/services.yaml +++ b/homeassistant/components/light/services.yaml @@ -117,6 +117,10 @@ lifx_set_state: description: Automatic infrared level (0..255) when light brightness is low example: 255 + zones: + description: List of zone numbers to affect (8 per LIFX Z, starts at 0) + example: '[0,5]' + transition: description: Duration in seconds it takes to get to the final state example: 10 diff --git a/requirements_all.txt b/requirements_all.txt index d4e4a30add7..58ef8d070d0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -52,7 +52,7 @@ aiohttp_cors==0.5.3 aiolifx==0.5.2 # homeassistant.components.light.lifx -aiolifx_effects==0.1.0 +aiolifx_effects==0.1.1 # homeassistant.components.scene.hunterdouglas_powerview aiopvapi==1.4 From 21e82bd0371aa7419e24c66a78e08ff7f62c73b5 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 14 Jul 2017 04:53:19 +0200 Subject: [PATCH 03/27] Add RGB support to switch.flux (#8417) --- homeassistant/components/switch/flux.py | 20 +++++++++-- tests/components/switch/test_flux.py | 47 +++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switch/flux.py b/homeassistant/components/switch/flux.py index daa4d1f8cd1..dea4285e3a9 100644 --- a/homeassistant/components/switch/flux.py +++ b/homeassistant/components/switch/flux.py @@ -37,6 +37,7 @@ CONF_MODE = 'mode' MODE_XY = 'xy' MODE_MIRED = 'mired' +MODE_RGB = 'rgb' DEFAULT_MODE = MODE_XY PLATFORM_SCHEMA = vol.Schema({ @@ -55,7 +56,7 @@ PLATFORM_SCHEMA = vol.Schema({ vol.All(vol.Coerce(int), vol.Range(min=0, max=255)), vol.Optional(CONF_DISABLE_BRIGTNESS_ADJUST): cv.boolean, vol.Optional(CONF_MODE, default=DEFAULT_MODE): - vol.Any(MODE_XY, MODE_MIRED) + vol.Any(MODE_XY, MODE_MIRED, MODE_RGB) }) @@ -79,6 +80,15 @@ def set_lights_temp(hass, lights, mired, brightness): transition=30) +def set_lights_rgb(hass, lights, rgb): + """Set color of array of lights.""" + for light in lights: + if is_on(hass, light): + turn_on(hass, light, + rgb_color=rgb, + transition=30) + + # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Flux switches.""" @@ -194,7 +204,8 @@ class FluxSwitch(SwitchDevice): temp = self._sunset_colortemp - temp_offset else: temp = self._sunset_colortemp + temp_offset - x_val, y_val, b_val = color_RGB_to_xy(*color_temperature_to_rgb(temp)) + rgb = color_temperature_to_rgb(temp) + x_val, y_val, b_val = color_RGB_to_xy(*rgb) brightness = self._brightness if self._brightness else b_val if self._disable_brightness_adjust: brightness = None @@ -205,6 +216,11 @@ class FluxSwitch(SwitchDevice): "of %s cycle complete at %s", x_val, y_val, brightness, round( percentage_complete * 100), time_state, now) + elif self._mode == MODE_RGB: + set_lights_rgb(self.hass, self._lights, rgb) + _LOGGER.info("Lights updated to rgb:%s, %s%% " + "of %s cycle complete at %s", rgb, + round(percentage_complete * 100), time_state, now) else: # Convert to mired and clamp to allowed values mired = color_temperature_kelvin_to_mired(temp) diff --git a/tests/components/switch/test_flux.py b/tests/components/switch/test_flux.py index 2422f0ea334..d529e8c3f56 100644 --- a/tests/components/switch/test_flux.py +++ b/tests/components/switch/test_flux.py @@ -557,3 +557,50 @@ class TestSwitchFlux(unittest.TestCase): self.hass.block_till_done() call = turn_on_calls[-1] self.assertEqual(call.data[light.ATTR_COLOR_TEMP], 269) + + def test_flux_with_rgb(self): + """Test the flux switch´s mode rgb.""" + platform = loader.get_component('light.test') + platform.init() + self.assertTrue( + setup_component(self.hass, light.DOMAIN, + {light.DOMAIN: {CONF_PLATFORM: 'test'}})) + + dev1 = platform.DEVICES[0] + + # Verify initial state of light + state = self.hass.states.get(dev1.entity_id) + 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) + sunset_time = test_time.replace(hour=17, minute=0, second=0) + sunrise_time = test_time.replace(hour=5, minute=0, second=0) + + def event_date(hass, event, now=None): + if event == 'sunrise': + return sunrise_time + else: + return sunset_time + + with patch('homeassistant.util.dt.now', return_value=test_time): + with patch('homeassistant.helpers.sun.get_astral_event_date', + side_effect=event_date): + assert setup_component(self.hass, switch.DOMAIN, { + switch.DOMAIN: { + 'platform': 'flux', + 'name': 'flux', + 'lights': [dev1.entity_id], + 'mode': 'rgb' + } + }) + turn_on_calls = mock_service( + self.hass, light.DOMAIN, SERVICE_TURN_ON) + switch.turn_on(self.hass, 'switch.flux') + self.hass.block_till_done() + fire_time_changed(self.hass, test_time) + self.hass.block_till_done() + call = turn_on_calls[-1] + rgb = (255, 198, 152) + rounded_call = tuple(map(round, call.data[light.ATTR_RGB_COLOR])) + self.assertEqual(rounded_call, rgb) From bd1e533409a6651c867725699751bb68bd7a87f8 Mon Sep 17 00:00:00 2001 From: dersger Date: Fri, 14 Jul 2017 05:00:23 +0200 Subject: [PATCH 04/27] Fix media_position for cast component (#8452) * Make it available during state paused. * Don't adjust for media_position_updated_at. I.e. do as vlc, sonos etc so that returned position is the position at the time of media_position_updated_at, not now. --- homeassistant/components/media_player/cast.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/media_player/cast.py b/homeassistant/components/media_player/cast.py index 418d3576750..51acf68d819 100644 --- a/homeassistant/components/media_player/cast.py +++ b/homeassistant/components/media_player/cast.py @@ -234,18 +234,13 @@ class CastDevice(MediaPlayerDevice): @property def media_position(self): """Position of current playing media in seconds.""" - if self.media_status is None or self.media_status_received is None or \ + if self.media_status is None or \ not (self.media_status.player_is_playing or + self.media_status.player_is_paused or self.media_status.player_is_idle): return None - position = self.media_status.current_time - - if self.media_status.player_is_playing: - position += (dt_util.utcnow() - - self.media_status_received).total_seconds() - - return position + return self.media_status.current_time @property def media_position_updated_at(self): From e5e2a151aa5d31e28e46f0bd2b2c86ba036e8f6a Mon Sep 17 00:00:00 2001 From: Sean Gollschewsky Date: Fri, 14 Jul 2017 04:01:25 +0100 Subject: [PATCH 05/27] Remove km from visibility, add visibility_distance (#8454) * Remove km from visibility, add visibility_distance * Fix line length * Fix trailing space and line break indentation * Indentation * More whitespace --- homeassistant/components/sensor/metoffice.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/metoffice.py b/homeassistant/components/sensor/metoffice.py index a20ec8fdd5a..25516eda5b1 100644 --- a/homeassistant/components/sensor/metoffice.py +++ b/homeassistant/components/sensor/metoffice.py @@ -40,6 +40,15 @@ CONDITION_CLASSES = { 'exceptional': [], } +VISIBILTY_CLASSES = { + 'VP': '<1', + 'PO': '1-4', + 'MO': '4-10', + 'GO': '10-20', + 'VG': '20-40', + 'EX': '>40' +} + SCAN_INTERVAL = timedelta(minutes=35) # Sensor types are defined like: Name, units @@ -51,7 +60,8 @@ SENSOR_TYPES = { 'wind_speed': ['Wind Speed', 'm/s'], 'wind_direction': ['Wind Direction', None], 'wind_gust': ['Wind Gust', 'm/s'], - 'visibility': ['Visibility', 'km'], + 'visibility': ['Visibility', None], + 'visibility_distance': ['Visibility Distance', 'km'], 'uv': ['UV', None], 'precipitation': ['Probability of Precipitation', '%'], 'humidity': ['Humidity', '%'] @@ -119,6 +129,9 @@ class MetOfficeCurrentSensor(Entity): @property def state(self): """Return the state of the sensor.""" + if (self._condition == 'visibility_distance' and + 'visibility' in self.data.data.__dict__.keys()): + return VISIBILTY_CLASSES.get(self.data.data.visibility.value) if self._condition in self.data.data.__dict__.keys(): variable = getattr(self.data.data, self._condition) if self._condition == "weather": From 1366c93c83f3cd2f55bdfa4f2ea2f526d497ac47 Mon Sep 17 00:00:00 2001 From: Bryce Edwards Date: Thu, 13 Jul 2017 22:02:07 -0500 Subject: [PATCH 06/27] Radarr sensor fix for issue #8250 (#8456) * Radarr sensor fix for issue #8250 * Radarr sensor fix for issue #8250 --- homeassistant/components/sensor/radarr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/radarr.py b/homeassistant/components/sensor/radarr.py index f5efe12c449..59408b4f96b 100644 --- a/homeassistant/components/sensor/radarr.py +++ b/homeassistant/components/sensor/radarr.py @@ -216,9 +216,9 @@ def get_date(zone, offset=0): def get_release_date(data): """Get release date.""" - date = data['physicalRelease'] + date = data.get('physicalRelease') if not date: - date = data['inCinemas'] + date = data.get('inCinemas') return date From 84ca4d2a21831701dd9e5c10811e07ceccde4bee Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Fri, 14 Jul 2017 05:04:23 +0200 Subject: [PATCH 07/27] Accept transition for light.toggle (#8466) --- homeassistant/helpers/entity.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index da177bc4331..49f250c65fa 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -378,18 +378,18 @@ class ToggleEntity(Entity): return self.hass.async_add_job( ft.partial(self.turn_off, **kwargs)) - def toggle(self) -> None: + def toggle(self, **kwargs) -> None: """Toggle the entity.""" if self.is_on: - self.turn_off() + self.turn_off(**kwargs) else: - self.turn_on() + self.turn_on(**kwargs) - def async_toggle(self): + def async_toggle(self, **kwargs): """Toggle the entity. This method must be run in the event loop and returns a coroutine. """ if self.is_on: - return self.async_turn_off() - return self.async_turn_on() + return self.async_turn_off(**kwargs) + return self.async_turn_on(**kwargs) From 3377f3061331b22733d4314423f41f0bc7accfa8 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 14 Jul 2017 21:26:26 +0300 Subject: [PATCH 08/27] Make themes API work even when themes are not defined. (#8473) --- homeassistant/components/frontend/__init__.py | 11 +++++++---- tests/components/test_frontend.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index 4184feabaeb..443ff6f3852 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -212,17 +212,20 @@ def setup(hass, config): register_built_in_panel(hass, panel) themes = config.get(DOMAIN, {}).get(ATTR_THEMES) - if themes: - setup_themes(hass, themes) + setup_themes(hass, themes) return True def setup_themes(hass, themes): """Set up themes data and services.""" - hass.data[DATA_THEMES] = themes - hass.data[DATA_DEFAULT_THEME] = DEFAULT_THEME hass.http.register_view(ThemesView) + hass.data[DATA_DEFAULT_THEME] = DEFAULT_THEME + if themes is None: + hass.data[DATA_THEMES] = {} + return + + hass.data[DATA_THEMES] = themes @callback def update_theme_and_fire_event(): diff --git a/tests/components/test_frontend.py b/tests/components/test_frontend.py index d1e2e5d4346..3682e0a2c14 100644 --- a/tests/components/test_frontend.py +++ b/tests/components/test_frontend.py @@ -133,3 +133,13 @@ def test_themes_reload_themes(hass, mock_http_client_with_themes): json = yield from resp.json() assert json['themes'] == {'sad': {'primary-color': 'blue'}} assert json['default_theme'] == 'default' + + +@asyncio.coroutine +def test_missing_themes(mock_http_client): + """Test that themes API works when themes are not defined.""" + resp = yield from mock_http_client.get('/api/themes') + assert resp.status == 200 + json = yield from resp.json() + assert json['default_theme'] == 'default' + assert json['themes'] == {} From 1d4a7f11607c111d51b248ff61470e1a93f5ec9c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 15 Jul 2017 21:06:20 -0700 Subject: [PATCH 09/27] Version bump to 0.49 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index f7df04be7f1..fae73899986 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 49 -PATCH_VERSION = '0.dev0' +PATCH_VERSION = '0' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2) From ffd295b38b10ab1599ef46ce619f4b7b95fd1dff Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 23 Jul 2017 23:34:08 -0700 Subject: [PATCH 10/27] Update to 0.49.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index fae73899986..25990b102a8 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 49 -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 5c39eebea8de2b0750e5ede785a9c64dedca86a2 Mon Sep 17 00:00:00 2001 From: Maikel Wever Date: Sun, 16 Jul 2017 19:27:48 +0200 Subject: [PATCH 11/27] Fix TP-Link device tracker regression since 0.49 (#8497) * Fix TP-Link device tracker regression since 0.49 This regression was introduced by #8322. Fix is to utf encode the password like the other TP-Link backends do. * Fix linting issue introduced in previous commit Commit in question: 677f3fbb7f821ee925364c8260d235dce4f0ddbe --- homeassistant/components/device_tracker/tplink.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/device_tracker/tplink.py b/homeassistant/components/device_tracker/tplink.py index 88b0abe8ce4..ccf0c2d01af 100755 --- a/homeassistant/components/device_tracker/tplink.py +++ b/homeassistant/components/device_tracker/tplink.py @@ -391,7 +391,8 @@ class Tplink5DeviceScanner(TplinkDeviceScanner): "Cache-Control": "no-cache" } - password_md5 = hashlib.md5(self.password).hexdigest().upper() + password_md5 = hashlib.md5( + self.password.encode('utf')).hexdigest().upper() # create a session to handle cookie easier session = requests.session() From 6dc93c27514039670254e2a2781bdb3bd56beb95 Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Mon, 17 Jul 2017 02:25:20 -0700 Subject: [PATCH 12/27] prometheus: Convert fahrenheit to celsius (#8511) --- homeassistant/components/prometheus.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/prometheus.py b/homeassistant/components/prometheus.py index 4ed6028ac56..18a3a932d36 100644 --- a/homeassistant/components/prometheus.py +++ b/homeassistant/components/prometheus.py @@ -17,6 +17,7 @@ from homeassistant.const import (CONF_DOMAINS, CONF_ENTITIES, CONF_EXCLUDE, TEMP_CELSIUS, TEMP_FAHRENHEIT) from homeassistant import core as hacore from homeassistant.helpers import state as state_helper +from homeassistant.util.temperature import fahrenheit_to_celsius _LOGGER = logging.getLogger(__name__) @@ -198,6 +199,8 @@ class Metrics: metric = self._metric(*metric) try: value = state_helper.state_as_number(state) + if unit == TEMP_FAHRENHEIT: + value = fahrenheit_to_celsius(value) metric.labels(**self._labels(state)).set(value) except ValueError: pass From 7d99d6aad97081419554f0cab34d04d2a61b032a Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 17 Jul 2017 11:03:16 +0200 Subject: [PATCH 13/27] Update dlib_face_detect.py (#8516) --- homeassistant/components/image_processing/dlib_face_detect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/image_processing/dlib_face_detect.py b/homeassistant/components/image_processing/dlib_face_detect.py index 7c0c0e26649..b4ad10934f2 100644 --- a/homeassistant/components/image_processing/dlib_face_detect.py +++ b/homeassistant/components/image_processing/dlib_face_detect.py @@ -68,4 +68,4 @@ class DlibFaceDetectEntity(ImageProcessingFaceEntity): image = face_recognition.load_image_file(fak_file) face_locations = face_recognition.face_locations(image) - self.process_faces(face_locations, len(face_locations)) + self.process_faces(list(face_locations), len(face_locations)) From 4961ece9311d403786edb57fd78b92bfa0e0d4a9 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 17 Jul 2017 12:09:42 +0200 Subject: [PATCH 14/27] Realfix for dlib (#8517) * Update dlib_face_detect.py * fix lint * Update dlib_face_detect.py --- .../components/image_processing/dlib_face_detect.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/image_processing/dlib_face_detect.py b/homeassistant/components/image_processing/dlib_face_detect.py index b4ad10934f2..1c999782ec7 100644 --- a/homeassistant/components/image_processing/dlib_face_detect.py +++ b/homeassistant/components/image_processing/dlib_face_detect.py @@ -19,6 +19,8 @@ REQUIREMENTS = ['face_recognition==0.2.0'] _LOGGER = logging.getLogger(__name__) +ATTR_LOCATION = 'location' + def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Dlib Face detection platform.""" @@ -68,4 +70,7 @@ class DlibFaceDetectEntity(ImageProcessingFaceEntity): image = face_recognition.load_image_file(fak_file) face_locations = face_recognition.face_locations(image) - self.process_faces(list(face_locations), len(face_locations)) + face_locations = [{ATTR_LOCATION: location} + for location in face_locations] + + self.process_faces(face_locations, len(face_locations)) From a5bfcceacd70beb85c302b08232f9658705b4380 Mon Sep 17 00:00:00 2001 From: Eugenio Panadero Date: Mon, 17 Jul 2017 13:47:28 +0200 Subject: [PATCH 15/27] Attach the `chat_id` for a callback query from a chat group (fixes #8461) (#8523) --- homeassistant/components/telegram_bot/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index 3d16252120b..6d9f43e2425 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -581,6 +581,8 @@ class BaseTelegramBotEntity: data[ATTR_FROM_LAST] = msg_data['from']['last_name'] if 'chat' in msg_data: data[ATTR_CHAT_ID] = msg_data['chat']['id'] + elif ATTR_MESSAGE in msg_data and 'chat' in msg_data[ATTR_MESSAGE]: + data[ATTR_CHAT_ID] = msg_data[ATTR_MESSAGE]['chat']['id'] return True, data From d7da90ae548cc4336dbd6b180ca18ed9558b26bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20St=C3=A5hl?= Date: Tue, 18 Jul 2017 20:19:36 +0200 Subject: [PATCH 16/27] Fix support for multiple Apple TVs (#8539) --- homeassistant/components/apple_tv.py | 2 +- homeassistant/components/remote/apple_tv.py | 5 +++++ requirements_all.txt | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/apple_tv.py b/homeassistant/components/apple_tv.py index 17cc46f3318..f5850bb21a9 100644 --- a/homeassistant/components/apple_tv.py +++ b/homeassistant/components/apple_tv.py @@ -18,7 +18,7 @@ from homeassistant.components.discovery import SERVICE_APPLE_TV from homeassistant.loader import get_component import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['pyatv==0.3.2'] +REQUIREMENTS = ['pyatv==0.3.4'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/remote/apple_tv.py b/homeassistant/components/remote/apple_tv.py index a7ea113c2db..e89234c60ac 100644 --- a/homeassistant/components/remote/apple_tv.py +++ b/homeassistant/components/remote/apple_tv.py @@ -44,6 +44,11 @@ class AppleTVRemote(remote.RemoteDevice): """Return the name of the device.""" return self._name + @property + def unique_id(self): + """Return an unique ID.""" + return self._atv.metadata.device_id + @property def is_on(self): """Return true if device is on.""" diff --git a/requirements_all.txt b/requirements_all.txt index 58ef8d070d0..48a3f677345 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -519,7 +519,7 @@ pyasn1-modules==0.0.9 pyasn1==0.2.3 # homeassistant.components.apple_tv -pyatv==0.3.2 +pyatv==0.3.4 # homeassistant.components.device_tracker.bbox # homeassistant.components.sensor.bbox From fb6bdfaba9563f8e2d52c78f5ff15fee6e42a5f0 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Thu, 20 Jul 2017 07:54:46 +0200 Subject: [PATCH 17/27] LIFX: assume default features for unknown products (#8553) This makes the detection work for prototypes as well. --- homeassistant/components/light/lifx.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/light/lifx.py b/homeassistant/components/light/lifx.py index a32aa0c4a6b..a6c5f855875 100644 --- a/homeassistant/components/light/lifx.py +++ b/homeassistant/components/light/lifx.py @@ -159,12 +159,18 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): def lifxwhite(device): """Return whether this is a white-only bulb.""" - return not aiolifx().products.features_map[device.product]["color"] + features = aiolifx().products.features_map.get(device.product, None) + if features: + return not features["color"] + return False def lifxmultizone(device): """Return whether this is a multizone bulb/strip.""" - return aiolifx().products.features_map[device.product]["multizone"] + features = aiolifx().products.features_map.get(device.product, None) + if features: + return features["multizone"] + return False def find_hsbk(**kwargs): From 7b10f0a14fe6763f733143f1f6f2cfbf8d7a7571 Mon Sep 17 00:00:00 2001 From: Yannick POLLART Date: Thu, 20 Jul 2017 07:56:11 +0200 Subject: [PATCH 18/27] Fix broken status update for lighting4 devices (#8543) * Fix broken status update for lighting4 devices * Fixed indentation --- .../components/binary_sensor/rfxtrx.py | 20 +++++++++---------- homeassistant/components/rfxtrx.py | 11 ++-------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/binary_sensor/rfxtrx.py b/homeassistant/components/binary_sensor/rfxtrx.py index 9a2c23206c1..b70169dc594 100644 --- a/homeassistant/components/binary_sensor/rfxtrx.py +++ b/homeassistant/components/binary_sensor/rfxtrx.py @@ -62,6 +62,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): entity[CONF_COMMAND_ON], entity[CONF_COMMAND_OFF]) device.hass = hass + device.is_lighting4 = (packet_id[2:4] == '13') sensors.append(device) rfxtrx.RFX_DEVICES[device_id] = device @@ -94,6 +95,8 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): pkt_id = "".join("{0:02x}".format(x) for x in event.data) sensor = RfxtrxBinarySensor(event, pkt_id) + sensor.hass = hass + sensor.is_lighting4 = (pkt_id[2:4] == '13') rfxtrx.RFX_DEVICES[device_id] = sensor add_devices_callback([sensor]) _LOGGER.info("Added binary sensor %s " @@ -111,12 +114,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): slugify(event.device.id_string.lower()), event.device.__class__.__name__, event.device.subtype) - - if sensor.is_pt2262: - cmd = rfxtrx.get_pt2262_cmd(device_id, sensor.data_bits) - _LOGGER.info("applying cmd %s to device_id: %s)", - cmd, sensor.masked_id) - sensor.apply_cmd(int(cmd, 16)) + if sensor.is_lighting4: + if sensor.data_bits is not None: + cmd = rfxtrx.get_pt2262_cmd(device_id, sensor.data_bits) + sensor.apply_cmd(int(cmd, 16)) + else: + sensor.update_state(True) else: rfxtrx.apply_received_command(event) @@ -170,11 +173,6 @@ class RfxtrxBinarySensor(BinarySensorDevice): """Return the device name.""" return self._name - @property - def is_pt2262(self): - """Return true if the device is PT2262-based.""" - return self._data_bits is not None - @property def masked_id(self): """Return the masked device id (isolated address bits).""" diff --git a/homeassistant/components/rfxtrx.py b/homeassistant/components/rfxtrx.py index b6e4d3415f4..e3ffc2f24a8 100644 --- a/homeassistant/components/rfxtrx.py +++ b/homeassistant/components/rfxtrx.py @@ -247,10 +247,8 @@ def get_pt2262_device(device_id): """Look for the device which id matches the given device_id parameter.""" for dev_id, device in RFX_DEVICES.items(): try: - if (device.is_pt2262 and - device.masked_id == get_pt2262_deviceid( - device_id, - device.data_bits)): + if device.masked_id == get_pt2262_deviceid(device_id, + device.data_bits): _LOGGER.info("rfxtrx: found matching device %s for %s", device_id, get_pt2262_deviceid(device_id, device.data_bits)) @@ -414,11 +412,6 @@ class RfxtrxDevice(Entity): """Return is the device must fire event.""" return self._should_fire_event - @property - def is_pt2262(self): - """Return true if the device is PT2262-based.""" - return False - @property def is_on(self): """Return true if device is on.""" From 333da0dc6da1fcb3eb1e5fdbda7481ef9f1a5e0c Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Fri, 21 Jul 2017 21:22:43 -0700 Subject: [PATCH 19/27] zha: Update to bellows 0.3.4 (#8594) --- homeassistant/components/zha/__init__.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index e397b7d042a..1b2d46ee72b 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -14,7 +14,7 @@ from homeassistant import const as ha_const from homeassistant.helpers import discovery, entity from homeassistant.util import slugify -REQUIREMENTS = ['bellows==0.3.2'] +REQUIREMENTS = ['bellows==0.3.4'] DOMAIN = 'zha' diff --git a/requirements_all.txt b/requirements_all.txt index 48a3f677345..53f37caf256 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -92,7 +92,7 @@ batinfo==0.4.2 beautifulsoup4==4.6.0 # homeassistant.components.zha -bellows==0.3.2 +bellows==0.3.4 # homeassistant.components.blink blinkpy==0.6.0 From 2cf9254a08d64effb393412fda80a68933d7a59c Mon Sep 17 00:00:00 2001 From: Chia-liang Kao Date: Sun, 23 Jul 2017 03:22:49 -0500 Subject: [PATCH 20/27] Fix STATION_SCHEMA validation on longitude (#8610) --- homeassistant/components/sensor/citybikes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/citybikes.py b/homeassistant/components/sensor/citybikes.py index 15046897732..b0cde805796 100644 --- a/homeassistant/components/sensor/citybikes.py +++ b/homeassistant/components/sensor/citybikes.py @@ -84,7 +84,7 @@ STATION_SCHEMA = vol.Schema({ vol.Required(ATTR_FREE_BIKES): cv.positive_int, vol.Required(ATTR_EMPTY_SLOTS): cv.positive_int, vol.Required(ATTR_LATITUDE): cv.latitude, - vol.Required(ATTR_LONGITUDE): cv.latitude, + vol.Required(ATTR_LONGITUDE): cv.longitude, vol.Required(ATTR_ID): cv.string, vol.Required(ATTR_NAME): cv.string, vol.Required(ATTR_TIMESTAMP): cv.string, From 3e34f34f6be606bc3ad9a5967860c649d899d80c Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Mon, 24 Jul 2017 02:46:23 -0400 Subject: [PATCH 21/27] Bumped Amcrest version (#8624) --- homeassistant/components/amcrest.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/amcrest.py b/homeassistant/components/amcrest.py index 8a40c790c12..76ba13c3409 100644 --- a/homeassistant/components/amcrest.py +++ b/homeassistant/components/amcrest.py @@ -18,7 +18,7 @@ from homeassistant.const import ( from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['amcrest==1.2.0'] +REQUIREMENTS = ['amcrest==1.2.1'] DEPENDENCIES = ['ffmpeg'] _LOGGER = logging.getLogger(__name__) diff --git a/requirements_all.txt b/requirements_all.txt index 53f37caf256..a2188f8b6a2 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -61,7 +61,7 @@ aiopvapi==1.4 alarmdecoder==0.12.1.0 # homeassistant.components.amcrest -amcrest==1.2.0 +amcrest==1.2.1 # homeassistant.components.media_player.anthemav anthemav==1.1.8 From 8760dc9b29d529b162f747acad182dab65828f07 Mon Sep 17 00:00:00 2001 From: Daniel Schaal Date: Mon, 24 Jul 2017 08:47:38 +0200 Subject: [PATCH 22/27] Check if /dev/input/by-id exists (#8601) --- homeassistant/components/keyboard_remote.py | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/keyboard_remote.py b/homeassistant/components/keyboard_remote.py index 88d406ace0b..5a81f6d2a9e 100644 --- a/homeassistant/components/keyboard_remote.py +++ b/homeassistant/components/keyboard_remote.py @@ -94,20 +94,25 @@ class KeyboardRemote(threading.Thread): if self.dev is not None: _LOGGER.debug("Keyboard connected, %s", self.device_id) else: - id_folder = '/dev/input/by-id/' - device_names = [InputDevice(file_name).name - for file_name in list_devices()] _LOGGER.debug( 'Keyboard not connected, %s.\n\ - Check /dev/input/event* permissions.\ - Possible device names are:\n %s.\n \ - Possible device descriptors are %s:\n %s', - self.device_id, - device_names, - id_folder, - os.listdir(id_folder) + Check /dev/input/event* permissions.', + self.device_id ) + id_folder = '/dev/input/by-id/' + + if os.path.isdir(id_folder): + device_names = [InputDevice(file_name).name + for file_name in list_devices()] + _LOGGER.debug( + 'Possible device names are:\n %s.\n \ + Possible device descriptors are %s:\n %s', + device_names, + id_folder, + os.listdir(id_folder) + ) + threading.Thread.__init__(self) self.stopped = threading.Event() self.hass = hass From e4317a6741db56ca50ea388184c9ef7b542fb6ba Mon Sep 17 00:00:00 2001 From: Phil Cole Date: Mon, 24 Jul 2017 08:48:20 +0200 Subject: [PATCH 23/27] Tado Fix #8606 (#8621) Handle case where 'mode' and 'fanSpeed' are missing JSON. Based on changes in commit https://github.com/wmalgadey/tado_component/commit/adfb608f86b8bf4c1c43e71b4067cbfe1de9ba85 --- homeassistant/components/climate/tado.py | 47 ++++++++++++++---------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/climate/tado.py b/homeassistant/components/climate/tado.py index 8a2e6621af3..459cbec0497 100644 --- a/homeassistant/components/climate/tado.py +++ b/homeassistant/components/climate/tado.py @@ -273,31 +273,38 @@ class TadoClimate(ClimateDevice): else: self._device_is_active = True + overlay = False + overlay_data = None + termination = self._current_operation + cooling = False + fan_speed = CONST_MODE_OFF + + if 'overlay' in data: + overlay_data = data['overlay'] + overlay = overlay_data is not None + + if overlay: + termination = overlay_data['termination']['type'] + + if 'setting' in overlay_data: + setting_data = overlay_data['setting'] + setting = setting is not None + + if setting: + if 'mode' in setting_data: + cooling = setting_data['mode'] == 'COOL' + + if 'fanSpeed' in setting_data: + fan_speed = setting_data['fanSpeed'] + if self._device_is_active: - overlay = False - overlay_data = None - termination = self._current_operation - cooling = False - fan_speed = CONST_MODE_OFF - - if 'overlay' in data: - overlay_data = data['overlay'] - overlay = overlay_data is not None - - if overlay: - termination = overlay_data['termination']['type'] - - if 'setting' in overlay_data: - cooling = overlay_data['setting']['mode'] == 'COOL' - fan_speed = overlay_data['setting']['fanSpeed'] - # If you set mode manualy to off, there will be an overlay # and a termination, but we want to see the mode "OFF" - self._overlay_mode = termination self._current_operation = termination - self._cooling = cooling - self._current_fan = fan_speed + + self._cooling = cooling + self._current_fan = fan_speed def _control_heating(self): """Send new target temperature to mytado.""" From 8f47a9109c03412d442af7ea583b3ea407295837 Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Sun, 23 Jul 2017 23:49:03 -0700 Subject: [PATCH 24/27] prometheus: Fix zwave battery level (#8615) --- homeassistant/components/prometheus.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/prometheus.py b/homeassistant/components/prometheus.py index 18a3a932d36..f244bcdd740 100644 --- a/homeassistant/components/prometheus.py +++ b/homeassistant/components/prometheus.py @@ -216,6 +216,9 @@ class Metrics: value = state_helper.state_as_number(state) metric.labels(**self._labels(state)).set(value) + def _handle_zwave(self, state): + self._battery(state) + class PrometheusView(HomeAssistantView): """Handle Prometheus requests.""" From 0c09cfc6c445950db9399b451fceb93466d2768a Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Mon, 24 Jul 2017 08:51:07 +0200 Subject: [PATCH 25/27] ubus: Make multiple instances work again (#8571) Back in "ubus: Refresh session on Access denied (#8111)" I added the decorator _refresh_on_acccess_denied. Somehow that stopped multiple ubus trackers from working in parallel, and only the one first init'ed worked. Changing the order of the decorators fixes the issue but, I'm sorry to say I can't figure out why. There's some magic somewhere which I'm missing. Signed-off-by: Anton Lundin --- homeassistant/components/device_tracker/ubus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/device_tracker/ubus.py b/homeassistant/components/device_tracker/ubus.py index e3cef60c376..8d4cd1dcd73 100644 --- a/homeassistant/components/device_tracker/ubus.py +++ b/homeassistant/components/device_tracker/ubus.py @@ -115,8 +115,8 @@ class UbusDeviceScanner(DeviceScanner): return self.mac2name.get(device.upper(), None) - @Throttle(MIN_TIME_BETWEEN_SCANS) @_refresh_on_acccess_denied + @Throttle(MIN_TIME_BETWEEN_SCANS) def _update_info(self): """Ensure the information from the Luci router is up to date. From 36e266442f946156b5b25bc7fb364d2acaabfc61 Mon Sep 17 00:00:00 2001 From: Jeff Wilson Date: Mon, 24 Jul 2017 02:53:03 -0400 Subject: [PATCH 26/27] Properly slugify switch.flux update service name (#8545) --- homeassistant/components/switch/flux.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/switch/flux.py b/homeassistant/components/switch/flux.py index dea4285e3a9..5613bcbb19e 100644 --- a/homeassistant/components/switch/flux.py +++ b/homeassistant/components/switch/flux.py @@ -15,6 +15,7 @@ from homeassistant.components.switch import DOMAIN, SwitchDevice from homeassistant.const import CONF_NAME, CONF_PLATFORM from homeassistant.helpers.event import track_time_change from homeassistant.helpers.sun import get_astral_event_date +from homeassistant.util import slugify from homeassistant.util.color import ( color_temperature_to_rgb, color_RGB_to_xy, color_temperature_kelvin_to_mired) @@ -111,7 +112,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): """Update lights.""" flux.flux_update() - hass.services.register(DOMAIN, name + '_update', update) + service_name = slugify("{} {}".format(name, 'update')) + hass.services.register(DOMAIN, service_name, update) class FluxSwitch(SwitchDevice): From c100b8cb52dcc1ec91d953fc42bab183292b3f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B8yer=20Iversen?= Date: Thu, 20 Jul 2017 11:12:42 +0200 Subject: [PATCH 27/27] Add is_lighting4 to RfxtrxBinarySensor (#8563) --- homeassistant/components/binary_sensor/rfxtrx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/binary_sensor/rfxtrx.py b/homeassistant/components/binary_sensor/rfxtrx.py index b70169dc594..e86c948e191 100644 --- a/homeassistant/components/binary_sensor/rfxtrx.py +++ b/homeassistant/components/binary_sensor/rfxtrx.py @@ -154,6 +154,7 @@ class RfxtrxBinarySensor(BinarySensorDevice): self._device_class = device_class self._off_delay = off_delay self._state = False + self.is_lighting4 = False self.delay_listener = None self._data_bits = data_bits self._cmd_on = cmd_on