core/homeassistant/components/plum_lightpad/light.py

240 lines
7.0 KiB
Python
Raw Normal View History

"""Support for Plum Lightpad lights."""
2020-06-25 11:20:42 +00:00
import asyncio
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
from typing import Callable, List
from plumlightpad import Plum
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
from homeassistant.components.light import (
2019-07-31 19:25:30 +00:00
ATTR_BRIGHTNESS,
ATTR_HS_COLOR,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
2020-04-26 16:49:41 +00:00
LightEntity,
2019-07-31 19:25:30 +00:00
)
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.entity import Entity
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
import homeassistant.util.color as color_util
2020-06-14 11:59:49 +00:00
from .const import DOMAIN
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity]], None],
) -> None:
"""Set up Plum Lightpad dimmer lights and glow rings."""
plum: Plum = hass.data[DOMAIN][entry.entry_id]
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
def setup_entities(device) -> None:
entities = []
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
if "lpid" in device:
lightpad = plum.get_lightpad(device["lpid"])
entities.append(GlowRing(lightpad=lightpad))
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
if "llid" in device:
logical_load = plum.get_load(device["llid"])
entities.append(PlumLight(load=logical_load))
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
if entities:
async_add_entities(entities)
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
async def new_load(device):
setup_entities(device)
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
async def new_lightpad(device):
setup_entities(device)
device_web_session = async_get_clientsession(hass, verify_ssl=False)
2020-06-25 11:20:42 +00:00
asyncio.create_task(
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
plum.discover(
hass.loop,
loadListener=new_load,
lightpadListener=new_lightpad,
websession=device_web_session,
)
)
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
2020-04-26 16:49:41 +00:00
class PlumLight(LightEntity):
"""Representation of a Plum Lightpad dimmer."""
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
def __init__(self, load):
"""Initialize the light."""
self._load = load
self._brightness = load.level
async def async_added_to_hass(self):
"""Subscribe to dimmerchange events."""
2019-07-31 19:25:30 +00:00
self._load.add_event_listener("dimmerchange", self.dimmerchange)
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
def dimmerchange(self, event):
"""Change event handler updating the brightness."""
2019-07-31 19:25:30 +00:00
self._brightness = event["level"]
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
self.schedule_update_ha_state()
@property
def should_poll(self):
"""No polling needed."""
return False
2020-06-08 04:52:03 +00:00
@property
def unique_id(self):
"""Combine logical load ID with .light to guarantee it is unique."""
return f"{self._load.llid}.light"
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def name(self):
"""Return the name of the switch if any."""
return self._load.name
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
@property
def device_info(self):
"""Return the device info."""
return {
"name": self.name,
"identifiers": {(DOMAIN, self.unique_id)},
"model": "Dimmer",
"manufacturer": "Plum",
}
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def brightness(self) -> int:
"""Return the brightness of this switch between 0..255."""
return self._brightness
@property
def is_on(self) -> bool:
"""Return true if light is on."""
return self._brightness > 0
@property
def supported_features(self):
"""Flag supported features."""
if self._load.dimmable:
return SUPPORT_BRIGHTNESS
return 0
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
async def async_turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_BRIGHTNESS in kwargs:
await self._load.turn_on(kwargs[ATTR_BRIGHTNESS])
else:
await self._load.turn_on()
async def async_turn_off(self, **kwargs):
"""Turn the light off."""
await self._load.turn_off()
2020-04-26 16:49:41 +00:00
class GlowRing(LightEntity):
"""Representation of a Plum Lightpad dimmer glow ring."""
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
def __init__(self, lightpad):
"""Initialize the light."""
self._lightpad = lightpad
self._name = f"{lightpad.friendly_name} Glow Ring"
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
self._state = lightpad.glow_enabled
self._glow_intensity = lightpad.glow_intensity
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
2019-07-31 19:25:30 +00:00
self._red = lightpad.glow_color["red"]
self._green = lightpad.glow_color["green"]
self._blue = lightpad.glow_color["blue"]
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
async def async_added_to_hass(self):
"""Subscribe to configchange events."""
2019-07-31 19:25:30 +00:00
self._lightpad.add_event_listener("configchange", self.configchange_event)
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
def configchange_event(self, event):
"""Handle Configuration change event."""
2019-07-31 19:25:30 +00:00
config = event["changes"]
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
2019-07-31 19:25:30 +00:00
self._state = config["glowEnabled"]
self._glow_intensity = config["glowIntensity"]
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
2019-07-31 19:25:30 +00:00
self._red = config["glowColor"]["red"]
self._green = config["glowColor"]["green"]
self._blue = config["glowColor"]["blue"]
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
self.schedule_update_ha_state()
@property
def hs_color(self):
"""Return the hue and saturation color value [float, float]."""
return color_util.color_RGB_to_hs(self._red, self._green, self._blue)
@property
def should_poll(self):
"""No polling needed."""
return False
2020-06-08 04:52:03 +00:00
@property
def unique_id(self):
"""Combine LightPad ID with .glow to guarantee it is unique."""
return f"{self._lightpad.lpid}.glow"
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def name(self):
"""Return the name of the switch if any."""
return self._name
Add Plum Lightpad config flow (#36802) * add support for config flow for Plum Lightpad integration * add support for config flow for Plum Lightpad integration (remove unintended change to requirements_test_all.txt) * add support for config flow for Plum Lightpad integration (fix lint issues) * add support for config flow for Plum Lightpad integration (PR feedback) * add support for config flow for Plum Lightpad integration (fix lint) * Update homeassistant/components/plum_lightpad/__init__.py use debug instead of info for logging Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use generated references instead of hard-coded strings Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json switch to use references instead of hard-coded string Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing translated title per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/plum_lightpad/strings.json removing per suggestion Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * remove unnecessary deepcopy * remove unnecessary logging warning, since ignoring is expected for configuration.yaml scenario * switch to hass.loop.create_task per PR feedback * show login errors when configuring integration via UI (PR feedback) * disable wrongly flag pylint violation * add except handler to handle connection errors when setting up config flow entry * address PR feedback regarding exception handling * Update homeassistant/components/plum_lightpad/config_flow.py use helper instead of custom code/message-id Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-24 03:40:11 +00:00
@property
def device_info(self):
"""Return the device info."""
return {
"name": self.name,
"identifiers": {(DOMAIN, self.unique_id)},
"model": "Glow Ring",
"manufacturer": "Plum",
}
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def brightness(self) -> int:
"""Return the brightness of this switch between 0..255."""
return min(max(int(round(self._glow_intensity * 255, 0)), 0), 255)
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def glow_intensity(self):
"""Brightness in float form."""
return self._glow_intensity
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def is_on(self) -> bool:
"""Return true if light is on."""
return self._state
@property
def icon(self):
"""Return the crop-portrait icon representing the glow ring."""
2019-07-31 19:25:30 +00:00
return "mdi:crop-portrait"
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR
async def async_turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_BRIGHTNESS in kwargs:
brightness_pct = kwargs[ATTR_BRIGHTNESS] / 255.0
await self._lightpad.set_config({"glowIntensity": brightness_pct})
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
elif ATTR_HS_COLOR in kwargs:
hs_color = kwargs[ATTR_HS_COLOR]
red, green, blue = color_util.color_hs_to_RGB(*hs_color)
await self._lightpad.set_glow_color(red, green, blue, 0)
else:
await self._lightpad.set_config({"glowEnabled": True})
async def async_turn_off(self, **kwargs):
"""Turn the light off."""
if ATTR_BRIGHTNESS in kwargs:
brightness_pct = kwargs[ATTR_BRIGHTNESS] / 255.0
await self._lightpad.set_config({"glowIntensity": brightness_pct})
Adding support for Plum Lightpad (#16576) * Adding basic Plum Lightpad support - https://plumlife.com/ * Used Const values is_on is a bool * Added LightpadPowerMeter Sensor to the plum_lightpad platform * Moved to async setup, Introduced a PlumManager, events, subscription, Light and Power meter working * Added PlumMotionSensor * Added Glow Ring support * Updated plum library and re-normalized * set the glow-ring's icon * Naming the glow ring * Formatting and linting * Cleaned up a number of linting issues. Left a number of documentation warnings * setup_platform migrated to async_setup_platform Plum discovery run as a job * bumped plumlightpad version * On shutdown disconnect the telnet session from each plum lightpad * Cleanup & formatting. Worked on parallell cloud update * Moved setup from async to non-async * Utilize async_call_later from the helpers * Cleanedup and linted, down to documentation & one #TODO * Remove commented out debug lines * Fixed Linting issues * Remove TODO * Updated comments & fixed Linting issues * Added plumlightpad to requirements_all.txt * Fixing imports with isort * Added components to .coveragerc * Added PLUM_DATA constant for accessing hass.data[PLUM_DATA] * used dictionary syntax vs get(...) for config * Linting needed an additonal line * Fully async_setup now. removed @callback utilize bus events for detecting new devices found. * Upgraded to plumlightpad 0.0.10 * Removed extra unused PLATFORM_SCHEMA declarations * Moved listener attachment to `async_added_to_hass` and removed unused properties & device_state_attributes * Utilized Discovery when devices were located * Linting and cleanup * used `hass.async_create_task` instead of `hass.async_add_job` per Martin * Removed redundant criteria in if block * Without discovery info, there is no need to setup * Better state management and async on/off for Glow Ring * renamed async_set_config back to set_config, fixed cleanup callback and Plum Initialization * Fixed flake8 linting issues * plumlightpad package update * Add 'motion' device_class to Motion Sensor * Fixed last known Linting issue * let homeassistant handle setting the brightness state * String formatting vs concatenation * use shared aiohttp session from homeassistant * Updating to use new formatting style * looks like @cleanup isn't neccesary * ditch the serial awaits * Ensure async_add_entities is only called once per async_setup_platform * Creating tasks to wait for vs coroutines * Remove unused white component in the GlowRing * Used local variables for GlowRing colors & added a setter for the hs_color property to keep the values in sync * Linted and added docstring * Update the documentation path to point to the component page * Removed the extra sensor and binary_sensor platforms as requested. (To be added in later PRs) * Update plum_lightpad.py * Update plum_lightpad.py
2018-12-14 13:42:04 +00:00
else:
await self._lightpad.set_config({"glowEnabled": False})