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:
parent
9587afc5ce
commit
02d9ed5e36
47 changed files with 538 additions and 626 deletions
|
@ -10,12 +10,13 @@ from homeassistant.const import (
|
|||
SERVICE_LOCK,
|
||||
SERVICE_UNLOCK,
|
||||
SERVICE_OPEN,
|
||||
ENTITY_MATCH_ALL,
|
||||
)
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
|
||||
@bind_hass
|
||||
def lock(hass, entity_id=None, code=None):
|
||||
def lock(hass, entity_id=ENTITY_MATCH_ALL, code=None):
|
||||
"""Lock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
|
@ -26,7 +27,7 @@ def lock(hass, entity_id=None, code=None):
|
|||
hass.services.call(DOMAIN, SERVICE_LOCK, data)
|
||||
|
||||
|
||||
async def async_lock(hass, entity_id=None, code=None):
|
||||
async def async_lock(hass, entity_id=ENTITY_MATCH_ALL, code=None):
|
||||
"""Lock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
|
@ -38,7 +39,7 @@ async def async_lock(hass, entity_id=None, code=None):
|
|||
|
||||
|
||||
@bind_hass
|
||||
def unlock(hass, entity_id=None, code=None):
|
||||
def unlock(hass, entity_id=ENTITY_MATCH_ALL, code=None):
|
||||
"""Unlock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
|
@ -49,7 +50,7 @@ def unlock(hass, entity_id=None, code=None):
|
|||
hass.services.call(DOMAIN, SERVICE_UNLOCK, data)
|
||||
|
||||
|
||||
async def async_unlock(hass, entity_id=None, code=None):
|
||||
async def async_unlock(hass, entity_id=ENTITY_MATCH_ALL, code=None):
|
||||
"""Lock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
|
@ -61,7 +62,7 @@ async def async_unlock(hass, entity_id=None, code=None):
|
|||
|
||||
|
||||
@bind_hass
|
||||
def open_lock(hass, entity_id=None, code=None):
|
||||
def open_lock(hass, entity_id=ENTITY_MATCH_ALL, code=None):
|
||||
"""Open all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
|
@ -72,7 +73,7 @@ def open_lock(hass, entity_id=None, code=None):
|
|||
hass.services.call(DOMAIN, SERVICE_OPEN, data)
|
||||
|
||||
|
||||
async def async_open_lock(hass, entity_id=None, code=None):
|
||||
async def async_open_lock(hass, entity_id=ENTITY_MATCH_ALL, code=None):
|
||||
"""Lock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue