mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add area support to lock service schemas (#25435)
* Add area support to lock service schemas * extend * Fixed tests * Fixed tests
This commit is contained in:
parent
4c067ecff7
commit
5e2dfb14fb
@ -4,8 +4,8 @@ import logging
|
||||
from pyhap.const import CATEGORY_DOOR_LOCK
|
||||
|
||||
from homeassistant.components.lock import (
|
||||
ATTR_ENTITY_ID, DOMAIN, STATE_LOCKED, STATE_UNLOCKED)
|
||||
from homeassistant.const import ATTR_CODE, STATE_UNKNOWN
|
||||
DOMAIN, STATE_LOCKED, STATE_UNLOCKED)
|
||||
from homeassistant.const import ATTR_CODE, ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
|
||||
from . import TYPES
|
||||
from .accessories import HomeAccessory
|
||||
|
@ -9,11 +9,11 @@ from homeassistant.loader import bind_hass
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.config_validation import ( # noqa
|
||||
PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE)
|
||||
ENTITY_SERVICE_SCHEMA, PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (
|
||||
ATTR_CODE, ATTR_CODE_FORMAT, ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED,
|
||||
SERVICE_LOCK, SERVICE_UNLOCK, SERVICE_OPEN)
|
||||
ATTR_CODE, ATTR_CODE_FORMAT, STATE_LOCKED, STATE_UNLOCKED, SERVICE_LOCK,
|
||||
SERVICE_UNLOCK, SERVICE_OPEN)
|
||||
from homeassistant.components import group
|
||||
|
||||
ATTR_CHANGED_BY = 'changed_by'
|
||||
@ -28,8 +28,7 @@ GROUP_NAME_ALL_LOCKS = 'all locks'
|
||||
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||
|
||||
LOCK_SERVICE_SCHEMA = vol.Schema({
|
||||
vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids,
|
||||
LOCK_SERVICE_SCHEMA = ENTITY_SERVICE_SCHEMA.extend({
|
||||
vol.Optional(ATTR_CODE): cv.string,
|
||||
})
|
||||
|
||||
|
@ -4,6 +4,7 @@ import logging
|
||||
from homeassistant.core import callback
|
||||
from homeassistant import setup
|
||||
from homeassistant.components import lock
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.const import STATE_ON, STATE_OFF
|
||||
|
||||
from tests.common import (get_test_home_assistant,
|
||||
@ -269,7 +270,7 @@ class TestTemplateLock:
|
||||
assert state.state == lock.STATE_UNLOCKED
|
||||
|
||||
self.hass.services.call(lock.DOMAIN, lock.SERVICE_LOCK, {
|
||||
lock.ATTR_ENTITY_ID: 'lock.template_lock'
|
||||
ATTR_ENTITY_ID: 'lock.template_lock'
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
|
||||
@ -302,7 +303,7 @@ class TestTemplateLock:
|
||||
assert state.state == lock.STATE_LOCKED
|
||||
|
||||
self.hass.services.call(lock.DOMAIN, lock.SERVICE_UNLOCK, {
|
||||
lock.ATTR_ENTITY_ID: 'lock.template_lock'
|
||||
ATTR_ENTITY_ID: 'lock.template_lock'
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user