@@ -32,14 +32,21 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
3232 for plug in data .wiserhub .devices .smartplugs .all :
3333 wiser_selects .extend ([WiserSmartPlugModeSelect (data , plug .id )])
3434
35+ #Added LGO LED indicator select if supported
36+ if plug .is_led_indicator_supported :
37+ wiser_selects .extend (
38+ [WiserSmartplugLedIndicatorSelect (data , plug .id )]
39+ )
40+ #End Added LGO LED indicator select if supported
41+
3542 if data .wiserhub .devices .lights .count > 0 :
3643 _LOGGER .debug ("Setting up Light mode select" )
3744 for light in data .wiserhub .devices .lights .all :
3845 wiser_selects .extend ([WiserLightModeSelect (data , light .id )])
46+ if light .is_led_indicator_supported :
47+ wiser_selects .extend ([WiserLightLedIndicatorSelect (data , light .id )])
3948
4049 if light .is_dimmable :
41- if light .is_led_indicator_supported :
42- wiser_selects .extend ([WiserLightLedIndicatorSelect (data , light .id )])
4350 if light .is_power_on_behaviour_supported :
4451 wiser_selects .extend (
4552 [WiserLightPowerOnBehaviourSelect (data , light .id )]
@@ -351,3 +358,49 @@ async def async_select_option(self, option: str) -> None:
351358 _LOGGER .error (
352359 f"{ option } is not a valid { self .name } . Please choose from { self ._options } "
353360 )
361+
362+ class WiserSmartplugLedIndicatorSelect (WiserSelectEntity ):
363+ def __init__ (self , data , smartplug_id ) -> None :
364+ """Initialize the sensor."""
365+ self ._device_id = smartplug_id
366+ super ().__init__ (data )
367+ self ._device = self ._data .wiserhub .devices .smartplugs .get_by_id (self ._device_id )
368+ self ._options = self ._device .available_led_indicator
369+
370+ @callback
371+ def _handle_coordinator_update (self ) -> None :
372+ """Fetch new state data for the sensor."""
373+ super ()._handle_coordinator_update ()
374+ self ._device = self ._data .wiserhub .devices .smartplugs .get_by_id (self ._device_id )
375+ self ._options = self ._device .available_led_indicator
376+ self .async_write_ha_state ()
377+
378+ @property
379+ def unique_id (self ):
380+ """Return unique ID of device."""
381+ return get_unique_id (
382+ self ._data ,
383+ self ._device .product_type ,
384+ "led-indicator" ,
385+ self ._device_id ,
386+ )
387+
388+ @property
389+ def name (self ):
390+ """Return Name of device."""
391+ return f"{ get_device_name (self ._data , self ._device_id )} Led Indicator"
392+
393+ @property
394+ def current_option (self ) -> str :
395+ return self ._device .led_indicator
396+
397+ @hub_error_handler
398+ async def async_select_option (self , option : str ) -> None :
399+ _LOGGER .debug (f"Setting { self .name } to { option } " )
400+ if option in self ._options :
401+ await self ._device .set_led_indicator (option )
402+ await self .async_force_update ()
403+ else :
404+ _LOGGER .error (
405+ f"{ option } is not a valid { self .name } . Please choose from { self ._options } "
406+ )
0 commit comments