mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Mill, support opeation mode (#18059)
This commit is contained in:
parent
7363378ac4
commit
145677ed75
@ -10,9 +10,9 @@ import logging
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
ClimateDevice, DOMAIN, PLATFORM_SCHEMA,
|
ClimateDevice, DOMAIN, PLATFORM_SCHEMA, STATE_HEAT,
|
||||||
SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE,
|
SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE,
|
||||||
SUPPORT_ON_OFF)
|
SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_TEMPERATURE, CONF_PASSWORD, CONF_USERNAME,
|
ATTR_TEMPERATURE, CONF_PASSWORD, CONF_USERNAME,
|
||||||
STATE_ON, STATE_OFF, TEMP_CELSIUS)
|
STATE_ON, STATE_OFF, TEMP_CELSIUS)
|
||||||
@ -32,7 +32,8 @@ 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_ON_OFF |
|
||||||
|
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,
|
||||||
@ -167,6 +168,16 @@ class MillHeater(ClimateDevice):
|
|||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature."""
|
||||||
return MAX_TEMP
|
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):
|
async def async_set_temperature(self, **kwargs):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
@ -194,3 +205,14 @@ class MillHeater(ClimateDevice):
|
|||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
self._heater = await self._conn.update_device(self._heater.device_id)
|
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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user