core/homeassistant/components/insteon_plm.py

215 lines
7.0 KiB
Python
Raw Normal View History

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
"""
Support for INSTEON PowerLinc Modem.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/insteon_plm/
"""
import asyncio
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 collections
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
import voluptuous as vol
from homeassistant.core import callback
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
from homeassistant.const import (CONF_PORT, EVENT_HOMEASSISTANT_STOP,
CONF_PLATFORM)
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
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import discovery
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
from homeassistant.helpers.entity import 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
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
REQUIREMENTS = ['insteonplm==0.8.2']
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
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'insteon_plm'
CONF_OVERRIDE = 'device_override'
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
CONF_ADDRESS = 'address'
CONF_CAT = 'cat'
CONF_SUBCAT = 'subcat'
CONF_FIRMWARE = 'firmware'
CONF_PRODUCT_KEY = 'product_key'
CONF_DEVICE_OVERRIDE_SCHEMA = vol.All(
cv.deprecated(CONF_PLATFORM), vol.Schema({
vol.Required(CONF_ADDRESS): cv.string,
vol.Optional(CONF_CAT): cv.byte,
vol.Optional(CONF_SUBCAT): cv.byte,
vol.Optional(CONF_FIRMWARE): cv.byte,
vol.Optional(CONF_PRODUCT_KEY): cv.byte,
vol.Optional(CONF_PLATFORM): cv.string,
}))
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
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_PORT): cv.string,
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
vol.Optional(CONF_OVERRIDE): vol.All(
cv.ensure_list_csv, [CONF_DEVICE_OVERRIDE_SCHEMA])
})
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
}, extra=vol.ALLOW_EXTRA)
@asyncio.coroutine
def async_setup(hass, config):
"""Set up the connection to the PLM."""
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
import insteonplm
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
ipdb = IPDB()
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
conf = config[DOMAIN]
port = conf.get(CONF_PORT)
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
overrides = conf.get(CONF_OVERRIDE, [])
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
@callback
def async_plm_new_device(device):
"""Detect device from transport to be delegated to platform."""
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
for state_key in device.states:
platform_info = ipdb[device.states[state_key]]
platform = platform_info.platform
if platform is not None:
_LOGGER.info("New INSTEON PLM device: %s (%s) %s",
device.address,
device.states[state_key].name,
platform)
hass.async_add_job(
discovery.async_load_platform(
hass, platform, DOMAIN,
discovered={'address': device.address.hex,
'state_key': state_key},
hass_config=config))
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
_LOGGER.info("Looking for PLM on %s", port)
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
conn = yield from insteonplm.Connection.create(
device=port,
loop=hass.loop,
workdir=hass.config.config_dir)
plm = conn.protocol
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
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
for device_override in overrides:
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
#
# Override the device default capabilities for a specific address
#
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
address = device_override.get('address')
for prop in device_override:
if prop in [CONF_CAT, CONF_SUBCAT]:
plm.devices.add_override(address, prop,
device_override[prop])
elif prop in [CONF_FIRMWARE, CONF_PRODUCT_KEY]:
plm.devices.add_override(address, CONF_PRODUCT_KEY,
device_override[prop])
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
hass.data['insteon_plm'] = plm
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
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, conn.close)
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
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
plm.devices.add_device_callback(async_plm_new_device)
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 True
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
State = collections.namedtuple('Product', 'stateType platform')
class IPDB(object):
"""Embodies the INSTEON Product Database static data and access methods."""
def __init__(self):
"""Create the INSTEON Product Database (IPDB)."""
from insteonplm.states.onOff import (OnOffSwitch,
OnOffSwitch_OutletTop,
OnOffSwitch_OutletBottom,
OpenClosedRelay)
from insteonplm.states.dimmable import (DimmableSwitch,
DimmableSwitch_Fan)
from insteonplm.states.sensor import (VariableSensor,
OnOffSensor,
SmokeCO2Sensor,
IoLincSensor)
self.states = [State(OnOffSwitch_OutletTop, 'switch'),
State(OnOffSwitch_OutletBottom, 'switch'),
State(OpenClosedRelay, 'switch'),
State(OnOffSwitch, 'switch'),
State(IoLincSensor, 'binary_sensor'),
State(SmokeCO2Sensor, 'sensor'),
State(OnOffSensor, 'binary_sensor'),
State(VariableSensor, 'sensor'),
State(DimmableSwitch_Fan, 'fan'),
State(DimmableSwitch, 'light')]
def __len__(self):
"""Return the number of INSTEON state types mapped to HA platforms."""
return len(self.states)
def __iter__(self):
"""Itterate through the INSTEON state types to HA platforms."""
for product in self.states:
yield product
def __getitem__(self, key):
"""Return a Home Assistant platform from an INSTEON state type."""
for state in self.states:
if isinstance(key, state.stateType):
return state
return None
class InsteonPLMEntity(Entity):
"""INSTEON abstract base entity."""
def __init__(self, device, state_key):
"""Initialize the INSTEON PLM binary sensor."""
self._insteon_device_state = device.states[state_key]
self._insteon_device = device
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def address(self):
"""Return the address of the node."""
return self._insteon_device.address.human
@property
def group(self):
"""Return the INSTEON group that the entity responds to."""
return self._insteon_device_state.group
@property
def name(self):
"""Return the name of the node (used for Entity_ID)."""
name = ''
if self._insteon_device_state.group == 0x01:
name = self._insteon_device.id
else:
name = '{:s}_{:d}'.format(self._insteon_device.id,
self._insteon_device_state.group)
return name
@property
def device_state_attributes(self):
"""Provide attributes for display on device card."""
attributes = {
'INSTEON Address': self.address,
'INSTEON Group': self.group
}
return attributes
@callback
def async_entity_update(self, deviceid, statename, val):
"""Receive notification from transport that new data exists."""
self.async_schedule_update_ha_state()
@asyncio.coroutine
def async_added_to_hass(self):
"""Register INSTEON update events."""
self._insteon_device_state.register_updates(
self.async_entity_update)