Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion miio/miot_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class MiotProperty(MiotBaseModel):
choices: Optional[list[MiotEnumValue]] = Field(alias="value-list")
gatt_access: Optional[list[Any]] = Field(alias="gatt-access")

source: Optional[int] = None

# TODO: currently just used to pass the data for miiocli
# there must be a better way to do this..
value: Optional[Any] = None
Expand All @@ -238,7 +240,10 @@ def pretty_value(self):

if self.choices is not None:
# TODO: find a nicer way to get the choice by value
selected = next(c.description for c in self.choices if c.value == value)
selected = next(
(c.description for c in self.choices if c.value == value),
self.choices[0],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that the reported 1 is for the index in the available choices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be. But the app didn't parse that 1 index as a value. So unsure what happened.
The miot protocol works in mysterious ways

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if you want to test it with different values on your device to confirm the behavior, it could be interesting. Otherwise, I would avoid changing the behavior here now, as it feels like a firmware bug on your device.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if you want to test it with different values on your device to confirm the behavior, it could be interesting. Otherwise, I would avoid changing the behavior here now, as it feels like a firmware bug on your device.

Yeah it does sound like a firmware bug. Would it be better if it returned None instead?

)
current = f"{selected} (value: {value})"
return current

Expand Down
Loading