Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
majki09 committed Jan 2, 2023
1 parent 80fa671 commit 18bfe48
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Author: majki
#
"""
<plugin key="LG_ThinQ" name="LG ThinQ" author="majki" version="2.1.1" externallink="https://github.com/majki09/domoticz_lg_thinq_plugin">
<plugin key="LG_ThinQ" name="LG ThinQ" author="majki" version="2.1.2" externallink="https://github.com/majki09/domoticz_lg_thinq_plugin">
<description>
<h2>LG ThinQ domoticz plugin</h2><br/>
Plugin uses LG API v2. All API interface (with some mods) comes from <a href="https://github.com/no2chem/wideq"> github.com/no2chem/wideq</a>.<br/><br/>
Expand Down Expand Up @@ -374,7 +374,6 @@ def onHeartbeat(self):
except wideq.NotLoggedInError:

# read AC parameters and Client state
Domoticz.Log("Session expired, refreshing...")
self.lg_device = self.wideq_object.operate_device(device_id=self.DEVICE_ID)

self.heartbeat_counter = self.heartbeat_counter + 1
Expand Down Expand Up @@ -731,8 +730,6 @@ def _force_device(self, client, device_id):
return device

def operate_device(self, device_id: str = ""):
lg_device = None

client = wideq.Client.load(self.state)
client._country = self.country
client._language = self.language
Expand All @@ -744,15 +741,14 @@ def operate_device(self, device_id: str = ""):
# Loop to retry if session has expired.
while True:
try:
if len(device_id) > 0:
lg_device = wideq.ACDevice(client, self._force_device(client, device_id))
lg_device = wideq.ACDevice(client, self._force_device(client, device_id))
break

except TypeError:
Domoticz.Log("Could NOT log in. Probably you need to accept new agreement in the mobile app.")

except wideq.NotLoggedInError or wideq.core.NotLoggedInError:
Domoticz.Log("Session expired.")
Domoticz.Log("Session expired, refreshing...")
client.refresh()

except UserError as exc:
Expand Down

0 comments on commit 18bfe48

Please sign in to comment.