mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Add "start_irrigation" service for Yardian (#100257)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
d70308ae9f
commit
4788dd2905
14
homeassistant/components/yardian/services.yaml
Normal file
14
homeassistant/components/yardian/services.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
start_irrigation:
|
||||||
|
target:
|
||||||
|
entity:
|
||||||
|
integration: yardian
|
||||||
|
domain: switch
|
||||||
|
fields:
|
||||||
|
duration:
|
||||||
|
required: true
|
||||||
|
default: 6
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 1
|
||||||
|
max: 1440
|
||||||
|
unit_of_measurement: "minutes"
|
@ -16,5 +16,17 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"services": {
|
||||||
|
"start_irrigation": {
|
||||||
|
"name": "Start irrigation",
|
||||||
|
"description": "Starts the irrigation.",
|
||||||
|
"fields": {
|
||||||
|
"duration": {
|
||||||
|
"name": "Duration",
|
||||||
|
"description": "Duration for the target to be turned on."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,23 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import DEFAULT_WATERING_DURATION, DOMAIN
|
from .const import DEFAULT_WATERING_DURATION, DOMAIN
|
||||||
from .coordinator import YardianUpdateCoordinator
|
from .coordinator import YardianUpdateCoordinator
|
||||||
|
|
||||||
|
SERVICE_START_IRRIGATION = "start_irrigation"
|
||||||
|
SERVICE_SCHEMA_START_IRRIGATION = {
|
||||||
|
vol.Required("duration"): cv.positive_int,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -28,6 +36,13 @@ async def async_setup_entry(
|
|||||||
for i in range(len(coordinator.data.zones))
|
for i in range(len(coordinator.data.zones))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
platform = entity_platform.async_get_current_platform()
|
||||||
|
platform.async_register_entity_service(
|
||||||
|
SERVICE_START_IRRIGATION,
|
||||||
|
SERVICE_SCHEMA_START_IRRIGATION,
|
||||||
|
"async_turn_on",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class YardianSwitch(CoordinatorEntity[YardianUpdateCoordinator], SwitchEntity):
|
class YardianSwitch(CoordinatorEntity[YardianUpdateCoordinator], SwitchEntity):
|
||||||
"""Representation of a Yardian switch."""
|
"""Representation of a Yardian switch."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user