Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rytilahti
Copy link
Owner

@rytilahti rytilahti commented Feb 10, 2021

  • Implements __repr__ to return the usual pretty repr with all defined properties
  • Special cases can override this behavior if really needed.

Prints out currently also properties returning None, opinions?
Another thing is that the order of elements in the response is not guaranteed, but no one should not be parsing these anyway, so I think it's a non-issue.

@starkillerOG
Copy link
Contributor

@rytilahti nice cleanup, always good to simplify things!

Would it be possible to use the same logic to add a "self.props" property to each class of python miio that is a dict with the keys beeing the name of the property and the value the value of the property?

That would be extremely helpfull when moving state attributes to seperate sensors in HomeAssistant.

@rytilahti
Copy link
Owner Author

@starkillerOG yes, it'd be great to improve the status containers even further, especially to simplify the integration you are talking about. I'm not sure what's the best approach here, but instead of using only plain properties in the code, we could allow defining also information like unit of measurement and measurement type, to allow easier mapping against what homeassistant wants (https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes).

@starkillerOG
Copy link
Contributor

Yea you are right, maybe just merge this and let the properties wait untill we have a simular yaml file as with the subdevices to load the info from.

* Implements __repr__ to return the usual pretty repr with all defined properties
@rytilahti rytilahti force-pushed the janitor/generalize_status_repr branch from 3aedf16 to 4735ad9 Compare March 9, 2021 00:03
@rytilahti rytilahti force-pushed the janitor/generalize_status_repr branch from 1729412 to 78ffd6c Compare March 9, 2021 00:22
@rytilahti rytilahti merged commit 252d3de into master Mar 9, 2021
@rytilahti rytilahti deleted the janitor/generalize_status_repr branch March 9, 2021 00:31
@rytilahti rytilahti mentioned this pull request Mar 13, 2021
xvlady pushed a commit to xvlady/python-miio that referenced this pull request May 9, 2021
* Cleanup: add DeviceStatus to simplify status containers

* Implements __repr__ to return the usual pretty repr with all defined properties

* Convert dreamvacuum_miot to use devicestatus

* Add missing imports
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.

3 participants