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

[amazonechocontrol] fix cycling of UNKOWN/ONLINE for smarthome devices #124

Merged
merged 1 commit into from
Jun 9, 2021

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Jun 7, 2021

The code did not properly handle the case where the capability is present but not the individual device and thus cycled between UNKNOWNand ONLINE.

Signed-off-by: Jan N. Klug jan.n.klug@rub.de

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@J-N-K J-N-K added the bug Something isn't working label Jun 7, 2021
@J-N-K J-N-K added this to the 3.1.3 milestone Jun 7, 2021
@J-N-K J-N-K requested review from mgeramb and Trinitus01 June 7, 2021 14:08
for (HandlerBase handlerBase : handlers.values()) {
UpdateChannelResult result = new UpdateChannelResult();
for (String interfaceName : handlerBase.getSupportedInterface()) {
List<JsonObject> stateList = mapInterfaceToStates.get(interfaceName);
if (stateList != null) {
try {
handlerBase.updateChannels(interfaceName, stateList, result);
} catch (Exception e) {
} catch (RuntimeException e) {
// We catch all exceptions, otherwise all other things are not updated!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is a good idea to change to RuntimeException here. If anything else happens which is not expected, all other things will not be updated. This was the reason for catching Exception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But all exceptions that do not inherit from RuntimeException are checked exceptions and thus the compiler makes sure that they are catched.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see, this feature does not exist in C#, so I'am not familiar with it.

@@ -255,11 +252,7 @@ public void updateChannelStates(List<SmartHomeBaseDevice> allDevices,
}
}

if (stateFound) {
updateStatus(ThingStatus.ONLINE);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we a debug trace instead of the updateStatus would be better. Removing this "if" complete would make diagnostic much harder.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logging in l. 228 is exactly that. It just exists early and skips the processing the lookup of applianceIds and interfaces if the state array is empty.

@J-N-K J-N-K merged commit 024e687 into smarthomej:main Jun 9, 2021
@J-N-K J-N-K deleted the aec branch June 9, 2021 07:33
J-N-K added a commit that referenced this pull request Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants