[caddx] Correct thing status on bridge initialization (#10317)
* Log event message construction improved Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com> * Changed level to debug for some logs Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com> * Added status request commands to b send when the bridge initializes Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com> * Don't change the label of the zone Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com> * Removed comment Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com>pull/10344/head
parent
85a66994b4
commit
279e87851c
|
@ -65,7 +65,6 @@ import org.slf4j.LoggerFactory;
|
||||||
public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelListener {
|
public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelListener {
|
||||||
private final Logger logger = LoggerFactory.getLogger(CaddxBridgeHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(CaddxBridgeHandler.class);
|
||||||
|
|
||||||
static final byte[] DISCOVERY_PARTITION_STATUS_REQUEST_0 = { 0x26, 0x00 };
|
|
||||||
static final byte[] DISCOVERY_ZONES_SNAPSHOT_REQUEST_00 = { 0x25, 0x00 }; // 1 - 16
|
static final byte[] DISCOVERY_ZONES_SNAPSHOT_REQUEST_00 = { 0x25, 0x00 }; // 1 - 16
|
||||||
static final byte[] DISCOVERY_ZONES_SNAPSHOT_REQUEST_10 = { 0x25, 0x01 }; // 17 - 32
|
static final byte[] DISCOVERY_ZONES_SNAPSHOT_REQUEST_10 = { 0x25, 0x01 }; // 17 - 32
|
||||||
static final byte[] DISCOVERY_ZONES_SNAPSHOT_REQUEST_20 = { 0x25, 0x02 }; // 33 - 48
|
static final byte[] DISCOVERY_ZONES_SNAPSHOT_REQUEST_20 = { 0x25, 0x02 }; // 33 - 48
|
||||||
|
@ -156,8 +155,13 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_B0, false));
|
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_B0, false));
|
||||||
|
|
||||||
// Send discovery commands for the partitions
|
// Send discovery commands for the partitions
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_PARTITION_STATUS_REQUEST_0, false));
|
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_PARTITIONS_SNAPSHOT_REQUEST, false));
|
comm.transmit(new CaddxMessage(DISCOVERY_PARTITIONS_SNAPSHOT_REQUEST, false));
|
||||||
|
|
||||||
|
// Send status commands to the zones and partitions
|
||||||
|
thingZonesMap.forEach((k, v) -> sendCommand(CaddxBindingConstants.ZONE_STATUS_REQUEST,
|
||||||
|
k.subtract(BigDecimal.ONE).toString()));
|
||||||
|
thingPartitionsMap.forEach((k, v) -> sendCommand(CaddxBindingConstants.PARTITION_STATUS_REQUEST,
|
||||||
|
k.subtract(BigDecimal.ONE).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// list all channels
|
// list all channels
|
||||||
|
|
|
@ -56,9 +56,6 @@ public class LogEventMessage {
|
||||||
int eventType = Integer.parseInt(type);
|
int eventType = Integer.parseInt(type);
|
||||||
logger.trace("eventType received: {}", eventType);
|
logger.trace("eventType received: {}", eventType);
|
||||||
LogEventType logEventType = LogEventType.valueOfLogEventType(eventType);
|
LogEventType logEventType = LogEventType.valueOfLogEventType(eventType);
|
||||||
if (logEventType == null) {
|
|
||||||
return "Unknown log event type received";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
sb.append(String.format("%02d", Integer.parseInt(day))).append('-')
|
sb.append(String.format("%02d", Integer.parseInt(day))).append('-')
|
||||||
|
@ -66,23 +63,27 @@ public class LogEventMessage {
|
||||||
.append(String.format("%02d", Integer.parseInt(hour))).append(':')
|
.append(String.format("%02d", Integer.parseInt(hour))).append(':')
|
||||||
.append(String.format("%02d", Integer.parseInt(minute))).append(' ');
|
.append(String.format("%02d", Integer.parseInt(minute))).append(' ');
|
||||||
|
|
||||||
sb.append(logEventType.description);
|
if (logEventType == null) {
|
||||||
if (logEventType.isPartitionValid) {
|
sb.append("Unknown log event type");
|
||||||
sb.append(" Partition ").append(Integer.parseInt(partition) + 1);
|
} else {
|
||||||
}
|
sb.append(logEventType.description);
|
||||||
|
if (logEventType.isPartitionValid) {
|
||||||
|
sb.append(" Partition ").append(Integer.parseInt(partition) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
switch (logEventType.zud) {
|
switch (logEventType.zud) {
|
||||||
case None:
|
case None:
|
||||||
break;
|
break;
|
||||||
case Zone:
|
case Zone:
|
||||||
sb.append(" Zone ").append(Integer.parseInt(zud) + 1);
|
sb.append(" Zone ").append(Integer.parseInt(zud) + 1);
|
||||||
break;
|
break;
|
||||||
case User:
|
case User:
|
||||||
sb.append(" User ").append(Integer.parseInt(zud) + 1);
|
sb.append(" User ").append(Integer.parseInt(zud) + 1);
|
||||||
break;
|
break;
|
||||||
case Device:
|
case Device:
|
||||||
sb.append(" Device ").append(zud);
|
sb.append(" Device ").append(zud);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
logger.trace("handleCommand(): Command Received - {} {}.", channelUID, command);
|
logger.debug("handleCommand(): Command Received - {} {}.", channelUID, command);
|
||||||
|
|
||||||
String cmd = null;
|
String cmd = null;
|
||||||
String data = null;
|
String data = null;
|
||||||
|
@ -167,10 +167,12 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
||||||
|
|
||||||
// get the channel id from the map
|
// get the channel id from the map
|
||||||
HashMap<String, String> logMap = panelLogMessagesMap;
|
HashMap<String, String> logMap = panelLogMessagesMap;
|
||||||
String id = logMap.get(eventNumberString);
|
if (logMap != null) {
|
||||||
if (logMap != null && id != null) {
|
String id = logMap.get(eventNumberString);
|
||||||
ChannelUID channelUID = new ChannelUID(getThing().getUID(), id);
|
if (id != null) {
|
||||||
updateChannel(channelUID, logEventMessage.toString());
|
ChannelUID channelUID = new ChannelUID(getThing().getUID(), id);
|
||||||
|
updateChannel(channelUID, logEventMessage.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (communicatorStackPointer != null && eventNumberString.equals(communicatorStackPointer)) {
|
if (communicatorStackPointer != null && eventNumberString.equals(communicatorStackPointer)) {
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
||||||
@Override
|
@Override
|
||||||
public void updateChannel(ChannelUID channelUID, String data) {
|
public void updateChannel(ChannelUID channelUID, String data) {
|
||||||
if (channelUID.getId().equals(CaddxBindingConstants.ZONE_NAME)) {
|
if (channelUID.getId().equals(CaddxBindingConstants.ZONE_NAME)) {
|
||||||
getThing().setLabel(data);
|
|
||||||
updateState(channelUID, new StringType(data));
|
updateState(channelUID, new StringType(data));
|
||||||
|
|
||||||
logger.trace(" updateChannel: {} = {}", channelUID, data);
|
logger.trace(" updateChannel: {} = {}", channelUID, data);
|
||||||
|
@ -71,7 +70,7 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
logger.trace("handleCommand(): Command Received - {} {}.", channelUID, command);
|
logger.debug("handleCommand(): Command Received - {} {}.", channelUID, command);
|
||||||
|
|
||||||
String cmd1 = null;
|
String cmd1 = null;
|
||||||
String cmd2 = null;
|
String cmd2 = null;
|
||||||
|
@ -124,9 +123,9 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
||||||
logger.trace(" updateChannel: {} = {}", channelUID, value);
|
logger.trace(" updateChannel: {} = {}", channelUID, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus(ThingStatus.ONLINE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue