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

Generalize settings and sensors into properties #1753

Merged
merged 1 commit into from
Mar 5, 2023

Conversation

rytilahti
Copy link
Owner

@rytilahti rytilahti commented Mar 5, 2023

This removes the unnecessary division between sensors and settings in favor of just having "properties" that can have different access flags.

This will greatly simplify the API as all properties are alike, the difference is just in the access flags.

The earlier API to get settable properties (settings) and readable properties (sensors) is kept intact for the time being.

  • SettingDescriptor is no more, all readable and writable properties are described using PropertyDescriptors:

    • SettingType is replaced with PropertyConstraint to allow signaling allowed ranges or choices.
    • EnumSettingDescriptor is now EnumDescriptor
    • NumberSettingDescriptor is now RangeDescriptor
  • Add 'access' to Descriptor

    • This will also allow for generic descriptors interface in the future, if needed.
  • Add 'property' to Descriptor

    • None for actions, allwos more generic interface for properties.
  • Add 'properties' method to 'Device' to get all property descriptors. 'settings' and 'sensors' return a filtered dict based on the properties for backwards compat.

This removes the unnecessary division between sensors and settings in favor of just having "properties" that can have different access flags.

This will greatly simplify the API as all properties are alike, the difference is just in the access flags.

The earlier API to get settable properties (settings) and readable properties (sensors) is kept intact for the time being.

* SettingDescriptor is no more, all readable and writable properties are described using PropertyDescriptors.
    * SettingType is replaced with PropertyConstraint to allow signaling allowed ranges or choices.
    * EnumSettingDescriptor is now EnumDescriptor
    * NumberSettingDescriptor is now RangeDescriptor

* Add 'access' to Descriptor
    * This will also allow for generic `descriptors` interface in the future, if needed.

* Add 'property' to Descriptor
    * None for actions, allwos more generic interface for properties.

* Add 'properties' method to 'Device' to get all property descriptors. 'settings' and 'sensors' return a filtered dict based on the properties for backwards compat.
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2023

Codecov Report

Merging #1753 (d01acfa) into master (69a5ff9) will decrease coverage by 0.13%.
The diff coverage is 78.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #1753      +/-   ##
==========================================
- Coverage   81.68%   81.56%   -0.13%     
==========================================
  Files         193      192       -1     
  Lines       18029    18028       -1     
  Branches     3845     3846       +1     
==========================================
- Hits        14727    14704      -23     
- Misses       3014     3038      +24     
+ Partials      288      286       -2     
Impacted Files Coverage Δ
miio/integrations/genericmiot/genericmiot.py 35.83% <35.00%> (-0.11%) ⬇️
miio/integrations/yeelight/light/yeelight.py 77.98% <40.00%> (ø)
miio/device.py 80.44% <71.79%> (-0.77%) ⬇️
miio/miot_models.py 75.00% <86.95%> (-1.06%) ⬇️
miio/devicestatus.py 91.66% <90.90%> (-0.37%) ⬇️
miio/descriptors.py 100.00% <100.00%> (+3.63%) ⬆️
miio/integrations/genericmiot/cli_helpers.py 13.88% <100.00%> (ø)
...ions/viomi/viomidishwasher/test_viomidishwasher.py 86.07% <100.00%> (-12.68%) ⬇️
...egrations/viomi/viomidishwasher/viomidishwasher.py 65.13% <0.00%> (-5.97%) ⬇️
... and 9 more

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

@rytilahti
Copy link
Owner Author

Windows builds are failing due to a dependency issue, which I'll ignore for now to unblock further development.

@rytilahti rytilahti merged commit 812dcbd into master Mar 5, 2023
@rytilahti rytilahti deleted the feat/descriptor_access branch March 5, 2023 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants