Clean up Abode unused automation events (#32825)

pull/32927/head
shred86 2020-03-17 17:58:05 -07:00 committed by GitHub
parent 82c8f18bc7
commit f02c5f66d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 21 deletions

View File

@ -263,7 +263,6 @@ def setup_abode_events(hass):
TIMELINE.TEST_GROUP,
TIMELINE.CAPTURE_GROUP,
TIMELINE.DEVICE_GROUP,
TIMELINE.AUTOMATION_EDIT_GROUP,
]
for event in events:
@ -343,21 +342,14 @@ class AbodeDevice(Entity):
class AbodeAutomation(Entity):
"""Representation of an Abode automation."""
def __init__(self, data, automation, event=None):
def __init__(self, data, automation):
"""Initialize for Abode automation."""
self._data = data
self._automation = automation
self._event = event
async def async_added_to_hass(self):
"""Subscribe to a group of Abode timeline events."""
if self._event:
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)
"""Set up automation entity."""
self.hass.data[DOMAIN].entity_ids.add(self.entity_id)
@property
def should_poll(self):
@ -385,8 +377,3 @@ class AbodeAutomation(Entity):
def unique_id(self):
"""Return a unique ID to use for this automation."""
return self._automation.automation_id
def _update_callback(self, device):
"""Update the automation state."""
self._automation.refresh()
self.schedule_update_ha_state()

View File

@ -1,6 +1,5 @@
"""Support for Abode Security System switches."""
import abodepy.helpers.constants as CONST
import abodepy.helpers.timeline as TIMELINE
from homeassistant.components.switch import SwitchDevice
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))
for automation in data.abode.get_automations():
entities.append(
AbodeAutomationSwitch(data, automation, TIMELINE.AUTOMATION_EDIT_GROUP)
)
entities.append(AbodeAutomationSwitch(data, automation))
async_add_entities(entities)
@ -52,7 +49,7 @@ class AbodeAutomationSwitch(AbodeAutomation, SwitchDevice):
"""A switch implementation for Abode automations."""
async def async_added_to_hass(self):
"""Subscribe Abode events."""
"""Set up trigger automation service."""
await super().async_added_to_hass()
signal = f"abode_trigger_automation_{self.entity_id}"