-
Notifications
You must be signed in to change notification settings - Fork 568
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
Add DP suggestions to switch platform #125
base: master
Are you sure you want to change the base?
Conversation
Hi @postlund i adapted light.py (because i just have lights) with the following code: from homeassistant.const import CONF_ID, CONF_BRIGHTNESS, CONF_COLOR_TEMP
....
DP_SUGGESTIONS = {
CONF_ID: [1, 20],
CONF_COLOR_MODE: [2, 21],
CONF_BRIGHTNESS: [3, 22],
CONF_COLOR_TEMP: [4, 23],
CONF_COLOR: [5, 24],
} The good point:
|
Ah, yes, right... there's some code sharing going on here and suggestions should not be done for YAML validation. Will fix that. |
@ultratoto14 Pushed an update now which should fix the problem, please give it a spin! |
@postlund unfortunately, still the same error. |
@ultratoto14 What about now? |
@ultratoto14 Added now, thanks for testing and providing values 👍 |
@postlund tested your last one and everything is Ok |
@rospogrigio I think this is ready now. Additional suggestions can be added in other PRs (feel free to do so for other platforms if you have something useful to add). |
I added support for not suggesting IDs already in use by other entities as well. |
@postlund just tested your last commit a switch then a light, the ID dp used in switch is not selected by default in the light 👍 A remark: as the value is selected by default, we do not have the ability to remove it, i mean, i added a RGBW light, the dps are well detected, i wanted to remove the color configuration and make my light white only, but i cannot remove the selected one as the field is already filled and the combo does not contain a "None" entry. Not sure i'm clear, tell me if it's not the case. |
@rospogrigio Right, that's a particular use case I didn't think of. We could add a check box in the dialog where entity type is selected to allow opt-out of automatic suggestions as a work-around? Ultimately we should support unsetting values, but it's a bit tricky so I have not prioritized that right now. One problem is that in a lot of places (which I believe I have mentioned before) we don't treat optional settings as optional, e.g. when a default value is specified we assume the value to always be set so no need to check if it's not. If we allow unsettling values, there's potentially a lot of issues that might happen. We should fix that though. |
Sorry @postlund and others, I am quite in the middle of a shitstorm (my daughter's nursery is closed due to 2 Covid-positive teachers and we are currently quarantined) so I'm having difficulties in testing and reviewing... hopefully the next days will be better, I'll review as soon as I can. Also @postlund I'll need your help with #111 because I have something weird going on, maybe the trout can help too 😄 . By the way, any news about hacs/default#662 ? Will get back to you soon, bye! |
@postlund I get the same problem as with #124 (discovery doesn't work). _Edit: sorry, my fault, my main HA instance was still running, even if I had stopped it Will test it again later. _ |
Shouldn't be any problem, I think we can fix that anyway in a good way. |
And oh, no pressure @rospogrigio, family goes first. Take care! (No news regarding HACS PR, but I saw someone asking for a review and the answer was in all-caps, so we shouldn't do that) |
@rospogrigio I added a check box so you can opt-out from suggestions. |
205e3f6
to
e3a2a2b
Compare
Hi @postlund, i see more and more issues that may be fixed once this one is merged. I just bought some sockets with power consumption and I also have multiple kind of lights (as you already know 😄 ) |
@ultratoto14 Nothing more on my end, we just need to wait for the situation to ease up a bit so @rospogrigio can review 😊 |
d89fa33
to
b55de3a
Compare
Hi @postlund , I'm back and I tried this PR with my 2-gang switch, however I have 2 issues:
|
@rospogrigio Welcome back 🎩
|
PS, what about hacs/default#662 ? I really don't want to be pushy but it's nearly one month since I created the PR... is there any way we can ask for a review? |
Yeah, the HACS issue is really taking a lot of time. There was a race a couple of days ago, lots of PRs were merged but not yours for some reason. Not sure what to do. |
I really don't know, I see that there are also other PRs slightly older than ours waiting for merge but would really know why this is taking so long... let's give them a couple of more days and then let's try to ask for a review and keep fingers crossed. |
b55de3a
to
13d1649
Compare
13d1649
to
b4133ef
Compare
b4133ef
to
368c269
Compare
In light DP_SUGGESTIONS, you can add 24 is usually used for color value and 25 for scene but one user reported that on his light, there's no scene support and color is on 25. @postlund, @rospogrigio I initiated a wiki page for known working devices if you want to add yours Known Devices |
Hi guys I am new here but this addon has made my life SO MUCH BETTER! that I want to chip in. I am using: Feit Dimmer (from Costco) Feit Electric Wi-Fi Smart Plug (from costco) Both work Super well also local tuya fixed issue with home assistant tuya integration where if I turn off the light with a classic 3 way switch the light would stay "On" on Home Assistant. That said the instructions for this integration needs some work. Maybe even including some pictures. I will be glad to help with refining the instructions. However I am new to this. So I am not sure how I would go about doing that. |
I will continue working on this PR as my next task (or rather, I already have). To allow more flexibility, to support the rather complex def suggest(dps, used_dps):
... The Expected return value is a dict with options, mapping to datapoints to use. Something like this: def suggest(dps, used_dps):
return {
CONF_ID: 1,
CONF_FOOBAR: 20,
} I'll see if this hold and hopefully have something ready by tonight or tomorrow. Will only focus on the |
@postlund, I like the id of already used |
@ultratoto14 I guess that it would be possible to some extent. It might be a future improvement, but I won't consider it now. Once we have the database, we can populate that locally with devices that have been manually set up and treat them as part of the database. That way we get a generic implementation. |
Basic framework for suggesting datapoints for options in config flow. Currently very basic as it only supports a list of probable datapoints, but we can extend that with for instance regexp later.
Already used datapoints are currently not respected (I.e.ignored in any way). I'm not sure what would be the best way to do that, as you might want to use the same datapoint in several entities (e.g. current consumption as both a switch attribute and a sensor). One idea is to apply this specifically to the ID, so we at least don't suggest an ID that is already used by another entity. One case for this is a double gang socket, where we should suggest DP 2 for the second switch we add. But that's minor future improvement as well.
This feature is opt-in by platforms and only
switch
implement it so far. Basically defineDP_SUGGESTIONS
and that is all. Seeswitch.py
for an example.Relates #93