Add light specs for yeelight#1163
Add light specs for yeelight#1163rytilahti merged 11 commits intorytilahti:masterfrom Kirmas:yeelight_addspecs
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1163 +/- ##
==========================================
+ Coverage 76.61% 77.90% +1.28%
==========================================
Files 77 79 +2
Lines 9155 9222 +67
Branches 756 762 +6
==========================================
+ Hits 7014 7184 +170
+ Misses 1958 1853 -105
- Partials 183 185 +2
Continue to review full report at Codecov.
|
@rytilahti Could you give some advice with 1 and 2 |
So, we could only initialize it only once inside the module. Think about a situation with 10 yeelight bulbs, calling the static method would cause file I/O & parsing for each and every instance. This would also skip those if the Yeelight module never gets initialized. Here's what I think could work: Does that make sense to you?
Better use |
I`m not satisfied but agree I/O for home assistant(or any other CD card user) more important than RAM. Hope in the future SSD will be cost nothing and all off us start to use it (and size must be like CD card) :) @rytilahti Please look current state. |
rytilahti
left a comment
There was a problem hiding this comment.
Just a couple of small changes and this is good to go.
| value["background_light"], | ||
| value["supports_color"], | ||
| ) | ||
| YeelightSpecHelper._models[key] = info |
There was a problem hiding this comment.
Even when improbable that someone adds a duplicate entry to the file, I'd check here if the key already exists and raise an exception if so.
There was a problem hiding this comment.
I did this but as I understand yaml.safe_load ignore key duplicates. I tried to add duplicate and wouldnt catch exception :(
There was a problem hiding this comment.
Okay, it's a dictionary already so new values will override the existing one. Let's do the following: remove the duplicate handling (no need to check for the key & raise the exception) and let's merge this then.

This is base support for spec file & uses it to provide information about supported models. Second PR based on #1094 (review)