mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Return all attributes that are not None in base lock entity class (#12049)
* Return all attributes that are not None in base lock entity class * Update __init__.py
This commit is contained in:
parent
e51427b284
commit
71cb4df817
@ -41,6 +41,11 @@ LOCK_SERVICE_SCHEMA = vol.Schema({
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PROP_TO_ATTR = {
|
||||||
|
'changed_by': ATTR_CHANGED_BY,
|
||||||
|
'code_format': ATTR_CODE_FORMAT,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def is_locked(hass, entity_id=None):
|
def is_locked(hass, entity_id=None):
|
||||||
@ -156,12 +161,11 @@ class LockDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
if self.code_format is None:
|
state_attr = {}
|
||||||
return None
|
for prop, attr in PROP_TO_ATTR.items():
|
||||||
state_attr = {
|
value = getattr(self, prop)
|
||||||
ATTR_CODE_FORMAT: self.code_format,
|
if value is not None:
|
||||||
ATTR_CHANGED_BY: self.changed_by
|
state_attr[attr] = value
|
||||||
}
|
|
||||||
return state_attr
|
return state_attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user