Skip to content

Commit

Permalink
Changing handling for google_assistant groups to treat them as lights. (
Browse files Browse the repository at this point in the history
home-assistant#10111)

* Fixed aliases warning message

* Fixed test cases

* Changing handling for google_assistant groups to treat them as lights - amending to include user info.

* Enable brightness, RGB, etc for groups in Google Assistant

* Revert color/hue/temp settings

* Change servce from light to homeassistant

* Fixed config_units

* Convert from light to switch

* Change group to switch

* Update tests to switch instead of light for group
  • Loading branch information
snowzach authored and balloob committed Nov 28, 2017
1 parent 0668fba commit 282e37e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/google_assistant/http.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 282e37e

Please sign in to comment.