Skip to content

Commit

Permalink
Replace structured_config with dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleech committed Dec 20, 2022
1 parent 33c14be commit 8d52bb2
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 202 deletions.
9 changes: 4 additions & 5 deletions custom_components/magiqtouch/magiqtouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ async def refresh_state(self, initial=False):
if rsp.status == 401:
raise UnauthorisedTokenException
data = await rsp.json()
new_state = RemoteStatus()
new_state.__update__(data)
new_state = RemoteStatus.from_dict(data)
if self._update_listener_override:
_LOGGER.debug("State watching: %s" % new_state)
self._update_listener_override()
Expand Down Expand Up @@ -208,7 +207,7 @@ def new_remote_props(self, state=None):

async def _send_remote_props(self, data=None, checker=None):
data = data or self.new_remote_props()
json = data.__json__(indent=0).replace("\n", "")
jdata = json.dumps(data.__dict__)
try:
update_lock = threading.Lock()
if checker:
Expand All @@ -222,11 +221,11 @@ def override_listener():
headers = await self._get_auth()
async with self._httpsession.put(
NewWebApiUrl + f"devices/{self._mac_address}", headers=headers,
data=json,
data=jdata,
) as rsp:
_LOGGER.debug(f"Update response received: {rsp.json()}")
if self.verbose:
_LOGGER.warn("Sent: %s" % json)
_LOGGER.warn("Sent: %s" % jdata)

if checker:
# Wait for expected response
Expand Down
6 changes: 1 addition & 5 deletions custom_components/magiqtouch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@
"documentation": "https://gitlab.com/alelec/ha_magiqtouch",
"issue_tracker": "https://gitlab.com/alelec/ha_magiqtouch/-/issues",
"dependencies": [],
"codeowners": ["[email protected]"],
"requirements": [
"structured-config==4.12"
],
"version": "2.0"
"version": "3.0"
}
Loading

0 comments on commit 8d52bb2

Please sign in to comment.