Improve support for 1. generation mill heater (#18423)

* Improve support for 1. gen mill heater

* style

* None operation_list for gen 1 heater

* Remove SUPPORT_OPERATION_MODE for gen 1
This commit is contained in:
Daniel Høyer Iversen 2018-11-14 19:35:12 +01:00 committed by GitHub
parent 80e616cacf
commit 00235cf6f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -19,7 +19,7 @@ from homeassistant.const import (
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
REQUIREMENTS = ['millheater==0.2.3'] REQUIREMENTS = ['millheater==0.2.4']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -32,8 +32,7 @@ MIN_TEMP = 5
SERVICE_SET_ROOM_TEMP = 'mill_set_room_temperature' SERVICE_SET_ROOM_TEMP = 'mill_set_room_temperature'
SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE |
SUPPORT_FAN_MODE | SUPPORT_ON_OFF | SUPPORT_FAN_MODE)
SUPPORT_OPERATION_MODE)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_USERNAME): cv.string,
@ -92,7 +91,9 @@ class MillHeater(ClimateDevice):
@property @property
def supported_features(self): def supported_features(self):
"""Return the list of supported features.""" """Return the list of supported features."""
return SUPPORT_FLAGS if self._heater.is_gen1:
return SUPPORT_FLAGS
return SUPPORT_FLAGS | SUPPORT_ON_OFF | SUPPORT_OPERATION_MODE
@property @property
def available(self): def available(self):
@ -157,6 +158,8 @@ class MillHeater(ClimateDevice):
@property @property
def is_on(self): def is_on(self):
"""Return true if heater is on.""" """Return true if heater is on."""
if self._heater.is_gen1:
return True
return self._heater.power_status == 1 return self._heater.power_status == 1
@property @property
@ -177,6 +180,8 @@ class MillHeater(ClimateDevice):
@property @property
def operation_list(self): def operation_list(self):
"""List of available operation modes.""" """List of available operation modes."""
if self._heater.is_gen1:
return None
return [STATE_HEAT, STATE_OFF] return [STATE_HEAT, STATE_OFF]
async def async_set_temperature(self, **kwargs): async def async_set_temperature(self, **kwargs):
@ -211,7 +216,7 @@ class MillHeater(ClimateDevice):
"""Set operation mode.""" """Set operation mode."""
if operation_mode == STATE_HEAT: if operation_mode == STATE_HEAT:
await self.async_turn_on() await self.async_turn_on()
elif operation_mode == STATE_OFF: elif operation_mode == STATE_OFF and not self._heater.is_gen1:
await self.async_turn_off() await self.async_turn_off()
else: else:
_LOGGER.error("Unrecognized operation mode: %s", operation_mode) _LOGGER.error("Unrecognized operation mode: %s", operation_mode)

View File

@ -628,7 +628,7 @@ mficlient==0.3.0
miflora==0.4.0 miflora==0.4.0
# homeassistant.components.climate.mill # homeassistant.components.climate.mill
millheater==0.2.3 millheater==0.2.4
# homeassistant.components.sensor.mitemp_bt # homeassistant.components.sensor.mitemp_bt
mitemp_bt==0.0.1 mitemp_bt==0.0.1