Use core constants for yeelight (#46552)

This commit is contained in:
tkdrob 2021-02-16 09:00:09 -05:00 committed by GitHub
parent 713544e5eb
commit add0d9d3eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 8 deletions

View file

@ -42,7 +42,6 @@ CONF_FLOW_PARAMS = "flow_params"
CONF_CUSTOM_EFFECTS = "custom_effects" CONF_CUSTOM_EFFECTS = "custom_effects"
CONF_NIGHTLIGHT_SWITCH_TYPE = "nightlight_switch_type" CONF_NIGHTLIGHT_SWITCH_TYPE = "nightlight_switch_type"
CONF_NIGHTLIGHT_SWITCH = "nightlight_switch" CONF_NIGHTLIGHT_SWITCH = "nightlight_switch"
CONF_DEVICE = "device"
DATA_CONFIG_ENTRIES = "config_entries" DATA_CONFIG_ENTRIES = "config_entries"
DATA_CUSTOM_EFFECTS = "custom_effects" DATA_CUSTOM_EFFECTS = "custom_effects"
@ -423,7 +422,6 @@ class YeelightDevice:
Uses brightness as it appears to be supported in both ceiling and other lights. Uses brightness as it appears to be supported in both ceiling and other lights.
""" """
return self._nightlight_brightness is not None return self._nightlight_brightness is not None
@property @property

View file

@ -5,12 +5,11 @@ import voluptuous as vol
import yeelight import yeelight
from homeassistant import config_entries, exceptions from homeassistant import config_entries, exceptions
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_ID, CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from . import ( from . import (
CONF_DEVICE,
CONF_MODE_MUSIC, CONF_MODE_MUSIC,
CONF_MODEL, CONF_MODEL,
CONF_NIGHTLIGHT_SWITCH, CONF_NIGHTLIGHT_SWITCH,

View file

@ -261,7 +261,6 @@ async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up Yeelight from a config entry.""" """Set up Yeelight from a config entry."""
custom_effects = _parse_custom_effects(hass.data[DOMAIN][DATA_CUSTOM_EFFECTS]) custom_effects = _parse_custom_effects(hass.data[DOMAIN][DATA_CUSTOM_EFFECTS])
device = hass.data[DOMAIN][DATA_CONFIG_ENTRIES][config_entry.entry_id][DATA_DEVICE] device = hass.data[DOMAIN][DATA_CONFIG_ENTRIES][config_entry.entry_id][DATA_DEVICE]
@ -563,7 +562,6 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the device specific state attributes.""" """Return the device specific state attributes."""
attributes = { attributes = {
"flowing": self.device.is_color_flow_enabled, "flowing": self.device.is_color_flow_enabled,
"music_mode": self._bulb.music_mode, "music_mode": self._bulb.music_mode,

View file

@ -3,7 +3,6 @@ from unittest.mock import MagicMock, patch
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.yeelight import ( from homeassistant.components.yeelight import (
CONF_DEVICE,
CONF_MODE_MUSIC, CONF_MODE_MUSIC,
CONF_MODEL, CONF_MODEL,
CONF_NIGHTLIGHT_SWITCH, CONF_NIGHTLIGHT_SWITCH,
@ -18,7 +17,7 @@ from homeassistant.components.yeelight import (
DOMAIN, DOMAIN,
NIGHTLIGHT_SWITCH_TYPE_LIGHT, NIGHTLIGHT_SWITCH_TYPE_LIGHT,
) )
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_ID, CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from . import ( from . import (