+++ /dev/null
-/**
- * Copyright (c) 2010-2024 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.nuvo.internal.communication;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.nuvo.internal.NuvoException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class to create a default NuvoDefaultConnector before initialization is complete.
- *
- * @author Laurent Garnier - Initial contribution
- * @author Michael Lobstein - Adapted for the Nuvo binding
- */
-@NonNullByDefault
-public class NuvoDefaultConnector extends NuvoConnector {
-
- private final Logger logger = LoggerFactory.getLogger(NuvoDefaultConnector.class);
-
- @Override
- public void open() throws NuvoException {
- logger.warn("Nuvo binding incorrectly configured. Please configure for Serial or IP over serial connection");
- setConnected(false);
- }
-
- @Override
- public void close() {
- setConnected(false);
- }
-}
import org.openhab.binding.nuvo.internal.NuvoThingActions;
import org.openhab.binding.nuvo.internal.communication.NuvoCommand;
import org.openhab.binding.nuvo.internal.communication.NuvoConnector;
-import org.openhab.binding.nuvo.internal.communication.NuvoDefaultConnector;
import org.openhab.binding.nuvo.internal.communication.NuvoEnum;
import org.openhab.binding.nuvo.internal.communication.NuvoImageResizer;
import org.openhab.binding.nuvo.internal.communication.NuvoIpConnector;
private @Nullable ScheduledFuture<?> clockSyncJob;
private @Nullable ScheduledFuture<?> pingJob;
- private NuvoConnector connector = new NuvoDefaultConnector();
+ private NuvoConnector connector = new NuvoIpConnector();
private long lastEventReceived = System.currentTimeMillis();
private int numZones = 1;
private String versionString = BLANK;
nuvoNetSrcMap.put(NuvoEnum.SOURCE5, config.nuvoNetSrc5);
nuvoNetSrcMap.put(NuvoEnum.SOURCE6, config.nuvoNetSrc6);
- nuvoGroupMap.put("1", new HashSet<>());
- nuvoGroupMap.put("2", new HashSet<>());
- nuvoGroupMap.put("3", new HashSet<>());
- nuvoGroupMap.put("4", new HashSet<>());
+ IntStream.range(1, 5).forEach(i -> nuvoGroupMap.put(String.valueOf(i), new HashSet<>()));
if (this.isMps4) {
logger.debug("Port set to {} configuring binding for MPS4 compatability", MPS4_PORT);
this.numZones = numZones;
}
- activeZones = IntStream.range((1), (this.numZones + 1)).boxed().collect(Collectors.toSet());
+ activeZones = IntStream.range(1, this.numZones + 1).boxed().collect(Collectors.toSet());
// remove the channels for the zones we are not using
if (this.numZones < MAX_ZONES) {
List<Channel> channels = new ArrayList<>(this.getThing().getChannels());
- List<Integer> zonesToRemove = IntStream.range((this.numZones + 1), (MAX_ZONES + 1)).boxed()
+ List<Integer> zonesToRemove = IntStream.range(this.numZones + 1, MAX_ZONES + 1).boxed()
.collect(Collectors.toList());
zonesToRemove.forEach(zone -> channels.removeIf(c -> (c.getUID().getId().contains("zone" + zone))));
// Build a list of State options for the global favorites using user config values (if supplied)
String[] favoritesArr = !config.favoriteLabels.isEmpty() ? config.favoriteLabels.split(COMMA) : new String[0];
List<StateOption> favoriteLabelsStateOptions = new ArrayList<>();
- for (int i = 0; i < MAX_FAV; i++) {
- if (favoritesArr.length > i) {
- favoriteLabelsStateOptions.add(new StateOption(String.valueOf(i + 1), favoritesArr[i]));
+ IntStream.range(1, MAX_FAV + 1).forEach(i -> {
+ if (favoritesArr.length >= i) {
+ favoriteLabelsStateOptions.add(new StateOption(String.valueOf(i), favoritesArr[i - 1]));
} else if (favoritesArr.length == 0) {
- favoriteLabelsStateOptions.add(new StateOption(String.valueOf(i + 1), "Favorite " + (i + 1)));
+ favoriteLabelsStateOptions.add(new StateOption(String.valueOf(i), "Favorite " + (i)));
}
- }
+ });
// Also add any openHAB NuvoNet source favorites to the list
- for (int src = 1; src <= MAX_SRC; src++) {
+ IntStream.range(1, MAX_SRC + 1).forEach(src -> {
NuvoEnum source = NuvoEnum.valueOf(SOURCE + src);
String[] favorites = favoriteMap.get(source);
if (favorites != null) {
- for (int fav = 0; fav < favorites.length; fav++) {
+ IntStream.range(0, favorites.length).forEach(fav -> {
favoriteLabelsStateOptions.add(new StateOption(String.valueOf(src * 100 + fav),
favPrefixMap.get(source) + favorites[fav]));
- }
+ });
}
- }
+ });
// Put the global favorites labels on all active zones
activeZones.forEach(zoneNum -> {
logger.debug("Using MCS instance '{}' for source {}", instance, source);
final String json = getMcsJson(String.format(GET_MCS_STATUS, mps4Host, instance, clientId), clientId);
- if (json.contains("\"name\":\"PlayState\",\"value\":3}")) {
+ if (json.contains("\"name\":\"PlayState\",\"value\":1}")
+ || json.contains("\"name\":\"PlayState\",\"value\":3}")) {
Matcher matcher = ART_GUID_PATTERN.matcher(json);
if (matcher.find()) {
final String nowPlayingGuid = matcher.group(1);