mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
register nuheat_resume_program service
This commit is contained in:
parent
fb90dab471
commit
7de3c62846
@ -6,9 +6,13 @@ https://home-assistant.io/components/climate.nuheat/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from os import path
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ClimateDevice,
|
||||
DOMAIN,
|
||||
SUPPORT_HOLD_MODE,
|
||||
SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
@ -16,10 +20,13 @@ from homeassistant.components.climate import (
|
||||
STATE_HEAT,
|
||||
STATE_IDLE)
|
||||
from homeassistant.components.nuheat import DATA_NUHEAT
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_TEMPERATURE,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
DEPENDENCIES = ["nuheat"]
|
||||
@ -41,6 +48,12 @@ SCHEDULE_HOLD = 3
|
||||
SCHEDULE_RUN = 1
|
||||
SCHEDULE_TEMPORARY_HOLD = 2
|
||||
|
||||
SERVICE_RESUME_PROGRAM = "nuheat_resume_program"
|
||||
|
||||
RESUME_PROGRAM_SCHEMA = vol.Schema({
|
||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids
|
||||
})
|
||||
|
||||
SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_HOLD_MODE |
|
||||
SUPPORT_OPERATION_MODE)
|
||||
|
||||
@ -58,6 +71,30 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
]
|
||||
add_devices(thermostats, True)
|
||||
|
||||
def resume_program_set_service(service):
|
||||
"""Resume the program on the target thermostats."""
|
||||
entity_id = service.data.get(ATTR_ENTITY_ID)
|
||||
|
||||
if entity_id:
|
||||
target_thermostats = [device for device in thermostats
|
||||
if device.entity_id in entity_id]
|
||||
else:
|
||||
target_thermostats = thermostats
|
||||
|
||||
for thermostat in target_thermostats:
|
||||
thermostat.resume_program()
|
||||
|
||||
thermostat.schedule_update_ha_state(True)
|
||||
|
||||
descriptions = load_yaml_config_file(
|
||||
path.join(path.dirname(__file__), "services.yaml"))
|
||||
|
||||
hass.services.register(
|
||||
DOMAIN, SERVICE_RESUME_PROGRAM, resume_program_set_service,
|
||||
descriptions.get(SERVICE_RESUME_PROGRAM),
|
||||
schema=RESUME_PROGRAM_SCHEMA)
|
||||
|
||||
|
||||
|
||||
class NuHeatThermostat(ClimateDevice):
|
||||
"""Representation of a NuHeat Thermostat."""
|
||||
|
@ -100,3 +100,10 @@ ecobee_resume_program:
|
||||
resume_all:
|
||||
description: Resume all events and return to the scheduled program. This default to false which removes only the top event.
|
||||
example: true
|
||||
|
||||
nuheat_resume_program:
|
||||
description: Resume the programmed schedule.
|
||||
fields:
|
||||
entity_id:
|
||||
description: Name(s) of entities to change.
|
||||
example: 'climate.kitchen'
|
||||
|
Loading…
x
Reference in New Issue
Block a user