Don't add RainMachine restriction switches if underlying data is missing (#80502)
This commit is contained in:
parent
b09e95431c
commit
cee8f2cabb
1 changed files with 3 additions and 1 deletions
|
@ -34,7 +34,7 @@ from .model import (
|
||||||
RainMachineEntityDescriptionMixinDataKey,
|
RainMachineEntityDescriptionMixinDataKey,
|
||||||
RainMachineEntityDescriptionMixinUid,
|
RainMachineEntityDescriptionMixinUid,
|
||||||
)
|
)
|
||||||
from .util import RUN_STATE_MAP
|
from .util import RUN_STATE_MAP, key_exists
|
||||||
|
|
||||||
ATTR_AREA = "area"
|
ATTR_AREA = "area"
|
||||||
ATTR_CS_ON = "cs_on"
|
ATTR_CS_ON = "cs_on"
|
||||||
|
@ -237,6 +237,8 @@ async def async_setup_entry(
|
||||||
|
|
||||||
# Add switches to control restrictions:
|
# Add switches to control restrictions:
|
||||||
for description in RESTRICTIONS_SWITCH_DESCRIPTIONS:
|
for description in RESTRICTIONS_SWITCH_DESCRIPTIONS:
|
||||||
|
if not key_exists(coordinator.data, description.data_key):
|
||||||
|
continue
|
||||||
entities.append(RainMachineRestrictionSwitch(entry, data, description))
|
entities.append(RainMachineRestrictionSwitch(entry, data, description))
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue