Skip to content

Commit

Permalink
Fixed async issue when pushing settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sockless-coding committed Jun 20, 2024
1 parent 6bcdad1 commit 17cbcb3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions custom_components/panasonic_cc/panasonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)

def api_call_login(func):
def wrapper_call(*args, **kwargs):
try:
func(*args, **kwargs)
except: # noqa: E722
args[0]._api.login()
func(*args, **kwargs)
return wrapper_call


class PanasonicApiDevice:

Expand Down Expand Up @@ -343,9 +336,16 @@ async def set_nanoe_mode(self, nanoe_mode):
)
await self.do_update()

@api_call_login
def set_device(self, args):
self._api.set_device(
self.id,
**args
)

async def set_device(self, args):
try:
await self._api.set_device(
self.id,
**args
)
except:
await self._api.start_session()
await self._api.set_device(
self.id,
**args
)

0 comments on commit 17cbcb3

Please sign in to comment.