Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
include tenacity retrying
Browse files Browse the repository at this point in the history
  • Loading branch information
bbo76 committed Dec 27, 2021
1 parent 262e991 commit c3733af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions custom_components/beewi_light/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import homeassistant.util.color as color_util

from bulbeewipy import BeewiSmartLight
import tenacity

_LOGGER = logging.getLogger(__name__)

# Validation of the user's configuration
Expand Down Expand Up @@ -72,6 +74,7 @@ def rgbw_color(self):
def is_on(self):
return self._isOn

@tenacity.retry(stop=(tenacity.stop_after_delay(10) | tenacity.stop_after_attempt(5)))
def turn_on(self, **kwargs):
try:
brightness = kwargs.get(ATTR_BRIGHTNESS)
Expand Down Expand Up @@ -103,13 +106,15 @@ def turn_on(self, **kwargs):
except Exception as e:
_LOGGER.error(e)

@tenacity.retry(stop=(tenacity.stop_after_delay(10) | tenacity.stop_after_attempt(5)))
def turn_off(self, **kwargs):
try:
self._light.turnOff()
self._isOn = False
except Exception as e:
_LOGGER.error(e)

@tenacity.retry(stop=(tenacity.stop_after_attempt(5)))
def update(self):
try:
_LOGGER.debug("Trying get states")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/beewi_light/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Beewi Light",
"documentation": "https://github.com/bbo76/light.beewi",
"codeowners": ["@bbo76"],
"requirements": ["bulbeewipy==1.0.3"],
"requirements": ["bulbeewipy==1.0.4","tenacity"],
"version": "2.0.0",
"iot_class": "local_polling"
}

0 comments on commit c3733af

Please sign in to comment.