mirror of
https://github.com/home-assistant/core.git
synced 2025-05-29 18:27:07 +00:00
Fix for Sensibo with missing temperature (#10801)
* Fix for sensibo woth missing temperature * Use new temperatureUnit API field
This commit is contained in:
parent
934c19445d
commit
8c5d6ee9c3
@ -35,7 +35,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
_FETCH_FIELDS = ','.join([
|
_FETCH_FIELDS = ','.join([
|
||||||
'room{name}', 'measurements', 'remoteCapabilities',
|
'room{name}', 'measurements', 'remoteCapabilities',
|
||||||
'acState', 'connectionStatus{isAlive}'])
|
'acState', 'connectionStatus{isAlive}', 'temperatureUnit'])
|
||||||
_INITIAL_FETCH_FIELDS = 'id,' + _FETCH_FIELDS
|
_INITIAL_FETCH_FIELDS = 'id,' + _FETCH_FIELDS
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
devices.append(SensiboClimate(client, dev))
|
devices.append(SensiboClimate(client, dev))
|
||||||
except (aiohttp.client_exceptions.ClientConnectorError,
|
except (aiohttp.client_exceptions.ClientConnectorError,
|
||||||
asyncio.TimeoutError):
|
asyncio.TimeoutError):
|
||||||
_LOGGER.exception('Failed to connct to Sensibo servers.')
|
_LOGGER.exception('Failed to connect to Sensibo servers.')
|
||||||
raise PlatformNotReady
|
raise PlatformNotReady
|
||||||
|
|
||||||
if devices:
|
if devices:
|
||||||
@ -63,7 +63,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
|
|
||||||
|
|
||||||
class SensiboClimate(ClimateDevice):
|
class SensiboClimate(ClimateDevice):
|
||||||
"""Representation os a Sensibo device."""
|
"""Representation of a Sensibo device."""
|
||||||
|
|
||||||
def __init__(self, client, data):
|
def __init__(self, client, data):
|
||||||
"""Build SensiboClimate.
|
"""Build SensiboClimate.
|
||||||
@ -84,11 +84,16 @@ class SensiboClimate(ClimateDevice):
|
|||||||
self._operations = sorted(capabilities['modes'].keys())
|
self._operations = sorted(capabilities['modes'].keys())
|
||||||
self._current_capabilities = capabilities[
|
self._current_capabilities = capabilities[
|
||||||
'modes'][self.current_operation]
|
'modes'][self.current_operation]
|
||||||
temperature_unit_key = self._ac_states['temperatureUnit']
|
temperature_unit_key = data.get('temperatureUnit') or \
|
||||||
self._temperature_unit = \
|
self._ac_states.get('temperatureUnit')
|
||||||
TEMP_CELSIUS if temperature_unit_key == 'C' else TEMP_FAHRENHEIT
|
if temperature_unit_key:
|
||||||
self._temperatures_list = self._current_capabilities[
|
self._temperature_unit = TEMP_CELSIUS if \
|
||||||
'temperatures'][temperature_unit_key]['values']
|
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
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
@ -108,7 +113,7 @@ class SensiboClimate(ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self):
|
||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
return self._ac_states['targetTemperature']
|
return self._ac_states.get('targetTemperature')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_step(self):
|
def target_temperature_step(self):
|
||||||
@ -178,12 +183,14 @@ class SensiboClimate(ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature."""
|
||||||
return self._temperatures_list[0]
|
return self._temperatures_list[0] \
|
||||||
|
if len(self._temperatures_list) else super.min_temp()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
"""Return the maximum temperature."""
|
"""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
|
@asyncio.coroutine
|
||||||
def async_set_temperature(self, **kwargs):
|
def async_set_temperature(self, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user