mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
parent
bfbf9b9751
commit
8c993116e1
@ -164,10 +164,7 @@ class BlackbirdZone(MediaPlayerEntity):
|
||||
return
|
||||
self._attr_state = MediaPlayerState.ON if state.power else MediaPlayerState.OFF
|
||||
idx = state.av
|
||||
if idx in self._source_id_name:
|
||||
self._attr_source = self._source_id_name[idx]
|
||||
else:
|
||||
self._attr_source = None
|
||||
self._attr_source = self._source_id_name.get(idx)
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
|
@ -71,16 +71,14 @@ class BlinkStickLight(LightEntity):
|
||||
"""Turn the device on."""
|
||||
if ATTR_HS_COLOR in kwargs:
|
||||
self._attr_hs_color = kwargs[ATTR_HS_COLOR]
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
self._attr_brightness = kwargs[ATTR_BRIGHTNESS]
|
||||
else:
|
||||
self._attr_brightness = 255
|
||||
assert self.brightness is not None
|
||||
self._attr_is_on = self.brightness > 0
|
||||
|
||||
brightness: int = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||
self._attr_brightness = brightness
|
||||
self._attr_is_on = bool(brightness)
|
||||
|
||||
assert self.hs_color
|
||||
rgb_color = color_util.color_hsv_to_RGB(
|
||||
self.hs_color[0], self.hs_color[1], self.brightness / 255 * 100
|
||||
self.hs_color[0], self.hs_color[1], brightness / 255 * 100
|
||||
)
|
||||
self._stick.set_color(red=rgb_color[0], green=rgb_color[1], blue=rgb_color[2])
|
||||
|
||||
|
@ -1333,10 +1333,7 @@ class ArmDisArmTrait(_Trait):
|
||||
|
||||
def query_attributes(self):
|
||||
"""Return ArmDisarm query attributes."""
|
||||
if "next_state" in self.state.attributes:
|
||||
armed_state = self.state.attributes["next_state"]
|
||||
else:
|
||||
armed_state = self.state.state
|
||||
armed_state = self.state.attributes.get("next_state", self.state.state)
|
||||
response = {"isArmed": armed_state in self.state_to_service}
|
||||
if response["isArmed"]:
|
||||
response.update({"currentArmLevel": armed_state})
|
||||
|
@ -261,14 +261,8 @@ def setup(hass: HomeAssistant, base_config: ConfigType) -> bool: # noqa: C901
|
||||
if ATTR_RAW in data:
|
||||
command = CecCommand(data[ATTR_RAW])
|
||||
else:
|
||||
if ATTR_SRC in data:
|
||||
src = data[ATTR_SRC]
|
||||
else:
|
||||
src = ADDR_UNREGISTERED
|
||||
if ATTR_DST in data:
|
||||
dst = data[ATTR_DST]
|
||||
else:
|
||||
dst = ADDR_BROADCAST
|
||||
src = data.get(ATTR_SRC, ADDR_UNREGISTERED)
|
||||
dst = data.get(ATTR_DST, ADDR_BROADCAST)
|
||||
if ATTR_CMD in data:
|
||||
cmd = data[ATTR_CMD]
|
||||
else:
|
||||
@ -374,10 +368,7 @@ class CecEntity(Entity):
|
||||
self._logical_address = logical
|
||||
self.entity_id = "%s.%d" % (DOMAIN, self._logical_address)
|
||||
self._set_attr_name()
|
||||
if self._device.type in ICONS_BY_TYPE:
|
||||
self._attr_icon = ICONS_BY_TYPE[self._device.type]
|
||||
else:
|
||||
self._attr_icon = ICON_UNKNOWN
|
||||
self._attr_icon = ICONS_BY_TYPE.get(self._device.type, ICON_UNKNOWN)
|
||||
|
||||
def _set_attr_name(self):
|
||||
"""Set name."""
|
||||
|
@ -77,10 +77,7 @@ async def async_call_action_from_config(
|
||||
data[ATTR_BRIGHTNESS_PCT] = config[ATTR_BRIGHTNESS_PCT]
|
||||
|
||||
if config[CONF_TYPE] == TYPE_FLASH:
|
||||
if ATTR_FLASH in config:
|
||||
data[ATTR_FLASH] = config[ATTR_FLASH]
|
||||
else:
|
||||
data[ATTR_FLASH] = FLASH_SHORT
|
||||
data[ATTR_FLASH] = config.get(ATTR_FLASH, FLASH_SHORT)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, data, blocking=True, context=context
|
||||
|
@ -165,10 +165,7 @@ class MonopriceZone(MediaPlayerEntity):
|
||||
self._attr_volume_level = state.volume / MAX_VOLUME
|
||||
self._attr_is_volume_muted = state.mute
|
||||
idx = state.source
|
||||
if idx in self._source_id_name:
|
||||
self._attr_source = self._source_id_name[idx]
|
||||
else:
|
||||
self._attr_source = None
|
||||
self._attr_source = self._source_id_name.get(idx)
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self) -> bool:
|
||||
|
@ -332,10 +332,7 @@ async def async_handle_waypoints_message(hass, context, message):
|
||||
if user not in context.waypoint_whitelist:
|
||||
return
|
||||
|
||||
if "waypoints" in message:
|
||||
wayps = message["waypoints"]
|
||||
else:
|
||||
wayps = [message]
|
||||
wayps = message.get("waypoints", [message])
|
||||
|
||||
_LOGGER.info("Got %d waypoints from %s", len(wayps), message["topic"])
|
||||
|
||||
|
@ -252,6 +252,7 @@ select = [
|
||||
"PGH004", # Use specific rule codes when using noqa
|
||||
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
|
||||
"SIM117", # Merge with-statements that use the same scope
|
||||
"SIM401", # Use get from dict with default instead of an if block
|
||||
"T20", # flake8-print
|
||||
"UP", # pyupgrade
|
||||
"W", # pycodestyle
|
||||
|
Loading…
x
Reference in New Issue
Block a user