Do not select all entities when omitting entity ID in service call (#29178)
* Do not select all entities when omitting entity ID * Address comments Matthew * Require either area_id or entity_id * Fix tests * Fix test
This commit is contained in:
1 parent
9587afc5ce
commit
02d9ed5e36
47 files changed
+538
-626
No files matched your search
@@ -6,7 +6,6 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_ICON, CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.config_validation import ENTITY_SERVICE_SCHEMA
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
@@ -37,10 +36,6 @@ SERVICE_PAUSE = "pause"
|
||||
SERVICE_CANCEL = "cancel"
|
||||
SERVICE_FINISH = "finish"
|
||||
|
||||
SERVICE_SCHEMA_DURATION = ENTITY_SERVICE_SCHEMA.extend(
|
||||
{vol.Optional(ATTR_DURATION, default=timedelta(DEFAULT_DURATION)): cv.time_period}
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: cv.schema_with_slug_keys(
|
||||
@@ -80,17 +75,17 @@ async def async_setup(hass, config):
|
||||
return False
|
||||
|
||||
component.async_register_entity_service(
|
||||
SERVICE_START, SERVICE_SCHEMA_DURATION, "async_start"
|
||||
)
|
||||
component.async_register_entity_service(
|
||||
SERVICE_PAUSE, ENTITY_SERVICE_SCHEMA, "async_pause"
|
||||
)
|
||||
component.async_register_entity_service(
|
||||
SERVICE_CANCEL, ENTITY_SERVICE_SCHEMA, "async_cancel"
|
||||
)
|
||||
component.async_register_entity_service(
|
||||
SERVICE_FINISH, ENTITY_SERVICE_SCHEMA, "async_finish"
|
||||
SERVICE_START,
|
||||
{
|
||||
vol.Optional(
|
||||
ATTR_DURATION, default=timedelta(DEFAULT_DURATION)
|
||||
): cv.time_period
|
||||
},
|
||||
"async_start",
|
||||
)
|
||||
component.async_register_entity_service(SERVICE_PAUSE, {}, "async_pause")
|
||||
component.async_register_entity_service(SERVICE_CANCEL, {}, "async_cancel")
|
||||
component.async_register_entity_service(SERVICE_FINISH, {}, "async_finish")
|
||||
|
||||
await component.async_add_entities(entities)
|
||||
return True
|
||||
|
||||
Reference in new issue
Block a user