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

Improve Yeelight by using common facilities #1846

Merged

Conversation

rytilahti
Copy link
Owner

@rytilahti rytilahti commented Oct 20, 2023

Add color and color temperature descriptors always and let downstreams handle filtering.
Remove custom cli_format_yeelight in favor of common status reporting.

Expose "toggle" and "set_default" as actions.
Expose "color_mode" sensor.

Old cli status output:

Name: 
Update default on change: False
Delay in minute before off: 0
Music mode: False
Developer mode: True
Main light
   Power: True
   Brightness: 100
   Color mode: 2
   Temperature: 5464
   Color flowing mode: False

New:

rw- Power (light:on): True
rw- Brightness (light:brightness): 100 %
r-- Color mode (YeelightStatus.color_mode): 2
rw- Color temperature (light:color-temperature): 5376 K
r-- Color flow active (YeelightStatus.color_flowing): False
rw- Developer mode enabled (YeelightStatus.developer_mode): True
rw- Save state on change enabled (YeelightStatus.save_state_on_change): False
r-- Device name (YeelightStatus.name): 
r-- Delayed turn off in (YeelightStatus.delay_off): 0 mins
r-- Music mode enabled (YeelightStatus.music_mode): False

Output for actions:

❯ miiocli yeelight actions
Running command actions
Set current as default (Yeelight.set_default)
        Access: --x

Toggle (Yeelight.toggle)
        Access: --x

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
Add color and color temperature descriptors always and let downstreams handle filtering.
Remove custom cli_format_yeelight in favor of common status reporting.

Expose "toggle" and "set_default" as actions.
Expose "color_mode" sensor.
@rytilahti rytilahti force-pushed the yeelight/refactor/use_descriptorcollection_interfaces branch from 8e568d3 to a6bc6c6 Compare October 20, 2023 18:33
Base automatically changed from refactor/descriptorcollection to master October 20, 2023 22:56
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #1846 (1e23284) into master (b50f0f2) will increase coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1846      +/-   ##
==========================================
+ Coverage   81.19%   81.35%   +0.16%     
==========================================
  Files         193      193              
  Lines       18587    18555      -32     
  Branches     4022     4023       +1     
==========================================
+ Hits        15091    15096       +5     
+ Misses       3221     3184      -37     
  Partials      275      275              
Files Coverage Δ
miio/integrations/yeelight/light/yeelight.py 89.83% <100.00%> (+11.84%) ⬆️

... and 1 file with indirect coverage changes

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

@rytilahti rytilahti merged commit 72880ae into master Oct 20, 2023
15 of 18 checks passed
@rytilahti rytilahti deleted the yeelight/refactor/use_descriptorcollection_interfaces branch October 20, 2023 23:05
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.

1 participant