Merge pull request #18958 from home-assistant/rc

0.83.3
This commit is contained in:
Paulus Schoutsen 2018-12-03 13:56:35 +01:00 committed by GitHub
commit acd2f55d4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 57 additions and 19 deletions

View File

@ -190,6 +190,7 @@ class AuthManager:
credentials=credentials, credentials=credentials,
name=info.name, name=info.name,
is_active=info.is_active, is_active=info.is_active,
group_ids=[GROUP_ID_ADMIN],
) )
self.hass.bus.async_fire(EVENT_USER_ADDED, { self.hass.bus.async_fire(EVENT_USER_ADDED, {

View File

@ -14,7 +14,7 @@ from homeassistant.const import (
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.discovery import async_load_platform
REQUIREMENTS = ['aioasuswrt==1.1.11'] REQUIREMENTS = ['aioasuswrt==1.1.13']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -186,9 +186,9 @@ class Cloud:
self._gactions_config = ga_h.Config( self._gactions_config = ga_h.Config(
should_expose=should_expose, should_expose=should_expose,
allow_unlock=self.prefs.google_allow_unlock,
agent_user_id=self.claims['cognito:username'], agent_user_id=self.claims['cognito:username'],
entity_config=conf.get(CONF_ENTITY_CONFIG), entity_config=conf.get(CONF_ENTITY_CONFIG),
allow_unlock=self.prefs.google_allow_unlock,
) )
return self._gactions_config return self._gactions_config

View File

@ -14,7 +14,7 @@ from homeassistant.components.device_tracker import (
DOMAIN, PLATFORM_SCHEMA, DeviceScanner) DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
REQUIREMENTS = ['ghlocalapi==0.1.0'] REQUIREMENTS = ['ghlocalapi==0.3.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -89,4 +89,5 @@ class GoogleHomeDeviceScanner(DeviceScanner):
devices[uuid]['btle_mac_address'] = device['mac_address'] devices[uuid]['btle_mac_address'] = device['mac_address']
devices[uuid]['ghname'] = ghname devices[uuid]['ghname'] = ghname
devices[uuid]['source_type'] = 'bluetooth' devices[uuid]['source_type'] = 'bluetooth'
await self.scanner.clear_scan_result()
self.last_results = devices self.last_results = devices

View File

@ -16,8 +16,8 @@ class SmartHomeError(Exception):
class Config: class Config:
"""Hold the configuration for Google Assistant.""" """Hold the configuration for Google Assistant."""
def __init__(self, should_expose, agent_user_id, entity_config=None, def __init__(self, should_expose, allow_unlock, agent_user_id,
allow_unlock=False): entity_config=None):
"""Initialize the configuration.""" """Initialize the configuration."""
self.should_expose = should_expose self.should_expose = should_expose
self.agent_user_id = agent_user_id self.agent_user_id = agent_user_id

View File

@ -15,6 +15,7 @@ from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
from .const import ( from .const import (
GOOGLE_ASSISTANT_API_ENDPOINT, GOOGLE_ASSISTANT_API_ENDPOINT,
CONF_ALLOW_UNLOCK,
CONF_EXPOSE_BY_DEFAULT, CONF_EXPOSE_BY_DEFAULT,
CONF_EXPOSED_DOMAINS, CONF_EXPOSED_DOMAINS,
CONF_ENTITY_CONFIG, CONF_ENTITY_CONFIG,
@ -32,6 +33,7 @@ def async_register_http(hass, cfg):
expose_by_default = cfg.get(CONF_EXPOSE_BY_DEFAULT) expose_by_default = cfg.get(CONF_EXPOSE_BY_DEFAULT)
exposed_domains = cfg.get(CONF_EXPOSED_DOMAINS) exposed_domains = cfg.get(CONF_EXPOSED_DOMAINS)
entity_config = cfg.get(CONF_ENTITY_CONFIG) or {} entity_config = cfg.get(CONF_ENTITY_CONFIG) or {}
allow_unlock = cfg.get(CONF_ALLOW_UNLOCK, False)
def is_exposed(entity) -> bool: def is_exposed(entity) -> bool:
"""Determine if an entity should be exposed to Google Assistant.""" """Determine if an entity should be exposed to Google Assistant."""
@ -57,7 +59,7 @@ def async_register_http(hass, cfg):
return is_default_exposed or explicit_expose return is_default_exposed or explicit_expose
hass.http.register_view( hass.http.register_view(
GoogleAssistantView(is_exposed, entity_config)) GoogleAssistantView(is_exposed, entity_config, allow_unlock))
class GoogleAssistantView(HomeAssistantView): class GoogleAssistantView(HomeAssistantView):
@ -67,15 +69,17 @@ class GoogleAssistantView(HomeAssistantView):
name = 'api:google_assistant' name = 'api:google_assistant'
requires_auth = True requires_auth = True
def __init__(self, is_exposed, entity_config): def __init__(self, is_exposed, entity_config, allow_unlock):
"""Initialize the Google Assistant request handler.""" """Initialize the Google Assistant request handler."""
self.is_exposed = is_exposed self.is_exposed = is_exposed
self.entity_config = entity_config self.entity_config = entity_config
self.allow_unlock = allow_unlock
async def post(self, request: Request) -> Response: async def post(self, request: Request) -> Response:
"""Handle Google Assistant requests.""" """Handle Google Assistant requests."""
message = await request.json() # type: dict message = await request.json() # type: dict
config = Config(self.is_exposed, config = Config(self.is_exposed,
self.allow_unlock,
request['hass_user'].id, request['hass_user'].id,
self.entity_config) self.entity_config)
result = await async_handle_message( result = await async_handle_message(

View File

@ -68,7 +68,7 @@ class AsuswrtRXSensor(AsuswrtSensor):
async def async_update(self): async def async_update(self):
"""Fetch new state data for the sensor.""" """Fetch new state data for the sensor."""
await super().async_update() await super().async_update()
if self._speed is not None: if self._speed:
self._state = round(self._speed[0] / 125000, 2) self._state = round(self._speed[0] / 125000, 2)
@ -86,7 +86,7 @@ class AsuswrtTXSensor(AsuswrtSensor):
async def async_update(self): async def async_update(self):
"""Fetch new state data for the sensor.""" """Fetch new state data for the sensor."""
await super().async_update() await super().async_update()
if self._speed is not None: if self._speed:
self._state = round(self._speed[1] / 125000, 2) self._state = round(self._speed[1] / 125000, 2)
@ -104,7 +104,7 @@ class AsuswrtTotalRXSensor(AsuswrtSensor):
async def async_update(self): async def async_update(self):
"""Fetch new state data for the sensor.""" """Fetch new state data for the sensor."""
await super().async_update() await super().async_update()
if self._rates is not None: if self._rates:
self._state = round(self._rates[0] / 1000000000, 1) self._state = round(self._rates[0] / 1000000000, 1)
@ -122,5 +122,5 @@ class AsuswrtTotalTXSensor(AsuswrtSensor):
async def async_update(self): async def async_update(self):
"""Fetch new state data for the sensor.""" """Fetch new state data for the sensor."""
await super().async_update() await super().async_update()
if self._rates is not None: if self._rates:
self._state = round(self._rates[1] / 1000000000, 1) self._state = round(self._rates[1] / 1000000000, 1)

View File

@ -19,7 +19,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
REQUIREMENTS = ['pytautulli==0.4.0'] REQUIREMENTS = ['pytautulli==0.4.1']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -90,9 +90,9 @@ class TautulliSensor(Entity):
await self.tautulli.async_update() await self.tautulli.async_update()
self.home = self.tautulli.api.home_data self.home = self.tautulli.api.home_data
self.sessions = self.tautulli.api.session_data self.sessions = self.tautulli.api.session_data
self._attributes['Top Movie'] = self.home[0]['rows'][0]['title'] self._attributes['Top Movie'] = self.home.get('movie')
self._attributes['Top TV Show'] = self.home[3]['rows'][0]['title'] self._attributes['Top TV Show'] = self.home.get('tv')
self._attributes['Top User'] = self.home[7]['rows'][0]['user'] self._attributes['Top User'] = self.home.get('user')
for key in self.sessions: for key in self.sessions:
if 'sessions' not in key: if 'sessions' not in key:
self._attributes[key] = self.sessions[key] self._attributes[key] = self.sessions[key]

View File

@ -690,6 +690,10 @@ class WinkDevice(Entity):
@property @property
def unique_id(self): def unique_id(self):
"""Return the unique id of the Wink device.""" """Return the unique id of the Wink device."""
if hasattr(self.wink, 'capability') and \
self.wink.capability() is not None:
return "{}_{}".format(self.wink.object_id(),
self.wink.capability())
return self.wink.object_id() return self.wink.object_id()
@property @property

View File

@ -2,7 +2,7 @@
"""Constants used by Home Assistant components.""" """Constants used by Home Assistant components."""
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 83 MINOR_VERSION = 83
PATCH_VERSION = '2' PATCH_VERSION = '3'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 5, 3) REQUIRED_PYTHON_VER = (3, 5, 3)

View File

@ -86,7 +86,7 @@ abodepy==0.14.0
afsapi==0.0.4 afsapi==0.0.4
# homeassistant.components.asuswrt # homeassistant.components.asuswrt
aioasuswrt==1.1.11 aioasuswrt==1.1.13
# homeassistant.components.device_tracker.automatic # homeassistant.components.device_tracker.automatic
aioautomatic==0.6.5 aioautomatic==0.6.5
@ -422,7 +422,7 @@ geojson_client==0.3
georss_client==0.4 georss_client==0.4
# homeassistant.components.device_tracker.googlehome # homeassistant.components.device_tracker.googlehome
ghlocalapi==0.1.0 ghlocalapi==0.3.5
# homeassistant.components.sensor.gitter # homeassistant.components.sensor.gitter
gitterpy==0.1.7 gitterpy==0.1.7
@ -1154,7 +1154,7 @@ pystride==0.1.7
pysyncthru==0.3.1 pysyncthru==0.3.1
# homeassistant.components.sensor.tautulli # homeassistant.components.sensor.tautulli
pytautulli==0.4.0 pytautulli==0.4.1
# homeassistant.components.media_player.liveboxplaytv # homeassistant.components.media_player.liveboxplaytv
pyteleloisirs==3.4 pyteleloisirs==3.4

View File

@ -870,3 +870,28 @@ async def test_async_remove_user(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(events) == 1 assert len(events) == 1
assert events[0].data['user_id'] == user.id assert events[0].data['user_id'] == user.id
async def test_new_users_admin(mock_hass):
"""Test newly created users are admin."""
manager = await auth.auth_manager_from_config(mock_hass, [{
'type': 'insecure_example',
'users': [{
'username': 'test-user',
'password': 'test-pass',
'name': 'Test Name'
}]
}], [])
ensure_auth_manager_loaded(manager)
user = await manager.async_create_user('Hello')
assert user.is_admin
user_cred = await manager.async_get_or_create_user(auth_models.Credentials(
id='mock-id',
auth_provider_type='insecure_example',
auth_provider_id=None,
data={'username': 'test-user'},
is_new=True,
))
assert user_cred.is_admin

View File

@ -11,6 +11,7 @@ from homeassistant.components.light.demo import DemoLight
BASIC_CONFIG = helpers.Config( BASIC_CONFIG = helpers.Config(
should_expose=lambda state: True, should_expose=lambda state: True,
allow_unlock=False,
agent_user_id='test-agent', agent_user_id='test-agent',
) )
REQ_ID = 'ff36a3cc-ec34-11e6-b1a0-64510650abcf' REQ_ID = 'ff36a3cc-ec34-11e6-b1a0-64510650abcf'
@ -35,6 +36,7 @@ async def test_sync_message(hass):
config = helpers.Config( config = helpers.Config(
should_expose=lambda state: state.entity_id != 'light.not_expose', should_expose=lambda state: state.entity_id != 'light.not_expose',
allow_unlock=False,
agent_user_id='test-agent', agent_user_id='test-agent',
entity_config={ entity_config={
'light.demo_light': { 'light.demo_light': {

View File

@ -25,6 +25,7 @@ from tests.common import async_mock_service
BASIC_CONFIG = helpers.Config( BASIC_CONFIG = helpers.Config(
should_expose=lambda state: True, should_expose=lambda state: True,
allow_unlock=False,
agent_user_id='test-agent', agent_user_id='test-agent',
) )