Skip to content

Commit

Permalink
fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrike committed Mar 19, 2019
1 parent d5264a1 commit 0d2e8cd
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions homeassistant/components/tfiac/climate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Climate platform that offers a climate device for the TFIAC protocol."""
from concurrent.futures import _base as futures
import logging
from concurrent import futures
from datetime import timedelta
import logging

import voluptuous as vol

Expand All @@ -13,7 +13,6 @@
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, TEMP_FAHRENHEIT
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
from homeassistant.util.temperature import convert as convert_temperature

DOMAIN = 'tfiac'

Expand All @@ -29,13 +28,20 @@

MIN_TEMP = 61
MAX_TEMP = 88
OPERATION_LIST = {
OPERATION_MAP = {
STATE_HEAT: 'heat',
STATE_AUTO: 'selfFeel',
STATE_DRY: 'dehumi',
STATE_FAN_ONLY: 'fan',
STATE_COOL: 'cool',
}
OPERATION_MAP_REV = {
'heat': STATE_HEAT,
'selfFeel': STATE_AUTO,
'dehumi': STATE_DRY,
'fan': STATE_FAN_ONLY,
'cool': STATE_COOL,
}
FAN_LIST = ['Auto', 'Low', 'Middle', 'High']
SWING_LIST = [
'Off',
Expand All @@ -57,19 +63,19 @@ async def async_setup_platform(hass, config, async_add_devices,
"""Set up the TFIAC climate device."""
from pytfiac import Tfiac

host = config.get(CONF_HOST)
if host is not None:
tfiac_client = Tfiac(host)
tfiac_client = Tfiac(config[CONF_HOST])
try:
await tfiac_client.update()
async_add_devices([TfiacClimate(hass, tfiac_client)])
except futures.TimeoutError:
return
async_add_devices([TfiacClimate(hass, tfiac_client)])


class TfiacClimate(ClimateDevice):
"""TFIAC class."""

def __init__(self, hass, client):
"""Init class."""
hass.data[DOMAIN] = self
self._client = client
self._available = True

Expand All @@ -96,14 +102,12 @@ def supported_features(self):
@property
def min_temp(self):
"""Return the minimum temperature."""
return convert_temperature(MIN_TEMP, TEMP_FAHRENHEIT,
self.temperature_unit)
return MIN_TEMP

@property
def max_temp(self):
"""Return the maximum temperature."""
return convert_temperature(MAX_TEMP, TEMP_FAHRENHEIT,
self.temperature_unit)
return MAX_TEMP

@property
def name(self):
Expand All @@ -129,8 +133,7 @@ def current_temperature(self):
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""
operation = self._client.status['operation']
return {v: k
for k, v in OPERATION_LIST.items()}.get(operation, operation)
return OPERATION_MAP_REV.get(operation, operation)

@property
def is_on(self):
Expand All @@ -140,7 +143,7 @@ def is_on(self):
@property
def operation_list(self):
"""Return the list of available operation modes."""
return sorted(OPERATION_LIST)
return sorted(OPERATION_MAP)

@property
def current_fan_mode(self):
Expand Down Expand Up @@ -171,7 +174,7 @@ async def async_set_temperature(self, **kwargs):
async def async_set_operation_mode(self, operation_mode):
"""Set new operation mode."""
await self._client.set_state(OPERATION_MODE,
OPERATION_LIST[operation_mode])
OPERATION_MAP[operation_mode])

async def async_set_fan_mode(self, fan_mode):
"""Set new fan mode."""
Expand Down

0 comments on commit 0d2e8cd

Please sign in to comment.