Google assistant climate mode fix (#10726)

* Changed supported climate modes lookup to be case insensitive by forcing to lower-case

* Fixed style errors. (Blank line and line too long)
pull/10130/merge
braddparker 2017-11-23 15:57:30 -05:00 committed by Paulus Schoutsen
parent 47183ce02e
commit 3ef9c99003
1 changed files with 6 additions and 5 deletions

View File

@ -124,14 +124,15 @@ def entity_to_device(entity: Entity, units: UnitSystem):
if entity.domain == climate.DOMAIN:
modes = ','.join(
m for m in entity.attributes.get(climate.ATTR_OPERATION_LIST, [])
if m in CLIMATE_SUPPORTED_MODES)
m.lower() for m in entity.attributes.get(
climate.ATTR_OPERATION_LIST, [])
if m.lower() in CLIMATE_SUPPORTED_MODES)
device['attributes'] = {
'availableThermostatModes': modes,
'thermostatTemperatureUnit':
'F' if units.temperature_unit == TEMP_FAHRENHEIT else 'C',
}
_LOGGER.debug('Thermostat attributes %s', device['attributes'])
return device
@ -143,7 +144,7 @@ def query_device(entity: Entity, units: UnitSystem) -> dict:
return None
return round(METRIC_SYSTEM.temperature(deg, units.temperature_unit), 1)
if entity.domain == climate.DOMAIN:
mode = entity.attributes.get(climate.ATTR_OPERATION_MODE)
mode = entity.attributes.get(climate.ATTR_OPERATION_MODE).lower()
if mode not in CLIMATE_SUPPORTED_MODES:
mode = 'on'
response = {
@ -218,6 +219,7 @@ def determine_service(
Attempt to return a tuple of service and service_data based on the entity
and action requested.
"""
_LOGGER.debug("Handling command %s with data %s", command, params)
domain = entity_id.split('.')[0]
service_data = {ATTR_ENTITY_ID: entity_id} # type: Dict[str, Any]
# special media_player handling
@ -260,7 +262,6 @@ def determine_service(
service_data['brightness'] = int(brightness / 100 * 255)
return (SERVICE_TURN_ON, service_data)
_LOGGER.debug("Handling command %s with data %s", command, params)
if command == COMMAND_COLOR:
color_data = params.get('color')
if color_data is not None: