Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing handling for google_assistant groups to treat them as lights. #10111

Merged
merged 10 commits into from Nov 28, 2017
2 changes: 2 additions & 0 deletions homeassistant/components/google_assistant/http.py
Expand Up @@ -133,6 +133,8 @@ def handle_execute(self,
(service, service_data) = determine_service(
eid, execution.get('command'), execution.get('params'),
hass.config.units)
if domain == "group":
domain = "homeassistant"
success = yield from hass.services.async_call(
domain, service, service_data, blocking=True)
result = {"ids": [eid], "states": {}}
Expand Down
11 changes: 6 additions & 5 deletions homeassistant/components/google_assistant/smart_home.py
Expand Up @@ -39,7 +39,7 @@
# Mapping is [actions schema, primary trait, optional features]
# optional is SUPPORT_* = (trait, command)
MAPPING_COMPONENT = {
group.DOMAIN: [TYPE_SCENE, TRAIT_SCENE, None],
group.DOMAIN: [TYPE_SWITCH, TRAIT_ONOFF, None],
scene.DOMAIN: [TYPE_SCENE, TRAIT_SCENE, None],
script.DOMAIN: [TYPE_SCENE, TRAIT_SCENE, None],
switch.DOMAIN: [TYPE_SWITCH, TRAIT_ONOFF, None],
Expand Down Expand Up @@ -94,10 +94,11 @@ def entity_to_device(entity: Entity, units: UnitSystem):

# use aliases
aliases = entity.attributes.get(CONF_ALIASES)
if isinstance(aliases, list):
device['name']['nicknames'] = aliases
else:
_LOGGER.warning("%s must be a list", CONF_ALIASES)
if aliases:
if isinstance(aliases, list):
device['name']['nicknames'] = aliases
else:
_LOGGER.warning("%s must be a list", CONF_ALIASES)

# add trait if entity supports feature
if class_data[2]:
Expand Down
16 changes: 8 additions & 8 deletions tests/components/google_assistant/__init__.py
Expand Up @@ -75,16 +75,16 @@
'name': {
'name': 'all lights'
},
'traits': ['action.devices.traits.Scene'],
'type': 'action.devices.types.SCENE',
'traits': ['action.devices.traits.OnOff'],
'type': 'action.devices.types.SWITCH',
'willReportState': False
}, {
'id': 'group.all_switches',
'name': {
'name': 'all switches'
},
'traits': ['action.devices.traits.Scene'],
'type': 'action.devices.types.SCENE',
'traits': ['action.devices.traits.OnOff'],
'type': 'action.devices.types.SWITCH',
'willReportState': False
}, {
'id':
Expand Down Expand Up @@ -131,8 +131,8 @@
'name': {
'name': 'all covers'
},
'traits': ['action.devices.traits.Scene'],
'type': 'action.devices.types.SCENE',
'traits': ['action.devices.traits.OnOff'],
'type': 'action.devices.types.SWITCH',
'willReportState': False
}, {
'id':
Expand Down Expand Up @@ -199,8 +199,8 @@
'name': {
'name': 'all fans'
},
'traits': ['action.devices.traits.Scene'],
'type': 'action.devices.types.SCENE',
'traits': ['action.devices.traits.OnOff'],
'type': 'action.devices.types.SWITCH',
'willReportState': False
}, {
'id': 'climate.hvac',
Expand Down