-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[shelly] Fix Shelly Pro 4PM discovery, thing init for unknown thing #18902
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
Conversation
@jlaur During testing I recognized that Pro 2 was discovered, but not initialized. For now I fixed it by initializing device.mode = "relay" and kept the "shellypro2-relay" thing id. Option b) would be to remove the "-relay" from the thing id, in fact there is no need for anymore. However, consequently we would have to rename thing id shellypro2-relay to shellypro2, but this breaks backward compatibility. Option c) we implement b), but keep thing definition for shellypro2-relay. New discovered things map to shellypro2, whereas old setups continue to use shellypro2-relay What do you think? |
I need a bit of additional context: Is it related to discovery, initialization or both? With #18882 the device type mapping should now work correctly, so that e.g. SPSW-002XE16EU with mode = "" will correctly map to thing type Without manually setting mode to "relay", where will the problem occur - can you point me to the code line? |
See ShellyBaseHandler:343
reqMode is relay and mode "" |
...ding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
Show resolved
Hide resolved
I think there is also a problem here: Lines 270 to 271 in b7a64a0
Line 223 in b7a64a0
If the |
...g.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java
Show resolved
Hide resolved
So we rely on two things there:
Is that correct? I'll need to think some more about this. I'm trying to figure out how such things are usually determined, but I'm currently a bit at a loss, so will probably need to try again with a fresh mind. 🙂 |
if we change the naming those would be ok, but you're right, in this case the old thing type wouldn't work and needs special handling. So I suggest to go with the current version. |
unknown thing Signed-off-by: Markus Michels <[email protected]>
Signed-off-by: Markus Michels <[email protected]>
Signed-off-by: Markus Michels <[email protected]>
151c9c9
to
32fc95d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few additional comments, otherwise LGTM. There is also a test to be fixed.
...ab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1HttpApi.java
Show resolved
Hide resolved
...ding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
Outdated
Show resolved
Hide resolved
...ding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
Outdated
Show resolved
Hide resolved
While testing with Shelly Shutter, I tried to omit the -relay/-roller suffix and got it working, I'll commit tomorrow |
Signed-off-by: Markus Michels <[email protected]>
Signed-off-by: Markus Michels <[email protected]>
Signed-off-by: Markus Michels <[email protected]>
@jlaur I fixed the build error/unit test |
Only one question:
Did you mean you'd commit something in relation to these test results? |
...g.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java
Show resolved
Hide resolved
There is also this comment unanswered: #18902 (comment) We compare directly by "shellypro2-relay" inside Lines 143 to 144 in 551bb5d
So even if service name was "shellypro2-relay" (which I guess it isn't), it would still call Lines 266 to 280 in 551bb5d
|
@jlaur while testing the implementation I ran into issues that default init mode="relay" if device doesn't provide the mode (relay/roller) impacts discovery of other devices, which is a no go. On the other side keeping the shellypro2-roller naming would be the only exception, also doesn't make sense. Therefor I decided to implement a breaking change in renaming thing shellypro2-relay into shellypro2. This makes is consistent naming schema, but also omits special handlings. Implicitly this also solves the issue above, because now service name and thing name are both shellypro2. Works for the moment, but I agree we should remove this mix. However, this is currently used to handle the case that the Pro2 has 2 relays, but no meters, therefor numMeters have to be 0. I already through how to avoid dependency to device types when determining the number of meters, but couldn't find a way so far. The problem is that the device doesn't return the number of meters in the device settings nor elements like em0/em10/em11/pm0, which could be used. This is included in the status report when meter data changes. However, I already need it at initialization time. I want to check if I could implement an auto-allocation/initialization on status updates instead of initialization, but that needs good testing and might create side effects. Long story short: Could you please review the current changes while I do some additional testing, esp. with detection/initialization of other devices before we merge. Sorry for the effort, but changes to that part of the code always has the risk for nice side effects :-), appreciate your help 👍 |
I already briefly started some draft refactoring regarding to this issue - in relation to #18802. I plan to run through my refactoring steps once again and provide distinct commits per step so you can follow the thinking. I'll then provide a draft PR to discuss. The main objective is to remove all dependencies between service name and thing type id.
I already reviewed up until current state. 👍 Will await the next changes. |
I try to do testing tonight
|
👍
Feature freeze is planned three days from now. After that additional five days until code freeze, i.e. important bugfixes can still get in. So there is not much time left. Can you also have a look at other Shelly PR's with pending reviews? |
looks good from a first check. I was able to discover 75 out of 82 devices on the network. The remaining 7 are device types, which are not integrated with this PR level like Pro Dimmer 1PM/2PM, DALI Dimmer etc. How could I document a breaking change (thing type shellypro2-relay was renamed to shellypro2 and things need to be re-discovered). I do some more testing tomorrow and check a bunch of devices that all channels get created correctly. |
You can create a PR towards the openhab-distro repo adding a line around here: |
I did additional testing and it LGTM, please go ahead and merge |
@jlaur i'll leave it to you to merge. @markus7017 could you both update the start post with a small description of the breaking change so that users have some guidance when looking at the release notes. And please also create a PR with the breaking change notices here: https://github.com/openhab/openhab-distro/pulls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…it for unknown thing (openhab#18902) Signed-off-by: Markus Michels <[email protected]>
…it for unknown thing (openhab#18902) Signed-off-by: Markus Michels <[email protected]> Signed-off-by: Paul Smedley <[email protected]>
This PR fixes some discovery / initialization issues