Skip to content

Commit

Permalink
Fix incorrect access, thanks to @fsalomon for pointing this out!
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Mar 29, 2020
1 parent 48be92b commit 42fcdbc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions miio/miioprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ def send_handshake(self) -> Message:
:raises DeviceException: if the device could not be discovered."""
m = MiIOProtocol.discover(self.ip)
header = m.header.value
if m is not None:
self._device_id = m.header.value.device_id
self._device_ts = m.header.value.ts
self._device_id = header.device_id
self._device_ts = header.ts
self._discovered = True
if self.debug > 1:
_LOGGER.debug(m)
Expand Down Expand Up @@ -179,17 +180,21 @@ def send(
try:
data, addr = s.recvfrom(1024)
m = Message.parse(data, token=self.token)
self._device_ts = m.header.value.ts
if self.debug > 1:
_LOGGER.debug("recv from %s: %s", addr[0], m)

header = m.header.value
payload = m.data.value

self.__id = payload["id"]
self._device_ts = header.ts

if self.debug > 1:
_LOGGER.debug("recv from %s: %s", addr[0], m)

_LOGGER.debug(
"%s:%s (ts: %s, id: %s) << %s",
self.ip,
self.port,
payload.ts,
header.ts,
payload["id"],
payload,
)
Expand Down

0 comments on commit 42fcdbc

Please sign in to comment.