Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce common interfaces based on device descriptors #1845

Merged
merged 6 commits into from
Oct 20, 2023

Conversation

rytilahti
Copy link
Owner

@rytilahti rytilahti commented Oct 20, 2023

Breaking change: MiotDevice.call_action has been renamed to MiotDevice.call_action_from_mapping.


This completes the common descriptor-based API for all device-inherited classes:

  • status() -> DeviceStatus: returns device status
  • descriptors() -> DescriptorCollection[Descriptor]: returns all defined descriptors
  • actions() -> DescriptorCollection[ActionDescriptor]: returns all defined actions
  • settings() -> DescriptorCollection[PropertyDescriptor]: returns all settable descriptors
  • sensors() -> DescriptorCollection[PropertyDescriptor]: returns all read-only descriptors
  • call_action(name, params): to call action using its name
  • change_setting(name, params): to change a setting using its name

These functionalities are also provided as cli commands for all devices:

  • status
  • descriptors
  • actions
  • settings
  • sensors
  • call (call_action)
  • set (change_setting)

TODO:

  • Add tests for DescriptorCollection
  • Add docs

Fixes #1814
Fixes #1692

This completes the common descriptor-based API for all device-inherited classes:
- status() -> DeviceStatus: returns device status
- descriptors() -> DescriptorCollection[Descriptor]: returns all defined descriptors
- actions() -> DescriptorCollection[ActionDescriptor]: returns all defined actions
- settings() -> DescriptorCollection[PropertyDescriptor]: returns all settable descriptors
- sensors() -> DescriptorCollection[PropertyDescriptor]: returns all read-only descriptors
- call_action(name, params): to call action using its name
- change_setting(name, params): to change a setting using its name

These functionalities are also provided as cli commands for all devices:
- status
- descriptors
- actions
- settings
- sensors
- call (call_action)
- set (change_setting)
@rytilahti rytilahti added this to the 0.6.0 milestone Oct 20, 2023
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #1845 (5f676c7) into master (4390234) will increase coverage by 0.32%.
The diff coverage is 85.62%.

@@            Coverage Diff             @@
##           master    #1845      +/-   ##
==========================================
+ Coverage   80.87%   81.20%   +0.32%     
==========================================
  Files         193      193              
  Lines       18599    18587      -12     
  Branches     4021     4022       +1     
==========================================
+ Hits        15042    15093      +51     
+ Misses       3279     3219      -60     
+ Partials      278      275       -3     
Files Coverage Δ
miio/__init__.py 100.00% <100.00%> (ø)
miio/device.py 88.19% <100.00%> (+7.75%) ⬆️
miio/integrations/zhimi/fan/zhimi_miot.py 83.33% <100.00%> (ø)
miio/miot_device.py 88.15% <100.00%> (ø)
miio/devicestatus.py 91.58% <88.88%> (-0.08%) ⬇️
...tegrations/scishare/coffee/scishare_coffeemaker.py 73.01% <76.92%> (-0.20%) ⬇️
miio/integrations/genericmiot/genericmiot.py 38.75% <38.46%> (+2.91%) ⬆️
miio/descriptorcollection.py 86.48% <86.48%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rytilahti rytilahti force-pushed the refactor/descriptorcollection branch from b20fef6 to ae602a9 Compare October 20, 2023 18:31
@rytilahti
Copy link
Owner Author

The docstrings shall do fine for now so I'll just merge this to allow people test it, proper docs for library usage can be added in a separate PR.

@rytilahti rytilahti merged commit b50f0f2 into master Oct 20, 2023
15 of 19 checks passed
@rytilahti rytilahti deleted the refactor/descriptorcollection branch October 20, 2023 22:56
rytilahti added a commit that referenced this pull request Oct 21, 2023
This is not needed anymore, as #1845 reports on missing identifiers and roborocks are covered by a wildcard matcher in devicefactory
rytilahti added a commit that referenced this pull request Oct 23, 2023
Fixes regression caused by introduction of the common device API (#1845)
rytilahti added a commit that referenced this pull request Oct 23, 2023
This is not needed anymore, as #1845 reports on missing identifiers and
roborocks are covered by a wildcard matcher in devicefactory.

The original reason for adding this warning was to gather a list of
devices that we should add to the supported devices list for
devicefactory, but I think we are well covered now at least for roborock
(closing the issues below, other integrations need to be adapted to use
wildcards where feasible).
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.

Implement common API for sensors, settings and actions genericmiot: handle duplicate types
1 participant