mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Add Elgato Avea integration (#24281)
* Adds Elgato Avea integration * Revert "Adds Elgato Avea integration" This reverts commit 8607a685eb47e99ea0e8a69fbdb84e511aaf1be0. * Adds Elgato Avea integration * Removed debug * Improved readability Co-Authored-By: Otto Winter <otto@otto-winter.com> * Adds Elgato Avea integration * Fixes for flake8 * More Fixes for flake8 * Hopefully last fixes for flake8 * Unnecessary rounding and typo removed * Duplicate calls removed * raise PlatformNotReady if communication with bulb failes * Fixes: flake8, missing import of exception and better handling of ble problems * Update requirements_all.txt Add requirements_all.txt file * Revert "Update requirements_all.txt" This reverts commit 2856025ed3d88bb081e3a8d0fb065f1e7ba1ef45. * Update requirements_all.txt * conform with snake_case naming style https://circleci.com/gh/home-assistant/home-assistant/31823 * Fixed variable rename * Unnecessary calculation removed Co-Authored-By: Otto Winter <otto@otto-winter.com> * Better Exception Handling * Changed position of import, renamed add_entities to add_devices, remove unnecessary comment * Unnecessary comments removed.
This commit is contained in:
parent
2fb03106ea
commit
4c067ecff7
@ -54,6 +54,7 @@ omit =
|
|||||||
homeassistant/components/august/*
|
homeassistant/components/august/*
|
||||||
homeassistant/components/aurora_abb_powerone/sensor.py
|
homeassistant/components/aurora_abb_powerone/sensor.py
|
||||||
homeassistant/components/automatic/device_tracker.py
|
homeassistant/components/automatic/device_tracker.py
|
||||||
|
homeassistant/components/avea/light.py
|
||||||
homeassistant/components/avion/light.py
|
homeassistant/components/avion/light.py
|
||||||
homeassistant/components/azure_event_hub/*
|
homeassistant/components/azure_event_hub/*
|
||||||
homeassistant/components/baidu/tts.py
|
homeassistant/components/baidu/tts.py
|
||||||
|
@ -35,6 +35,7 @@ homeassistant/components/aurora_abb_powerone/* @davet2001
|
|||||||
homeassistant/components/auth/* @home-assistant/core
|
homeassistant/components/auth/* @home-assistant/core
|
||||||
homeassistant/components/automatic/* @armills
|
homeassistant/components/automatic/* @armills
|
||||||
homeassistant/components/automation/* @home-assistant/core
|
homeassistant/components/automation/* @home-assistant/core
|
||||||
|
homeassistant/components/avea/* @pattyland
|
||||||
homeassistant/components/awair/* @danielsjf
|
homeassistant/components/awair/* @danielsjf
|
||||||
homeassistant/components/aws/* @awarecan @robbiet480
|
homeassistant/components/aws/* @awarecan @robbiet480
|
||||||
homeassistant/components/axis/* @kane610
|
homeassistant/components/axis/* @kane610
|
||||||
|
1
homeassistant/components/avea/__init__.py
Normal file
1
homeassistant/components/avea/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""The avea component."""
|
88
homeassistant/components/avea/light.py
Normal file
88
homeassistant/components/avea/light.py
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
"""Support for the Elgato Avea lights."""
|
||||||
|
import logging
|
||||||
|
import avea
|
||||||
|
|
||||||
|
from homeassistant.components.light import (
|
||||||
|
ATTR_BRIGHTNESS, ATTR_HS_COLOR, SUPPORT_BRIGHTNESS,
|
||||||
|
SUPPORT_COLOR, Light)
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SUPPORT_AVEA = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
"""Set up the Avea platform."""
|
||||||
|
|
||||||
|
try:
|
||||||
|
nearby_bulbs = avea.discover_avea_bulbs()
|
||||||
|
for bulb in nearby_bulbs:
|
||||||
|
bulb.get_name()
|
||||||
|
bulb.get_brightness()
|
||||||
|
except OSError as err:
|
||||||
|
raise PlatformNotReady from err
|
||||||
|
|
||||||
|
add_entities(AveaLight(bulb) for bulb in nearby_bulbs)
|
||||||
|
|
||||||
|
|
||||||
|
class AveaLight(Light):
|
||||||
|
"""Representation of an Avea."""
|
||||||
|
|
||||||
|
def __init__(self, light):
|
||||||
|
"""Initialize an AveaLight."""
|
||||||
|
self._light = light
|
||||||
|
self._name = light.name
|
||||||
|
self._state = None
|
||||||
|
self._brightness = light.brightness
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
return SUPPORT_AVEA
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the display name of this light."""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def brightness(self):
|
||||||
|
"""Return the brightness of the light."""
|
||||||
|
return self._brightness
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
"""Return true if light is on."""
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
def turn_on(self, **kwargs):
|
||||||
|
"""Instruct the light to turn on."""
|
||||||
|
if not kwargs:
|
||||||
|
self._light.set_brightness(4095)
|
||||||
|
else:
|
||||||
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
|
bright = round((kwargs[ATTR_BRIGHTNESS] / 255) * 4095)
|
||||||
|
self._light.set_brightness(bright)
|
||||||
|
if ATTR_HS_COLOR in kwargs:
|
||||||
|
rgb = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
|
||||||
|
self._light.set_rgb(rgb[0], rgb[1], rgb[2])
|
||||||
|
|
||||||
|
def turn_off(self, **kwargs):
|
||||||
|
"""Instruct the light to turn off."""
|
||||||
|
self._light.set_brightness(0)
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Fetch new state data for this light.
|
||||||
|
|
||||||
|
This is the only method that should fetch new data for Home Assistant.
|
||||||
|
"""
|
||||||
|
brightness = self._light.get_brightness()
|
||||||
|
if brightness is not None:
|
||||||
|
if brightness == 0:
|
||||||
|
self._state = False
|
||||||
|
else:
|
||||||
|
self._state = True
|
||||||
|
self._brightness = round(255 * (brightness / 4095))
|
8
homeassistant/components/avea/manifest.json
Normal file
8
homeassistant/components/avea/manifest.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"domain": "avea",
|
||||||
|
"name": "Elgato Avea",
|
||||||
|
"documentation": "https://www.home-assistant.io/components/avea",
|
||||||
|
"dependencies": [],
|
||||||
|
"codeowners": ["@pattyland"],
|
||||||
|
"requirements": ["avea==1.2.8"]
|
||||||
|
}
|
@ -229,6 +229,9 @@ aurorapy==0.2.6
|
|||||||
# homeassistant.components.stream
|
# homeassistant.components.stream
|
||||||
av==6.1.2
|
av==6.1.2
|
||||||
|
|
||||||
|
# homeassistant.components.avea
|
||||||
|
avea==1.2.8
|
||||||
|
|
||||||
# homeassistant.components.avion
|
# homeassistant.components.avion
|
||||||
# avion==0.10
|
# avion==0.10
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user