Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions homeassistant/components/abode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from asyncio import gather
from copy import deepcopy
from functools import partial
import logging

from abodepy import Abode
from abodepy.exceptions import AbodeException
Expand All @@ -24,15 +23,13 @@
from homeassistant.helpers.dispatcher import dispatcher_send
from homeassistant.helpers.entity import Entity

from .const import ATTRIBUTION, DEFAULT_CACHEDB, DOMAIN

_LOGGER = logging.getLogger(__name__)
from .const import ATTRIBUTION, DEFAULT_CACHEDB, DOMAIN, LOGGER

CONF_POLLING = "polling"

SERVICE_SETTINGS = "change_setting"
SERVICE_CAPTURE_IMAGE = "capture_image"
SERVICE_TRIGGER = "trigger_quick_action"
SERVICE_TRIGGER_AUTOMATION = "trigger_automation"

ATTR_DEVICE_ID = "device_id"
ATTR_DEVICE_NAME = "device_name"
Expand All @@ -47,8 +44,6 @@
ATTR_EVENT_BY = "event_by"
ATTR_VALUE = "value"

ABODE_DEVICE_ID_LIST_SCHEMA = vol.Schema([str])

CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
Expand All @@ -68,7 +63,7 @@

CAPTURE_IMAGE_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})

TRIGGER_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})
AUTOMATION_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})

ABODE_PLATFORMS = [
"alarm_control_panel",
Expand All @@ -87,7 +82,6 @@ class AbodeSystem:

def __init__(self, abode, polling):
"""Initialize the system."""

self.abode = abode
self.polling = polling
self.entity_ids = set()
Expand Down Expand Up @@ -124,7 +118,7 @@ async def async_setup_entry(hass, config_entry):
hass.data[DOMAIN] = AbodeSystem(abode, polling)

except (AbodeException, ConnectTimeout, HTTPError) as ex:
_LOGGER.error("Unable to connect to Abode: %s", str(ex))
LOGGER.error("Unable to connect to Abode: %s", str(ex))
return False

for platform in ABODE_PLATFORMS:
Expand All @@ -143,7 +137,7 @@ async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
hass.services.async_remove(DOMAIN, SERVICE_SETTINGS)
hass.services.async_remove(DOMAIN, SERVICE_CAPTURE_IMAGE)
hass.services.async_remove(DOMAIN, SERVICE_TRIGGER)
hass.services.async_remove(DOMAIN, SERVICE_TRIGGER_AUTOMATION)

tasks = []

Expand Down Expand Up @@ -174,7 +168,7 @@ def change_setting(call):
try:
hass.data[DOMAIN].abode.set_setting(setting, value)
except AbodeException as ex:
_LOGGER.warning(ex)
LOGGER.warning(ex)

def capture_image(call):
"""Capture a new image."""
Expand All @@ -190,8 +184,8 @@ def capture_image(call):
signal = f"abode_camera_capture_{entity_id}"
dispatcher_send(hass, signal)

def trigger_quick_action(call):
"""Trigger a quick action."""
def trigger_automation(call):
"""Trigger an Abode automation."""
entity_ids = call.data.get(ATTR_ENTITY_ID, None)

target_entities = [
Expand All @@ -201,7 +195,7 @@ def trigger_quick_action(call):
]

for entity_id in target_entities:
signal = f"abode_trigger_quick_action_{entity_id}"
signal = f"abode_trigger_automation_{entity_id}"
dispatcher_send(hass, signal)

hass.services.register(
Expand All @@ -213,7 +207,7 @@ def trigger_quick_action(call):
)

hass.services.register(
DOMAIN, SERVICE_TRIGGER, trigger_quick_action, schema=TRIGGER_SCHEMA
DOMAIN, SERVICE_TRIGGER_AUTOMATION, trigger_automation, schema=AUTOMATION_SCHEMA
)


Expand All @@ -226,7 +220,7 @@ def logout(event):
hass.data[DOMAIN].abode.events.stop()

hass.data[DOMAIN].abode.logout()
_LOGGER.info("Logged out of Abode")
LOGGER.info("Logged out of Abode")

if not hass.data[DOMAIN].polling:
await hass.async_add_executor_job(hass.data[DOMAIN].abode.events.start)
Expand Down Expand Up @@ -384,11 +378,14 @@ def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
"automation_id": self._automation.automation_id,
"type": self._automation.type,
"sub_type": self._automation.sub_type,
"type": "CUE automation",
}

@property
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()
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/abode/alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Support for Abode Security System alarm control panels."""
import logging

import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY,
Expand All @@ -16,8 +14,6 @@
from . import AbodeDevice
from .const import ATTRIBUTION, DOMAIN

_LOGGER = logging.getLogger(__name__)

ICON = "mdi:security"


Expand Down Expand Up @@ -50,6 +46,11 @@ def state(self):
state = None
return state

@property
def code_arm_required(self):
"""Whether the code is required for arm actions."""
return False

@property
def supported_features(self) -> int:
"""Return the list of supported features."""
Expand Down
34 changes: 1 addition & 33 deletions homeassistant/components/abode/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
"""Support for Abode Security System binary sensors."""
import logging

import abodepy.helpers.constants as CONST
import abodepy.helpers.timeline as TIMELINE

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.helpers.dispatcher import async_dispatcher_connect

from . import AbodeAutomation, AbodeDevice
from . import AbodeDevice
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Abode binary sensor devices."""
Expand All @@ -30,13 +24,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for device in data.abode.get_devices(generic_type=device_types):
entities.append(AbodeBinarySensor(data, device))

for automation in data.abode.get_automations(generic_type=CONST.TYPE_QUICK_ACTION):
entities.append(
AbodeQuickActionBinarySensor(
data, automation, TIMELINE.AUTOMATION_EDIT_GROUP
)
)

async_add_entities(entities)


Expand All @@ -52,22 +39,3 @@ def is_on(self):
def device_class(self):
"""Return the class of the binary sensor."""
return self._device.generic_type


class AbodeQuickActionBinarySensor(AbodeAutomation, BinarySensorDevice):
"""A binary sensor implementation for Abode quick action automations."""

async def async_added_to_hass(self):
"""Subscribe Abode events."""
await super().async_added_to_hass()
signal = f"abode_trigger_quick_action_{self.entity_id}"
async_dispatcher_connect(self.hass, signal, self.trigger)

def trigger(self):
"""Trigger a quick automation."""
self._automation.trigger()

@property
def is_on(self):
"""Return True if the binary sensor is on."""
return self._automation.is_active
7 changes: 2 additions & 5 deletions homeassistant/components/abode/camera.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Support for Abode Security System cameras."""
from datetime import timedelta
import logging

import abodepy.helpers.constants as CONST
import abodepy.helpers.timeline as TIMELINE
Expand All @@ -11,12 +10,10 @@
from homeassistant.util import Throttle

from . import AbodeDevice
from .const import DOMAIN
from .const import DOMAIN, LOGGER

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=90)

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Abode camera devices."""
Expand Down Expand Up @@ -71,7 +68,7 @@ def get_image(self):

self._response.raise_for_status()
except requests.HTTPError as err:
_LOGGER.warning("Failed to get camera image: %s", err)
LOGGER.warning("Failed to get camera image: %s", err)
self._response = None
else:
self._response = None
Expand Down
11 changes: 3 additions & 8 deletions homeassistant/components/abode/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Config flow for the Abode Security System component."""
import logging

from abodepy import Abode
from abodepy.exceptions import AbodeException
from requests.exceptions import ConnectTimeout, HTTPError
Expand All @@ -10,12 +8,10 @@
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback

from .const import DEFAULT_CACHEDB, DOMAIN # pylint: disable=unused-import
from .const import DEFAULT_CACHEDB, DOMAIN, LOGGER # pylint: disable=unused-import

CONF_POLLING = "polling"

_LOGGER = logging.getLogger(__name__)


class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Config flow for Abode."""
Expand All @@ -32,7 +28,6 @@ def __init__(self):

async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""

if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

Expand All @@ -50,7 +45,7 @@ async def async_step_user(self, user_input=None):
)

except (AbodeException, ConnectTimeout, HTTPError) as ex:
_LOGGER.error("Unable to connect to Abode: %s", str(ex))
LOGGER.error("Unable to connect to Abode: %s", str(ex))
if ex.errcode == 400:
return self._show_form({"base": "invalid_credentials"})
return self._show_form({"base": "connection_error"})
Expand All @@ -76,7 +71,7 @@ def _show_form(self, errors=None):
async def async_step_import(self, import_config):
"""Import a config entry from configuration.yaml."""
if self._async_current_entries():
_LOGGER.warning("Only one configuration of abode is allowed.")
LOGGER.warning("Only one configuration of abode is allowed.")
return self.async_abort(reason="single_instance_allowed")

return await self.async_step_user(import_config)
4 changes: 4 additions & 0 deletions homeassistant/components/abode/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Constants for the Abode Security System component."""
import logging

LOGGER = logging.getLogger(__package__)

DOMAIN = "abode"
ATTRIBUTION = "Data provided by goabode.com"

Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/abode/cover.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""Support for Abode Security System covers."""
import logging

import abodepy.helpers.constants as CONST

from homeassistant.components.cover import CoverDevice

from . import AbodeDevice
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Abode cover devices."""
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/components/abode/light.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Support for Abode Security System lights."""
import logging
from math import ceil

import abodepy.helpers.constants as CONST
Expand All @@ -21,8 +20,6 @@
from . import AbodeDevice
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Abode light devices."""
Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/abode/lock.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""Support for the Abode Security System locks."""
import logging

import abodepy.helpers.constants as CONST

from homeassistant.components.lock import LockDevice

from . import AbodeDevice
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Abode lock devices."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/abode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Abode",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/abode",
"requirements": ["abodepy==0.17.0"],
"requirements": ["abodepy==0.18.1"],
"dependencies": [],
"codeowners": ["@shred86"]
}
4 changes: 0 additions & 4 deletions homeassistant/components/abode/sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Support for Abode Security System sensors."""
import logging

import abodepy.helpers.constants as CONST

from homeassistant.const import (
Expand All @@ -12,8 +10,6 @@
from . import AbodeDevice
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

# Sensor types: Name, icon
SENSOR_TYPES = {
CONST.TEMP_STATUS_KEY: ["Temperature", DEVICE_CLASS_TEMPERATURE],
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/abode/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ change_setting:
fields:
setting: {description: Setting to change., example: beeper_mute}
value: {description: Value of the setting., example: '1'}
trigger_quick_action:
description: Trigger an Abode quick action.
trigger_automation:
description: Trigger an Abode automation.
fields:
entity_id: {description: Entity id of the quick action to trigger., example: binary_sensor.home_quick_action}
entity_id: {description: Entity id of the automation to trigger., example: switch.my_automation}
Loading