Skip to content

Commit

Permalink
Mill, support opeation mode (#18059)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielhiversen authored and pvizeli committed Oct 31, 2018
1 parent 7363378 commit 145677e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions homeassistant/components/climate/mill.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import voluptuous as vol

from homeassistant.components.climate import (
ClimateDevice, DOMAIN, PLATFORM_SCHEMA,
ClimateDevice, DOMAIN, PLATFORM_SCHEMA, STATE_HEAT,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE,
SUPPORT_ON_OFF)
SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE)
from homeassistant.const import (
ATTR_TEMPERATURE, CONF_PASSWORD, CONF_USERNAME,
STATE_ON, STATE_OFF, TEMP_CELSIUS)
Expand All @@ -32,7 +32,8 @@
SERVICE_SET_ROOM_TEMP = 'mill_set_room_temperature'

SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE |
SUPPORT_FAN_MODE | SUPPORT_ON_OFF)
SUPPORT_FAN_MODE | SUPPORT_ON_OFF |
SUPPORT_OPERATION_MODE)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string,
Expand Down Expand Up @@ -167,6 +168,16 @@ def max_temp(self):
"""Return the maximum temperature."""
return MAX_TEMP

@property
def current_operation(self):
"""Return current operation."""
return STATE_HEAT if self.is_on else STATE_OFF

@property
def operation_list(self):
"""List of available operation modes."""
return [STATE_HEAT, STATE_OFF]

async def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
Expand Down Expand Up @@ -194,3 +205,14 @@ async def async_turn_off(self):
async def async_update(self):
"""Retrieve latest state."""
self._heater = await self._conn.update_device(self._heater.device_id)

async def async_set_operation_mode(self, operation_mode):
"""Set operation mode."""
if operation_mode == STATE_HEAT:
await self.async_turn_on()
elif operation_mode == STATE_OFF:
await self.async_turn_off()
else:
_LOGGER.error("Unrecognized operation mode: %s", operation_mode)
return
self.schedule_update_ha_state()

0 comments on commit 145677e

Please sign in to comment.