1
mirror of https://github.com/home-assistant/core synced 2024-09-15 17:29:45 +02:00

Move imports to top for spc (#29547)

* Move imports to top for spc

* Fix pylint error by removing duplicate import
This commit is contained in:
springstan 2019-12-06 15:40:04 +01:00 committed by Martin Hjelmare
parent d9b52ef98c
commit 606d310ea3
4 changed files with 15 additions and 15 deletions

View File

@ -1,11 +1,14 @@
"""Support for Vanderbilt (formerly Siemens) SPC alarm systems."""
import logging
from pyspcwebgw import SpcWebGateway
from pyspcwebgw.area import Area
from pyspcwebgw.zone import Zone
import voluptuous as vol
from homeassistant.helpers import discovery, aiohttp_client
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers import aiohttp_client, discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
_LOGGER = logging.getLogger(__name__)
@ -33,11 +36,8 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup(hass, config):
"""Set up the SPC component."""
from pyspcwebgw import SpcWebGateway
async def async_upate_callback(spc_object):
from pyspcwebgw.area import Area
from pyspcwebgw.zone import Zone
if isinstance(spc_object, Area):
async_dispatcher_send(hass, SIGNAL_UPDATE_ALARM.format(spc_object.id))

View File

@ -1,6 +1,8 @@
"""Support for Vanderbilt (formerly Siemens) SPC alarm systems."""
import logging
from pyspcwebgw.const import AreaMode
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY,
@ -24,7 +26,6 @@ _LOGGER = logging.getLogger(__name__)
def _get_alarm_state(area):
"""Get the alarm state."""
from pyspcwebgw.const import AreaMode
if area.verified_alarm:
return STATE_ALARM_TRIGGERED
@ -92,24 +93,20 @@ class SpcAlarm(alarm.AlarmControlPanel):
async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
from pyspcwebgw.const import AreaMode
await self._api.change_mode(area=self._area, new_mode=AreaMode.UNSET)
async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
from pyspcwebgw.const import AreaMode
await self._api.change_mode(area=self._area, new_mode=AreaMode.PART_SET_A)
async def async_alarm_arm_night(self, code=None):
"""Send arm home command."""
from pyspcwebgw.const import AreaMode
await self._api.change_mode(area=self._area, new_mode=AreaMode.PART_SET_B)
async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
from pyspcwebgw.const import AreaMode
await self._api.change_mode(area=self._area, new_mode=AreaMode.FULL_SET)

View File

@ -1,6 +1,8 @@
"""Support for Vanderbilt (formerly Siemens) SPC alarm systems."""
import logging
from pyspcwebgw.const import ZoneInput
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -60,7 +62,6 @@ class SpcBinarySensor(BinarySensorDevice):
@property
def is_on(self):
"""Whether the device is switched on."""
from pyspcwebgw.const import ZoneInput
return self._zone.input == ZoneInput.OPEN

View File

@ -13,7 +13,8 @@ async def test_valid_device_config(hass, monkeypatch):
config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}}
with patch(
"pyspcwebgw.SpcWebGateway.async_load_parameters", return_value=mock_coro(True)
"homeassistant.components.spc.SpcWebGateway.async_load_parameters",
return_value=mock_coro(True),
):
assert await async_setup_component(hass, "spc", config) is True
@ -23,7 +24,8 @@ async def test_invalid_device_config(hass, monkeypatch):
config = {"spc": {"api_url": "http://localhost/"}}
with patch(
"pyspcwebgw.SpcWebGateway.async_load_parameters", return_value=mock_coro(True)
"homeassistant.components.spc.SpcWebGateway.async_load_parameters",
return_value=mock_coro(True),
):
assert await async_setup_component(hass, "spc", config) is False
@ -45,11 +47,11 @@ async def test_update_alarm_device(hass):
area_mock.verified_alarm = False
with patch(
"pyspcwebgw.SpcWebGateway.areas", new_callable=PropertyMock
"homeassistant.components.spc.SpcWebGateway.areas", new_callable=PropertyMock
) as mock_areas:
mock_areas.return_value = {"1": area_mock}
with patch(
"pyspcwebgw.SpcWebGateway.async_load_parameters",
"homeassistant.components.spc.SpcWebGateway.async_load_parameters",
return_value=mock_coro(True),
):
assert await async_setup_component(hass, "spc", config) is True