[nuvo] Fix MPS4 flag and online status reporting (#13345)

* Fix mps4 flag and online status reporting
* Update missing statuses

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein 2022-09-03 10:44:39 -05:00 committed by GitHub
parent 32c76898c1
commit 5a11f1420e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 18 deletions

View File

@ -43,9 +43,9 @@ public class NuvoStatusCodes {
PLAY_MODE.put("6", "Play Shuffle"); PLAY_MODE.put("6", "Play Shuffle");
PLAY_MODE.put("7", "Play Repeat"); PLAY_MODE.put("7", "Play Repeat");
PLAY_MODE.put("8", "Play Shuffle Repeat"); PLAY_MODE.put("8", "Play Shuffle Repeat");
PLAY_MODE.put("9", "unknown-9"); PLAY_MODE.put("9", "Step Tune");
PLAY_MODE.put("10", "unknown-10"); PLAY_MODE.put("10", "Seek Tune");
PLAY_MODE.put("11", "Radio"); // undocumented PLAY_MODE.put("11", "Preset Tune");
PLAY_MODE.put("12", "unknown-12"); PLAY_MODE.put("12", "unknown-12");
} }

View File

@ -182,21 +182,20 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
return; return;
} }
if (serialPort != null) { if (serialPort != null && !serialPort.isEmpty()) {
connector = new NuvoSerialConnector(serialPortManager, serialPort, uid); connector = new NuvoSerialConnector(serialPortManager, serialPort, uid);
} else if (port != null) { } else if (port != null) {
connector = new NuvoIpConnector(host, port, uid); connector = new NuvoIpConnector(host, port, uid);
this.isMps4 = (port.intValue() == MPS4_PORT);
if (this.isMps4) {
logger.debug("Port set to {} configuring binding for MPS4 compatability", MPS4_PORT);
}
} else { } else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Either Serial port or Host & Port must be specifed"); "Either Serial port or Host & Port must be specifed");
return; return;
} }
this.isMps4 = (port != null && port.intValue() == MPS4_PORT);
if (this.isMps4) {
logger.debug("Port set to {} configuring binding for MPS4 compatability", MPS4_PORT);
}
if (numZones != null) { if (numZones != null) {
this.numZones = numZones; this.numZones = numZones;
} }
@ -462,7 +461,7 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
String type = evt.getType(); String type = evt.getType();
String key = evt.getKey(); String key = evt.getKey();
String updateData = evt.getValue().trim(); String updateData = evt.getValue().trim();
if (this.getThing().getStatus() == ThingStatus.OFFLINE) { if (this.getThing().getStatus() != ThingStatus.ONLINE) {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString); updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString);
} }
@ -598,7 +597,6 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
if (!connector.isConnected()) { if (!connector.isConnected()) {
logger.debug("Trying to reconnect..."); logger.debug("Trying to reconnect...");
closeConnection(); closeConnection();
String error = null;
if (openConnection()) { if (openConnection()) {
logger.debug("Reconnected"); logger.debug("Reconnected");
// Polling status will disconnect from MPS4 on reconnect // Polling status will disconnect from MPS4 on reconnect
@ -606,13 +604,8 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
pollStatus(); pollStatus();
} }
} else { } else {
error = "Reconnection failed"; updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Reconnection failed");
}
if (error != null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error);
closeConnection(); closeConnection();
} else {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString);
} }
} }
}, 1, RECON_POLLING_INTERVAL_SEC, TimeUnit.SECONDS); }, 1, RECON_POLLING_INTERVAL_SEC, TimeUnit.SECONDS);
@ -630,7 +623,7 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis
scheduleReconnectJob(); scheduleReconnectJob();
}, PING_TIMEOUT_SEC, TimeUnit.SECONDS); }, PING_TIMEOUT_SEC, TimeUnit.SECONDS);
} else { } else {
logger.debug("Ping Timeout job on valid for MPS4 connections"); logger.debug("Ping Timeout job not valid for serial connections");
} }
} }