Init sub-components using global var. (#17220)
This commit is contained in:
parent
2de1193fd9
commit
e922dd10ba
6 changed files with 13 additions and 138 deletions
|
@ -9,8 +9,7 @@ import logging
|
|||
import homeassistant.components.alarm_control_panel as alarm
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.spc import (
|
||||
ATTR_DISCOVER_AREAS, DATA_API, SIGNAL_UPDATE_ALARM)
|
||||
from homeassistant.components.spc import (DATA_API, SIGNAL_UPDATE_ALARM)
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT,
|
||||
STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED)
|
||||
|
@ -37,12 +36,9 @@ def _get_alarm_state(area):
|
|||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the SPC alarm control panel platform."""
|
||||
if (discovery_info is None or
|
||||
discovery_info[ATTR_DISCOVER_AREAS] is None):
|
||||
return
|
||||
|
||||
async_add_entities([SpcAlarm(area=area, api=hass.data[DATA_API])
|
||||
for area in discovery_info[ATTR_DISCOVER_AREAS]])
|
||||
api = hass.data[DATA_API]
|
||||
async_add_entities([SpcAlarm(area=area, api=api)
|
||||
for area in api.areas.values()])
|
||||
|
||||
|
||||
class SpcAlarm(alarm.AlarmControlPanel):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue