Skip to content

Commit e749587

Browse files
committed
Supported attributtes
1 parent 3b28468 commit e749587

2 files changed

Lines changed: 17 additions & 27 deletions

File tree

custom_components/ir_light/light.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ def __init__(self, hass: HomeAssistant, name: str, config_data: dict):
8181
'BRIGHT_DOWN': self._config_data.get('ir_button_bright_down'),
8282
}
8383

84-
self._effect_list = []
85-
if self.button_map.get('EFFECT_FLASH'):
86-
self._effect_list.append("Flash")
87-
if self.button_map.get('EFFECT_SMOOTH'):
88-
self._effect_list.append("Smooth")
84+
#self._effect_list = []
85+
#if self.button_map.get('EFFECT_FLASH'):
86+
# self._effect_list.append("Flash")
87+
#if self.button_map.get('EFFECT_SMOOTH'):
88+
# self._effect_list.append("Smooth")
89+
90+
self._attr_supported_features = LightEntityFeature(0)
91+
if any(config_data.get(f"ir_button_effect_{e}") for e in ["flash", "smooth"]):
92+
self._attr_supported_features |= LightEntityFeature.EFFECT
8993

9094
@property
9195
def name(self) -> str:
@@ -104,13 +108,13 @@ def brightness(self) -> int | None:
104108
"""Returns brightness (0-255)"""
105109
return self._brightness
106110

107-
@property
108-
def supported_features(self) -> int:
109-
features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR
110-
if self._effect_list:
111-
features |= SUPPORT_EFFECT
112-
self._attr_supported_features = LightEntityFeature.EFFECT
113-
return features
111+
#@property
112+
#def supported_features(self) -> int:
113+
# features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR
114+
# if self._effect_list:
115+
# features |= SUPPORT_EFFECT
116+
# self._attr_supported_features = LightEntityFeature.EFFECT
117+
# return features
114118

115119
@property
116120
def effect_list(self) -> list[str] | None:
@@ -133,9 +137,6 @@ async def _async_map_color_to_button(self, hue: float, sat: float) -> None:
133137
button_id = self._config_data.get("color_white")
134138
if button_id:
135139
await self._async_press_button(button_id)
136-
#await self.hass.services.async_call(
137-
# "homeassistant", "turn_on", {"entity_id": button_id}, blocking=False
138-
#)
139140
return
140141

141142
available_buttons = {}
@@ -159,9 +160,6 @@ async def _async_map_color_to_button(self, hue: float, sat: float) -> None:
159160
if best_button:
160161
_LOGGER.debug(f"Closest match for Hue {hue}: {best_button} (dist: {min_distance})")
161162
await self._async_press_button(best_button)
162-
#await self.hass.services.async_call(
163-
# "homeassistant", "turn_on", {"entity_id": best_button}, blocking=False
164-
#)
165163

166164
async def _async_press_button(self, entity_id: str) -> None:
167165
"""Helper to press the corresponding IR button."""
@@ -190,14 +188,6 @@ async def _async_press_button(self, entity_id: str) -> None:
190188
blocking=False
191189
)
192190

193-
#entity_id = self.button_map.get(action_key)
194-
#if entity_id:
195-
# await self.hass.services.async_call(
196-
# "homeassistant", "turn_on", {"entity_id": entity_id}, blocking=False
197-
# )
198-
#else:
199-
# _LOGGER.warning(f"IR button for action '{action_key}' not found in BUTTON_MAP.")
200-
201191
async def async_turn_on(self, **kwargs) -> None:
202192
"""Turn on light. Manages brightness, color and effect"""
203193

custom_components/ir_light/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "local_polling",
99
"issue_tracker": "https://github.com/Infinitte/HA-IR-Light/issues",
1010
"requirements": [],
11-
"version": "0.2.2"
11+
"version": "0.2.3"
1212
}

0 commit comments

Comments
 (0)