mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add override duration for genius hub switches (#45558)
This commit is contained in:
parent
71c169c84f
commit
da713e206d
@ -26,3 +26,15 @@ set_zone_override:
|
||||
description: >-
|
||||
The duration of the override. Optional, default 1 hour, maximum 24 hours.
|
||||
example: '{"minutes": 135}'
|
||||
|
||||
set_switch_override:
|
||||
description: >-
|
||||
Override switch for a given duration.
|
||||
fields:
|
||||
entity_id:
|
||||
description: The zone's entity_id.
|
||||
example: switch.study
|
||||
duration:
|
||||
description: >-
|
||||
The duration of the override. Optional, default 1 hour, maximum 24 hours.
|
||||
example: '{"minutes": 135}'
|
||||
|
@ -1,13 +1,29 @@
|
||||
"""Support for Genius Hub switch/outlet devices."""
|
||||
from datetime import timedelta
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import DEVICE_CLASS_OUTLET, SwitchEntity
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
||||
from . import DOMAIN, GeniusZone
|
||||
|
||||
ATTR_DURATION = "duration"
|
||||
from . import ATTR_DURATION, DOMAIN, GeniusZone
|
||||
|
||||
GH_ON_OFF_ZONE = "on / off"
|
||||
|
||||
SVC_SET_SWITCH_OVERRIDE = "set_switch_override"
|
||||
|
||||
SET_SWITCH_OVERRIDE_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_ENTITY_ID): cv.entity_id,
|
||||
vol.Optional(ATTR_DURATION): vol.All(
|
||||
cv.time_period,
|
||||
vol.Range(min=timedelta(minutes=5), max=timedelta(days=1)),
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
|
||||
@ -26,6 +42,15 @@ async def async_setup_platform(
|
||||
]
|
||||
)
|
||||
|
||||
# Register custom services
|
||||
platform = entity_platform.current_platform.get()
|
||||
|
||||
platform.async_register_entity_service(
|
||||
SVC_SET_SWITCH_OVERRIDE,
|
||||
SET_SWITCH_OVERRIDE_SCHEMA,
|
||||
"async_turn_on",
|
||||
)
|
||||
|
||||
|
||||
class GeniusSwitch(GeniusZone, SwitchEntity):
|
||||
"""Representation of a Genius Hub switch."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user