Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Dec 21, 2020
1 parent c7ec21c commit d295fe7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,21 @@ class Device(metaclass=DeviceGroupMeta):
This class should not be initialized directly but a device-specific class inheriting
it should be used instead of it."""

retry_count = 3
timeout = 5

def __init__(
self,
ip: str = None,
token: str = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = 5,
timeout: int = None,
) -> None:
self.ip = ip
self.token = token
if hasattr(self, "timeout"):
timeout = self.timeout
timeout = timeout if timeout is not None else self.timeout
self._protocol = MiIOProtocol(
ip, token, start_id, debug, lazy_discover, timeout
)
Expand All @@ -127,7 +129,7 @@ def send(
self,
command: str,
parameters: Any = None,
retry_count=3,
retry_count: int = None,
*,
extra_parameters=None,
) -> Any:
Expand All @@ -145,8 +147,7 @@ def send(
:param int retry_count: How many times to retry on error
:param dict extra_parameters: Extra top-level parameters
"""
if hasattr(self, "retry_count"):
retry_count = self.retry_count
retry_count = retry_count if retry_count is not None else self._retry_count
return self._protocol.send(
command, parameters, retry_count, extra_parameters=extra_parameters
)
Expand Down

0 comments on commit d295fe7

Please sign in to comment.