mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix ADS light when parameter adsvar_brightness is not set (#19636)
* ADS light breaks if optional parameter adsvar_brightness is not set Just a small change to prevent exception if optional parameter adsvar_brightness is not set * corrected blank lines
This commit is contained in:
parent
cc8b811572
commit
4b90ed6b22
@ -63,15 +63,16 @@ class AdsLight(Light):
|
|||||||
self._brightness = value
|
self._brightness = value
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
self.hass.async_add_job(
|
self.hass.async_add_executor_job(
|
||||||
self._ads_hub.add_device_notification,
|
self._ads_hub.add_device_notification,
|
||||||
self.ads_var_enable, self._ads_hub.PLCTYPE_BOOL, update_on_state
|
self.ads_var_enable, self._ads_hub.PLCTYPE_BOOL, update_on_state
|
||||||
)
|
)
|
||||||
self.hass.async_add_job(
|
if self.ads_var_brightness is not None:
|
||||||
self._ads_hub.add_device_notification,
|
self.hass.async_add_executor_job(
|
||||||
self.ads_var_brightness, self._ads_hub.PLCTYPE_INT,
|
self._ads_hub.add_device_notification,
|
||||||
update_brightness
|
self.ads_var_brightness, self._ads_hub.PLCTYPE_INT,
|
||||||
)
|
update_brightness
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -96,8 +97,10 @@ class AdsLight(Light):
|
|||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
|
support = 0
|
||||||
if self.ads_var_brightness is not None:
|
if self.ads_var_brightness is not None:
|
||||||
return SUPPORT_BRIGHTNESS
|
support = SUPPORT_BRIGHTNESS
|
||||||
|
return support
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the light on or set a specific dimmer value."""
|
"""Turn the light on or set a specific dimmer value."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user