core/homeassistant/components/insteon/light.py

66 lines
1.7 KiB
Python
Raw Normal View History

"""Support for Insteon lights via PowerLinc Modem."""
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
import logging
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
2020-04-26 16:49:41 +00:00
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS,
LightEntity,
)
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
from .insteon_entity import InsteonEntity
_LOGGER = logging.getLogger(__name__)
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
MAX_BRIGHTNESS = 255
2019-07-31 19:25:30 +00:00
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
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
2018-08-22 07:09:04 +00:00
"""Set up the Insteon component."""
2019-07-31 19:25:30 +00:00
insteon_modem = hass.data["insteon"].get("modem")
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
2019-07-31 19:25:30 +00:00
address = discovery_info["address"]
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
2018-08-22 07:09:04 +00:00
device = insteon_modem.devices[address]
2019-07-31 19:25:30 +00:00
state_key = discovery_info["state_key"]
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
2019-07-31 19:25:30 +00:00
_LOGGER.debug(
"Adding device %s entity %s to Light platform",
device.address.hex,
device.states[state_key].name,
)
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
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
2018-08-22 07:09:04 +00:00
new_entity = InsteonDimmerDevice(device, state_key)
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
async_add_entities([new_entity])
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
2020-04-26 16:49:41 +00:00
class InsteonDimmerDevice(InsteonEntity, LightEntity):
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
"""A Class for an Insteon device."""
@property
def brightness(self):
"""Return the brightness of this light between 0..255."""
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
onlevel = self._insteon_device_state.value
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
return int(onlevel)
@property
def is_on(self):
"""Return the boolean response if the node is on."""
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
return bool(self.brightness)
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
@property
def supported_features(self):
"""Flag supported features."""
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
return SUPPORT_BRIGHTNESS
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
async def async_turn_on(self, **kwargs):
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
"""Turn device on."""
if ATTR_BRIGHTNESS in kwargs:
brightness = int(kwargs[ATTR_BRIGHTNESS])
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
self._insteon_device_state.set_level(brightness)
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
else:
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
self._insteon_device_state.on()
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
async def async_turn_off(self, **kwargs):
New component 'insteon_plm' and related platforms (#6104) * Connect to PLM and process simple protocol callbacks * Baseline commit * Connect to PLM and process simple protocol callbacks * Baseline commit * Connection working again * Async add devices is working via callback now * Beginning to interface with PLM library for control and state * Deal with brightness in 255 levels with library * Change sub names to match API changes * Remove PLM-level update callback * Support dimmable based on underlying PLM device attributes * Expand to non-light platforms * Stubs for turn on and off * Current version of Python library * Amend to use switch device attributes * Use asyncio endpoints for control * Add logging line * Bump module version to 0.7.1 * Auto-load platforms, display device info/attributes * Unify method name for getting a device attribute * Require Current version of insteonplm module * Import the component function in each platform in the balloob-recommend manner * For consistency, handle switch state as onlevel just like lights * Use level 0xff for on state, even with binary switches Observing the behavior of a 2477S switch, it looks like even the non-dimmable devices use 0x00 and 0xff for off/on respectively. I was using 0x01 for on previously, but that yields unnecessary state change callbacks when message traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff. * Use sensorstate attribute for sensor onoff * Move new device callback to devices attribute * Add support for platform override on a device * Bump version of insteonplm module * Default overrides is an empty list * Avoid calling private methods when doing common attributes * Remove unused CONF_DEBUG for now * flake8 and pylint code cleanup * Move get_component to local function where it is needed * Update to include insteonplm module. * New files for insteon_plm component * Legitimate class doctring instead of stub * Docstring changes. * Style changes as requested by @SEJeff * Changes requested by @pvizeli * Add @callback decorator to callback functions * Opportunistic platform loading triggered by qualifying device detection Instead of loading all the constituent platforms that comprise the insteon_plm component, instead we defer and wait until we receive a callback for a device that requires the platform.
2017-02-21 07:53:39 +00:00
"""Turn device off."""
Upgrade insteonplm to 0.8.2 (required refactoring) (#12534) * Merge from current dev * Update for Sensor approach * Update reference to state classes * Reference stateKey correctly * Reference stateKey * Change deviceInfo to a dict * Pass state to properties method * Add state info to device_state_attributes * Update entity name to include state name * Update for on() off() vs light_on/off * Flag newnames option * Update configuration schema * Update configuration schema * Spell False correctly * Rename state to statekey * Rename statekey to stateKey * Call new device with stateKey and newname * Simplify use of newnames * Add workdir to save devices * Fix newnames config setup * Propogate OnOffSensor to VariableSensor change * Upgrade insteonplm version to 0.8.0 * Pass address rather than device object to platform * Set inteon_plm data variable to PLM * Consistant use of conn and plm * Consistant use of conn and plm * Proper reference to device and address * Fixed platform setup issues * Correct issue with missing _supported_features attr * Properly reference self._state vs self.state * Bump insteonplm version to 0.8.1 * Remove subplatform and map based on state name * Correct refrence to State * Correct reference to device.states * Bump insteonplm to 0.8.2 * Fix format errors * Fix format issues * Fix trailing whitespace * Correct format issues * Fix format issues * Fix format issues * Fixed format issues * Fixed format issues * Move imports inside classes * Simplify import of modules * Correct reference to OnOffSwitch_OutletTop and bottom * Remove unnessary references * Fix format issues * Code review adjustments * Fix format issue * Use new nameing format for groups that are not group 0x01 * Remove newname feature * Fix binary_sensor type to default to None * Fix device_class property to return the sensor type correctly. * rename _device and _state to avoid conflicts with Entity * Format long lines * Pylint clean up * Insteon_PLM * lint cleanup * Check device_override has address * 3.4 lint clean up * Changes per code review * Change discovered from a list of dict to a dict * Correct common_attributes usage * Change discovered from a list of dict to a dict * Add debugging message to confirm platform setup * Debug messages * Debug messages * Debug async_added_to_hass * Debug async_added_to_hass async_add_job * Debug async_added_to_hass * Debug devices not loading in hass * Debug new entities not being added to hass * Debug adding devices to hass * Revert "3.4 lint clean up" This reverts commit 0d8fb992b12e9eea86716753fd2f302b1addb458. * 3.4 lint clean up * Revert "Debug adding devices to hass" This reverts commit ec306773d47401b100bcdaaf0af47c93699d78b4. * Revert "Debug new entities not being added to hass" This reverts commit 55fb724d06e7d1e249de46acb2de7eac2eb7d14d. * Revert "Debug devices not loading in hass" This reverts commit 07814b4f14cab85e67197812b055a2d71a954b1f. * Revert "Debug async_added_to_hass" This reverts commit 4963a255d86c1bf63ec6064b0d911893d310f13d. * Revert "Debug async_added_to_hass async_add_job" This reverts commit 22cadff91f524edf91605c4c1f9df0a3d125d1d9. * Revert "Debug async_added_to_hass" This reverts commit 12c5651fe497b439ba962473973232ae9745314d. * Pylint clean up * pylint cleanup * Clean up naming * Enhance config schema. Fix logging issue * Reapply changes after squash
2018-02-25 19:13:39 +00:00
self._insteon_device_state.off()