8000 Fix for Sensibo with missing temperature by andrey-git · Pull Request #10801 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix for Sensibo with missing temperature #10801

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

Merged
merged 2 commits into from
Nov 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions homeassistant/components/climate/sensibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

_FETCH_FIELDS = ','.join([
'room{name}', 'measurements', 'remoteCapabilities',
'acState', 'connectionStatus{isAlive}'])
'acState', 'connectionStatus{isAlive}', 'temperatureUnit'])
_INITIAL_FETCH_FIELDS = 'id,' + _FETCH_FIELDS


Expand All @@ -55,15 +55,15 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
devices.append(SensiboClimate(client, dev))
except (aiohttp.client_exceptions.ClientConnectorError,
asyncio.TimeoutError):
_LOGGER.exception('Failed to connct to Sensibo servers.')
_LOGGER.exception('Failed to connect to Sensibo servers.')
raise PlatformNotReady

if devices:
async_add_devices(devices)


class SensiboClimate(ClimateDevice):
"""Representation os a Sensibo device."""
"""Representation of a Sensibo device."""

def __init__(self, client, data):
"""Build SensiboClimate.
Expand All @@ -84,11 +84,16 @@ def _do_update(self, data):
self._operations = sorted(capabilities['modes'].keys())
self._current_capabilities = capabilities[
'modes'][self.current_operation]
temperature_unit_key = self._ac_states['temperatureUnit']
self._temperature_unit = \
TEMP_CELSIUS if temperature_unit_key == 'C' else TEMP_FAHRENHEIT
self._temperatures_list = self._current_capabilities[
'temperatures'][temperature_unit_key]['values']
temperature_unit_key = data.get('temperatureUnit') or \
self._ac_states.get('temperatureUnit')
if temperature_unit_key:
self._temperature_unit = TEMP_CELSIUS if \
temperature_unit_key == 'C' else TEMP_FAHRENHEIT
self._temperatures_list = self._current_capabilities[
'temperatures'].get(temperature_unit_key, {}).get('values', [])
else:
self._temperature_unit = self.unit_of_measurement
self._temperatures_list = []

@property
def device_state_attributes(self):
Expand All @@ -108,7 +113,7 @@ def available(self):
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return self._ac_states['targetTemperature']
return self._ac_states.get('targetTemperature')

@property
def target_temperature_step(self):
Expand Down Expand Up @@ -178,12 +183,14 @@ def is_aux_heat_on(self):
@property
def min_temp(self):
"""Return the minimum temperature."""
return self._temperatures_list[0]
return self._temperatures_list[0] \
if len(self._temperatures_list) else super.min_temp()

@property
def max_temp(self):
"""Return the maximum temperature."""
return self._temperatures_list[-1]
return self._temperatures_list[-1] \
if len(self._temperatures_list) else super.max_temp()

@asyncio.coroutine
def async_set_temperature(self, **kwargs):
Expand Down
0