Skip to content

Commit

Permalink
More safety property mapping of the device status.
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Oct 21, 2017
1 parent 67196c2 commit c7687b6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion miio/philips_eyecare.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import logging
from .device import Device
from typing import Any, Dict
from collections import defaultdict

_LOGGER = logging.getLogger(__name__)


class PhilipsEyecare(Device):
Expand Down Expand Up @@ -70,7 +74,15 @@ def status(self):
"get_prop",
properties
)
return PhilipsEyecareStatus(dict(zip(properties, values)))
properties_count = len(properties)
values_count = len(values)
if properties_count != values_count:
_LOGGER.debug(
"Count (%s) of requested properties does not match the "
"count (%s) of received values.",
properties_count, values_count)

return PhilipsEyecareStatus(defaultdict(lambda: None, zip(properties, values)))


class PhilipsEyecareStatus:
Expand Down

0 comments on commit c7687b6

Please sign in to comment.