mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[insteon] Fix x10 device message handling (#18031)
Signed-off-by: Jeremy Setton <jeremy.setton@gmail.com>
This commit is contained in:
parent
44ff26a29d
commit
0dce37ae1e
@ -564,16 +564,10 @@ public abstract class BaseDevice<@NonNull T extends DeviceAddress, @NonNull S ex
|
|||||||
public void requestReplied(Msg msg) {
|
public void requestReplied(Msg msg) {
|
||||||
DeviceFeature feature = getFeatureQueried();
|
DeviceFeature feature = getFeatureQueried();
|
||||||
if (feature != null && feature.isMyReply(msg)) {
|
if (feature != null && feature.isMyReply(msg)) {
|
||||||
if (msg.isReplyAck()) {
|
// mark feature queried as processed and answered
|
||||||
// mark feature queried as acked
|
setFeatureQueried(null);
|
||||||
feature.setQueryStatus(QueryStatus.QUERY_ACKED);
|
feature.setQueryMessage(null);
|
||||||
} else {
|
feature.setQueryStatus(QueryStatus.QUERY_ANSWERED);
|
||||||
logger.debug("got a reply nack msg: {}", msg);
|
|
||||||
// mark feature queried as processed and answered
|
|
||||||
setFeatureQueried(null);
|
|
||||||
feature.setQueryMessage(null);
|
|
||||||
feature.setQueryStatus(QueryStatus.QUERY_ANSWERED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,6 +906,25 @@ public class InsteonDevice extends BaseDevice<InsteonAddress, InsteonDeviceHandl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies that a message request was replied for this device
|
||||||
|
*
|
||||||
|
* @param msg the message received
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void requestReplied(Msg msg) {
|
||||||
|
DeviceFeature feature = getFeatureQueried();
|
||||||
|
if (feature != null && feature.isMyReply(msg)) {
|
||||||
|
if (msg.isReplyAck()) {
|
||||||
|
// mark feature queried as acked
|
||||||
|
feature.setQueryStatus(QueryStatus.QUERY_ACKED);
|
||||||
|
} else {
|
||||||
|
logger.debug("got a reply nack msg: {}", msg);
|
||||||
|
super.requestReplied(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies that the link db has been updated for this device
|
* Notifies that the link db has been updated for this device
|
||||||
*/
|
*/
|
||||||
|
@ -447,9 +447,6 @@ public class InsteonModem extends BaseDevice<InsteonAddress, InsteonBridgeHandle
|
|||||||
if (address == null) {
|
if (address == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.isX10()) {
|
|
||||||
lastX10Address = msg.isX10Address() ? (X10Address) address : null;
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
Device device = getAddress().equals(address) ? this : getDevice(address);
|
Device device = getAddress().equals(address) ? this : getDevice(address);
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
@ -482,13 +479,12 @@ public class InsteonModem extends BaseDevice<InsteonAddress, InsteonBridgeHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleX10Message(Msg msg) throws FieldException {
|
private void handleX10Message(Msg msg) throws FieldException {
|
||||||
X10Address address = lastX10Address;
|
X10Address address = msg.isX10Address() ? msg.getX10Address() : lastX10Address;
|
||||||
if (msg.isX10Address()) {
|
if (address != null) {
|
||||||
// store the x10 address to use with the next cmd
|
|
||||||
lastX10Address = msg.getX10Address();
|
|
||||||
} else if (address != null) {
|
|
||||||
handleMessage(address, msg);
|
handleMessage(address, msg);
|
||||||
lastX10Address = null;
|
// store the x10 address to use with the next cmd
|
||||||
|
lastX10Address = msg.isX10Address() ? address : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class X10Address implements DeviceAddress {
|
|||||||
private final byte unitCode;
|
private final byte unitCode;
|
||||||
|
|
||||||
public X10Address(byte address) {
|
public X10Address(byte address) {
|
||||||
this.houseCode = (byte) (address >> 4);
|
this.houseCode = (byte) (address >> 4 & 0x0F);
|
||||||
this.unitCode = (byte) (address & 0x0F);
|
this.unitCode = (byte) (address & 0x0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class X10Address implements DeviceAddress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public X10Address(String address) throws IllegalArgumentException {
|
public X10Address(String address) throws IllegalArgumentException {
|
||||||
String[] parts = address.replace(".", "").split("");
|
String[] parts = address.replace(".", "").split("", 2);
|
||||||
if (parts.length != 2) {
|
if (parts.length != 2) {
|
||||||
throw new IllegalArgumentException("Invalid X10 address format");
|
throw new IllegalArgumentException("Invalid X10 address format");
|
||||||
}
|
}
|
||||||
|
@ -242,11 +242,13 @@ public abstract class MessageDispatcher extends BaseFeatureHandler {
|
|||||||
@Override
|
@Override
|
||||||
public boolean dispatch(Msg msg) {
|
public boolean dispatch(Msg msg) {
|
||||||
try {
|
try {
|
||||||
byte cmd = msg.getByte("rawX10");
|
if (msg.isX10Command()) {
|
||||||
MessageHandler handler = feature.getOrDefaultMsgHandler(cmd);
|
byte cmd = (byte) (msg.getByte("rawX10") & 0x0F);
|
||||||
logger.debug("{}:{}->{} X10", getX10Device().getAddress(), feature.getName(),
|
MessageHandler handler = feature.getOrDefaultMsgHandler(cmd);
|
||||||
handler.getClass().getSimpleName());
|
logger.debug("{}:{}->{} X10", getX10Device().getAddress(), feature.getName(),
|
||||||
handler.handleMessage(cmd, msg);
|
handler.getClass().getSimpleName());
|
||||||
|
handler.handleMessage(cmd, msg);
|
||||||
|
}
|
||||||
} catch (FieldException e) {
|
} catch (FieldException e) {
|
||||||
logger.warn("error parsing, dropping msg {}", msg);
|
logger.warn("error parsing, dropping msg {}", msg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user