Merge insteon_plm and insteon_local to insteon component (#16102)
* Implement X10 * Add X10 after add_device_callback * Ref device by id not hex and add x10OnOffSwitch name * X10 services and add sensor device * Correctly reference X10_HOUSECODE_SCHEMA * Log adding of X10 devices * Add X10 All Units Off, All Lights On and All Lights Off devices * Correct ref to X10 states vs devices * Add X10 All Units Off, All Lights On and All Lights Off devices * Correct X10 config * Debug x10 device additions * Config x10 from bool to housecode char * Pass PLM to X10 device create * Remove PLM to call to add_x10_device * Unconfuse x10 config and method names * Correct spelling of x10_all_lights_off_housecode * Bump insteonplm to 0.10.0 to support X10 * Add host to config options * Add username and password to config for hub connectivity * Add username and password to config for hub * Convert port to int if host is defined * Add KeypadLinc * Update config schema to require either port or host * Solidify Hub and PLM configuration to ensure proper settings * Update hub schema * Bump insteonplm version * Fix pylint and flake issues * Bump insteonplm to 0.12.1 * Merge insteon_plm and insteon_local to insteon * Rename insteon_plm to insteon * Bump insteonplm to 0.12.2 * Flake8 cleanup * Update .coveragerc for insteon_plm, insteon_local and insteon changes * Add persistent notification * Fix reference to insteon_plm * Fix indentation * Shorten message and fix grammer * Add comment to remove in release 0.90 * Hound fix
This commit is contained in:
1 parent
6864a44b5a
commit
a31501d99e
14 files changed
+204
-474
No files matched your search
+8
-8
@@ -2,40 +2,40 @@
|
||||
Support for Insteon lights via PowerLinc Modem.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.insteon_plm/
|
||||
https://home-assistant.io/components/light.insteon/
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant.components.insteon_plm import InsteonPLMEntity
|
||||
from homeassistant.components.insteon import InsteonEntity
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['insteon_plm']
|
||||
DEPENDENCIES = ['insteon']
|
||||
|
||||
MAX_BRIGHTNESS = 255
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the Insteon PLM device."""
|
||||
plm = hass.data['insteon_plm'].get('plm')
|
||||
"""Set up the Insteon component."""
|
||||
insteon_modem = hass.data['insteon'].get('modem')
|
||||
|
||||
address = discovery_info['address']
|
||||
device = plm.devices[address]
|
||||
device = insteon_modem.devices[address]
|
||||
state_key = discovery_info['state_key']
|
||||
|
||||
_LOGGER.debug('Adding device %s entity %s to Light platform',
|
||||
device.address.hex, device.states[state_key].name)
|
||||
|
||||
new_entity = InsteonPLMDimmerDevice(device, state_key)
|
||||
new_entity = InsteonDimmerDevice(device, state_key)
|
||||
|
||||
async_add_devices([new_entity])
|
||||
|
||||
|
||||
class InsteonPLMDimmerDevice(InsteonPLMEntity, Light):
|
||||
class InsteonDimmerDevice(InsteonEntity, Light):
|
||||
"""A Class for an Insteon device."""
|
||||
|
||||
@property
|
||||
@@ -1,98 +0,0 @@
|
||||
"""
|
||||
Support for Insteon dimmers via local hub control.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.insteon_local/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
|
||||
from homeassistant import util
|
||||
|
||||
_CONFIGURING = {}
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['insteon_local']
|
||||
DOMAIN = 'light'
|
||||
|
||||
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)
|
||||
|
||||
SUPPORT_INSTEON_LOCAL = SUPPORT_BRIGHTNESS
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the Insteon local light platform."""
|
||||
insteonhub = hass.data['insteon_local']
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
linked = discovery_info['linked']
|
||||
device_list = []
|
||||
for device_id in linked:
|
||||
if linked[device_id]['cat_type'] == 'dimmer':
|
||||
device = insteonhub.dimmer(device_id)
|
||||
device_list.append(
|
||||
InsteonLocalDimmerDevice(device)
|
||||
)
|
||||
|
||||
add_devices(device_list)
|
||||
|
||||
|
||||
class InsteonLocalDimmerDevice(Light):
|
||||
"""An abstract Class for an Insteon node."""
|
||||
|
||||
def __init__(self, node):
|
||||
"""Initialize the device."""
|
||||
self.node = node
|
||||
self._value = 0
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the node."""
|
||||
return self.node.device_id
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this Insteon node."""
|
||||
return self.node.device_id
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
return self._value
|
||||
|
||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||
def update(self):
|
||||
"""Update state of the light."""
|
||||
resp = self.node.status(0)
|
||||
|
||||
while 'error' in resp and resp['error'] is True:
|
||||
resp = self.node.status(0)
|
||||
|
||||
if 'cmd2' in resp:
|
||||
self._value = int(resp['cmd2'], 16)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the boolean response if the node is on."""
|
||||
return self._value != 0
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_INSTEON_LOCAL
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn device on."""
|
||||
brightness = 100
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
brightness = int(kwargs[ATTR_BRIGHTNESS]) / 255 * 100
|
||||
|
||||
self.node.change_level(brightness)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn device off."""
|
||||
self.node.off()
|
||||
Reference in new issue
Block a user