Skip to content

Conversation

@rytilahti
Copy link
Owner

This changes the way genericmiotstatus properties are accessed to use normalized names (e.g., light:on = light_on, brush-cleaner:brush-life-level = brush_cleaner_brush_life_level) to make them valid python identifiers, and thus directly accessible using the regular attribute access.

__dir__() is now also implemented for GenericMiotStatus to enable autocompleting these names for easier repling.

Example using mijia.vacuum.v2:

In [7]: for name in sorted(status.property_dict().keys()):
   ...:     print(name)
   ...: 
alarm:alarm
alarm:volume
battery:battery-level
battery:charging-state
brush-cleaner:brush-left-time
brush-cleaner:brush-life-level
clean-record:clean-area
clean-record:clean-time
clean-record:total-clean-area
clean-record:total-clean-count
clean-record:total-clean-time
filter:filter-left-time
filter:filter-life-level
language:language
...

In [8]: status.<tab>
            alarm_alarm                    brush_cleaner_brush_left_time  clean_record_total_clean_area   
            alarm_volume                   brush_cleaner_brush_life_level clean_record_total_clean_count  
            battery_battery_level          clean_record_clean_area        clean_record_total_clean_time  >
            battery_charging_state         clean_record_clean_time        data                            

In [9]: status.clean_record_total_clean_count
Out[9]: 30506

This changes the way genericmiotstatus properties are accessed to use normalized names (e.g., light:on = light_on, brush-cleaner:brush-life-level = brush_cleaner_brush_life_level) to make them valid python identifiers.

The __dir__() is now also implemented for GenericMiotStatus to enable autocompleting these names.
@rytilahti rytilahti merged commit ae50f23 into master Feb 9, 2023
@rytilahti rytilahti deleted the feat/genericmiotstatus_expose_attributes branch February 9, 2023 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants