Skip to content

Commit

Permalink
Unbreak the communication when using construct v2.9.23 (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Jan 28, 2018
1 parent b0c04cf commit 17c7a26
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,11 @@ def send(self, command: str, parameters: Any=None, retry_count=3) -> Any:
msg = {'data': {'value': cmd},
'header': {'value': header},
'checksum': 0}
ctx = {'token': self.token}
m = Message.build(msg, ctx)
m = Message.build(msg, token=self.token)
_LOGGER.debug("%s:%s >>: %s", self.ip, self.port, cmd)
if self.debug > 1:
_LOGGER.debug("send (timeout %s): %s",
self._timeout, Message.parse(m, ctx))
self._timeout, Message.parse(m, token=self.token))

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(self._timeout)
Expand All @@ -236,7 +235,7 @@ def send(self, command: str, parameters: Any=None, retry_count=3) -> Any:

try:
data, addr = s.recvfrom(1024)
m = Message.parse(data, ctx)
m = Message.parse(data, token=self.token)
self._device_ts = m.header.value.ts
self._device_id = m.header.value.device_id
if self.debug > 1:
Expand Down

0 comments on commit 17c7a26

Please sign in to comment.