[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 {
|
||||
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_10 = { 0x25, 0x01 }; // 17 - 32
|
||||
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));
|
||||
|
||||
// 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));
|
||||
|
||||
// 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
|
||||
|
|
|
@ -56,9 +56,6 @@ public class LogEventMessage {
|
|||
int eventType = Integer.parseInt(type);
|
||||
logger.trace("eventType received: {}", eventType);
|
||||
LogEventType logEventType = LogEventType.valueOfLogEventType(eventType);
|
||||
if (logEventType == null) {
|
||||
return "Unknown log event type received";
|
||||
}
|
||||
|
||||
// Date
|
||||
sb.append(String.format("%02d", Integer.parseInt(day))).append('-')
|
||||
|
@ -66,6 +63,9 @@ public class LogEventMessage {
|
|||
.append(String.format("%02d", Integer.parseInt(hour))).append(':')
|
||||
.append(String.format("%02d", Integer.parseInt(minute))).append(' ');
|
||||
|
||||
if (logEventType == null) {
|
||||
sb.append("Unknown log event type");
|
||||
} else {
|
||||
sb.append(logEventType.description);
|
||||
if (logEventType.isPartitionValid) {
|
||||
sb.append(" Partition ").append(Integer.parseInt(partition) + 1);
|
||||
|
@ -84,6 +84,7 @@ public class LogEventMessage {
|
|||
sb.append(" Device ").append(zud);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
} catch (NumberFormatException e) {
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||
|
||||
@Override
|
||||
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 data = null;
|
||||
|
@ -167,11 +167,13 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||
|
||||
// get the channel id from the map
|
||||
HashMap<String, String> logMap = panelLogMessagesMap;
|
||||
if (logMap != null) {
|
||||
String id = logMap.get(eventNumberString);
|
||||
if (logMap != null && id != null) {
|
||||
if (id != null) {
|
||||
ChannelUID channelUID = new ChannelUID(getThing().getUID(), id);
|
||||
updateChannel(channelUID, logEventMessage.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (communicatorStackPointer != null && eventNumberString.equals(communicatorStackPointer)) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
|
|
@ -52,7 +52,6 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||
@Override
|
||||
public void updateChannel(ChannelUID channelUID, String data) {
|
||||
if (channelUID.getId().equals(CaddxBindingConstants.ZONE_NAME)) {
|
||||
getThing().setLabel(data);
|
||||
updateState(channelUID, new StringType(data));
|
||||
|
||||
logger.trace(" updateChannel: {} = {}", channelUID, data);
|
||||
|
@ -71,7 +70,7 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||
|
||||
@Override
|
||||
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 cmd2 = null;
|
||||
|
@ -124,10 +123,10 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||
logger.trace(" updateChannel: {} = {}", channelUID, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
|
|
Loading…
Reference in New Issue