Add support for Lupusec alarm control panel (#17691)
* Adds support for Lupusec alarm control panel * fixed various mostly cosmetic issues * fixed generic type of binary sensors * fixed some formatting; removed scan interval completely -> defaults now to 2 secs * removed unused data caches; added check if binary sensor class exists * cosmetics * generic type fix * small fix * small fixes * guard clause added * small fixes
This commit is contained in:
parent
00c1b40940
commit
ec732c896d
6 changed files with 273 additions and 0 deletions
53
homeassistant/components/switch/lupusec.py
Normal file
53
homeassistant/components/switch/lupusec.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
"""
|
||||
This component provides HA switch support for Lupusec Security System.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.lupusec/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.lupusec import (LupusecDevice,
|
||||
DOMAIN as LUPUSEC_DOMAIN)
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
DEPENDENCIES = ['lupusec']
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=2)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Lupusec switch devices."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
import lupupy.constants as CONST
|
||||
|
||||
data = hass.data[LUPUSEC_DOMAIN]
|
||||
|
||||
devices = []
|
||||
|
||||
for device in data.lupusec.get_devices(generic_type=CONST.TYPE_SWITCH):
|
||||
|
||||
devices.append(LupusecSwitch(data, device))
|
||||
|
||||
add_entities(devices)
|
||||
|
||||
|
||||
class LupusecSwitch(LupusecDevice, SwitchDevice):
|
||||
"""Representation of a Lupusec switch."""
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn on the device."""
|
||||
self._device.switch_on()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn off the device."""
|
||||
self._device.switch_off()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
return self._device.is_on
|
Loading…
Add table
Add a link
Reference in a new issue