Mill service (#17971)

* Mill service

* style
This commit is contained in:
Daniel Høyer Iversen 2018-10-29 23:36:49 +01:00 committed by Fabian Affolter
parent 32cb666dac
commit 98163504fb
3 changed files with 52 additions and 6 deletions

View file

@ -10,7 +10,7 @@ import logging
import voluptuous as vol
from homeassistant.components.climate import (
ClimateDevice, PLATFORM_SCHEMA,
ClimateDevice, DOMAIN, PLATFORM_SCHEMA,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE,
SUPPORT_ON_OFF)
from homeassistant.const import (
@ -19,12 +19,18 @@ from homeassistant.const import (
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
REQUIREMENTS = ['millheater==0.2.1']
REQUIREMENTS = ['millheater==0.2.2']
_LOGGER = logging.getLogger(__name__)
ATTR_AWAY_TEMP = 'away_temp'
ATTR_COMFORT_TEMP = 'comfort_temp'
ATTR_ROOM_NAME = 'room_name'
ATTR_SLEEP_TEMP = 'sleep_temp'
MAX_TEMP = 35
MIN_TEMP = 5
SERVICE_SET_ROOM_TEMP = 'mill_set_room_temperature'
SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE |
SUPPORT_FAN_MODE | SUPPORT_ON_OFF)
@ -33,6 +39,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_PASSWORD): cv.string,
})
SET_ROOM_TEMP_SCHEMA = vol.Schema({
vol.Required(ATTR_ROOM_NAME): cv.string,
vol.Optional(ATTR_AWAY_TEMP): cv.positive_int,
vol.Optional(ATTR_COMFORT_TEMP): cv.positive_int,
vol.Optional(ATTR_SLEEP_TEMP): cv.positive_int,
})
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
@ -52,6 +65,20 @@ async def async_setup_platform(hass, config, async_add_entities,
dev.append(MillHeater(heater, mill_data_connection))
async_add_entities(dev)
async def set_room_temp(service):
"""Set room temp."""
room_name = service.data.get(ATTR_ROOM_NAME)
sleep_temp = service.data.get(ATTR_SLEEP_TEMP)
comfort_temp = service.data.get(ATTR_COMFORT_TEMP)
away_temp = service.data.get(ATTR_AWAY_TEMP)
await mill_data_connection.set_room_temperatures_by_name(room_name,
sleep_temp,
comfort_temp,
away_temp)
hass.services.async_register(DOMAIN, SERVICE_SET_ROOM_TEMP,
set_room_temp, schema=SET_ROOM_TEMP_SCHEMA)
class MillHeater(ClimateDevice):
"""Representation of a Mill Thermostat device."""
@ -88,9 +115,12 @@ class MillHeater(ClimateDevice):
room = self._heater.room.name
else:
room = "Independent device"
return {"room": room,
"open_window": self._heater.open_window,
"heating": self._heater.is_heating}
return {
"room": room,
"open_window": self._heater.open_window,
"heating": self._heater.is_heating,
"controlled_by_tibber": self._heater.tibber_control,
}
@property
def temperature_unit(self):

View file

@ -116,6 +116,22 @@ ecobee_resume_program:
description: Resume all events and return to the scheduled program. This default to false which removes only the top event.
example: true
mill_set_room_temperature:
description: Set Mill room temperatures.
fields:
room_name:
description: Name of room to change.
example: 'kitchen'
away_temp:
description: Away temp.
example: 12
comfort_temp:
description: Comfort temp.
example: 22
sleep_temp:
description: Sleep temp.
example: 17
nuheat_resume_program:
description: Resume the programmed schedule.
fields:

View file

@ -615,7 +615,7 @@ mficlient==0.3.0
miflora==0.4.0
# homeassistant.components.climate.mill
millheater==0.2.1
millheater==0.2.2
# homeassistant.components.sensor.mitemp_bt
mitemp_bt==0.0.1