Clean up Abode unused automation events (#32825)
parent
82c8f18bc7
commit
f02c5f66d6
|
@ -263,7 +263,6 @@ def setup_abode_events(hass):
|
||||||
TIMELINE.TEST_GROUP,
|
TIMELINE.TEST_GROUP,
|
||||||
TIMELINE.CAPTURE_GROUP,
|
TIMELINE.CAPTURE_GROUP,
|
||||||
TIMELINE.DEVICE_GROUP,
|
TIMELINE.DEVICE_GROUP,
|
||||||
TIMELINE.AUTOMATION_EDIT_GROUP,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for event in events:
|
for event in events:
|
||||||
|
@ -343,21 +342,14 @@ class AbodeDevice(Entity):
|
||||||
class AbodeAutomation(Entity):
|
class AbodeAutomation(Entity):
|
||||||
"""Representation of an Abode automation."""
|
"""Representation of an Abode automation."""
|
||||||
|
|
||||||
def __init__(self, data, automation, event=None):
|
def __init__(self, data, automation):
|
||||||
"""Initialize for Abode automation."""
|
"""Initialize for Abode automation."""
|
||||||
self._data = data
|
self._data = data
|
||||||
self._automation = automation
|
self._automation = automation
|
||||||
self._event = event
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Subscribe to a group of Abode timeline events."""
|
"""Set up automation entity."""
|
||||||
if self._event:
|
self.hass.data[DOMAIN].entity_ids.add(self.entity_id)
|
||||||
self.hass.async_add_job(
|
|
||||||
self._data.abode.events.add_event_callback,
|
|
||||||
self._event,
|
|
||||||
self._update_callback,
|
|
||||||
)
|
|
||||||
self.hass.data[DOMAIN].entity_ids.add(self.entity_id)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
@ -385,8 +377,3 @@ class AbodeAutomation(Entity):
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique ID to use for this automation."""
|
"""Return a unique ID to use for this automation."""
|
||||||
return self._automation.automation_id
|
return self._automation.automation_id
|
||||||
|
|
||||||
def _update_callback(self, device):
|
|
||||||
"""Update the automation state."""
|
|
||||||
self._automation.refresh()
|
|
||||||
self.schedule_update_ha_state()
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""Support for Abode Security System switches."""
|
"""Support for Abode Security System switches."""
|
||||||
import abodepy.helpers.constants as CONST
|
import abodepy.helpers.constants as CONST
|
||||||
import abodepy.helpers.timeline as TIMELINE
|
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
@ -24,9 +23,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
entities.append(AbodeSwitch(data, device))
|
entities.append(AbodeSwitch(data, device))
|
||||||
|
|
||||||
for automation in data.abode.get_automations():
|
for automation in data.abode.get_automations():
|
||||||
entities.append(
|
entities.append(AbodeAutomationSwitch(data, automation))
|
||||||
AbodeAutomationSwitch(data, automation, TIMELINE.AUTOMATION_EDIT_GROUP)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
@ -52,7 +49,7 @@ class AbodeAutomationSwitch(AbodeAutomation, SwitchDevice):
|
||||||
"""A switch implementation for Abode automations."""
|
"""A switch implementation for Abode automations."""
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Subscribe Abode events."""
|
"""Set up trigger automation service."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
|
|
||||||
signal = f"abode_trigger_automation_{self.entity_id}"
|
signal = f"abode_trigger_automation_{self.entity_id}"
|
||||||
|
|
Loading…
Reference in New Issue