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

[tr064] fix wanBlockByIP channel and improvements to paramater handling #9655

Merged
merged 1 commit into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bundles/org.openhab.binding.tr064/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ This is an optional parameter and multiple values are allowed.
| `wifi5GHzEnable` | `Switch` | | Enable/Disable the 5.0 GHz WiFi device. |
| `wifiGuestEnable` | `Switch` | | Enable/Disable the guest WiFi. |

Parameters that accept lists (e.g. `macOnline`, `wanBlockIPs`) can contain comments.
Comments are separated from the value with a '#' (e.g. `192.168.0.77 # Daughter's iPhone`).
The full string is used for the channel label.

### Channel `callList`

Call lists are provided for one or more days (as configured) as JSON.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.binding.tr064.internal.config;

import java.util.Collections;
import java.util.List;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand All @@ -29,14 +28,15 @@ public class Tr064RootConfiguration extends Tr064BaseThingConfiguration {
public String password = "";

/* following parameters only available in fritzbox thing */
public List<String> tamIndices = Collections.emptyList();
public List<String> callDeflectionIndices = Collections.emptyList();
public List<String> missedCallDays = Collections.emptyList();
public List<String> rejectedCallDays = Collections.emptyList();
public List<String> inboundCallDays = Collections.emptyList();
public List<String> outboundCallDays = Collections.emptyList();
public List<String> callListDays = Collections.emptyList();
public int phonebookInterval = 0;
public List<String> tamIndices = List.of();
public List<String> callDeflectionIndices = List.of();
public List<String> missedCallDays = List.of();
public List<String> rejectedCallDays = List.of();
public List<String> inboundCallDays = List.of();
public List<String> outboundCallDays = List.of();
public List<String> callListDays = List.of();
public List<String> wanBlockIPs = List.of();
public int phonebookInterval = 600;

public boolean isValid() {
return !host.isEmpty() && !user.isEmpty() && !password.isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
import static java.util.Comparator.comparing;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -92,19 +87,8 @@ private ProfileType createLocalizedProfileType(ProfileType profileType, @Nullabl
final LocalizedKey localizedKey = new LocalizedKey(profileType.getUID(),
locale != null ? locale.toLanguageTag() : null);

final ProfileType cachedlocalizedProfileType = localizedProfileTypeCache.get(localizedKey);
if (cachedlocalizedProfileType != null) {
return cachedlocalizedProfileType;
}

final ProfileType localizedProfileType = profileTypeI18nLocalizationService.createLocalizedProfileType(bundle,
profileType, locale);
if (localizedProfileType != null) {
localizedProfileTypeCache.put(localizedKey, localizedProfileType);
return localizedProfileType;
} else {
return profileType;
}
return Objects.requireNonNull(localizedProfileTypeCache.computeIfAbsent(localizedKey,
key -> profileTypeI18nLocalizationService.createLocalizedProfileType(bundle, profileType, locale)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
*/
@NonNullByDefault
public class SOAPValueConverter {
private static final int REQUEST_TIMEOUT = 5000; // in ms
private final Logger logger = LoggerFactory.getLogger(SOAPValueConverter.class);
private final HttpClient httpClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ public static void checkAvailableChannels(Thing thing, ThingBuilder thingBuilder
} else {
// create a channel for each parameter
parameters.forEach(parameter -> {
String normalizedParameter = UIDUtils.encode(parameter);
// remove comment: split parameter at '#', discard everything after that and remove
// trailing spaces
String normalizedParameter = UIDUtils.encode(parameter.split("#")[0].trim());
ChannelUID channelUID = new ChannelUID(thing.getUID(),
channelId + "_" + normalizedParameter);
ChannelBuilder channelBuilder = ChannelBuilder
Expand Down