[yioremote] BugFix sendIRCode action (#9574)
* Corrected sendIRCode handler Signed-off-by: Michael Loercher <MichaelLoercher@web.de> * Update YIOremoteDockHandler.java Updating IR receiver switch handler so it's running now Solved issue during triggering channel while it was disposed Signed-off-by: Michael Loercher <MichaelLoercher@web.de> * Update YIOremoteDockHandler.java Signed-off-by: Michael Loercher <MichaelLoercher@web.de>
This commit is contained in:
parent
4e04bac010
commit
1b5df97af5
|
@ -44,7 +44,6 @@ import org.openhab.core.thing.binding.BaseThingHandler;
|
||||||
import org.openhab.core.thing.binding.ThingHandlerService;
|
import org.openhab.core.thing.binding.ThingHandlerService;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.UnDefType;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -117,8 +116,6 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
recievedJson = convertStringToJsonObject(receivedMessage);
|
recievedJson = convertStringToJsonObject(receivedMessage);
|
||||||
if (recievedJson.size() > 0) {
|
if (recievedJson.size() > 0) {
|
||||||
if (decodeReceivedMessage(recievedJson)) {
|
if (decodeReceivedMessage(recievedJson)) {
|
||||||
triggerChannel(getChannelUuid(GROUP_OUTPUT, STATUS_STRING_CHANNEL));
|
|
||||||
updateChannelString(GROUP_OUTPUT, STATUS_STRING_CHANNEL, receivedStatus);
|
|
||||||
switch (yioRemoteDockActualStatus) {
|
switch (yioRemoteDockActualStatus) {
|
||||||
case CONNECTION_ESTABLISHED:
|
case CONNECTION_ESTABLISHED:
|
||||||
case AUTHENTICATION_PROCESS:
|
case AUTHENTICATION_PROCESS:
|
||||||
|
@ -127,6 +124,12 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
case COMMUNICATION_ERROR:
|
case COMMUNICATION_ERROR:
|
||||||
reconnectWebsocket();
|
reconnectWebsocket();
|
||||||
break;
|
break;
|
||||||
|
case AUTHENTICATION_COMPLETE:
|
||||||
|
case CHECK_PONG:
|
||||||
|
case SEND_PING:
|
||||||
|
updateChannelString(GROUP_OUTPUT, STATUS_STRING_CHANNEL, receivedStatus);
|
||||||
|
triggerChannel(getChannelUuid(GROUP_OUTPUT, STATUS_STRING_CHANNEL));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -202,6 +205,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
} else {
|
} else {
|
||||||
irCodeReceivedHandler.setCode("");
|
irCodeReceivedHandler.setCode("");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("ir_receive message {}", irCodeReceivedHandler.getCode());
|
logger.debug("ir_receive message {}", irCodeReceivedHandler.getCode());
|
||||||
heartBeat = true;
|
heartBeat = true;
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -266,6 +270,8 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
if (RECEIVER_SWITCH_CHANNEL.equals(channelUID.getIdWithoutGroup())) {
|
if (RECEIVER_SWITCH_CHANNEL.equals(channelUID.getIdWithoutGroup())) {
|
||||||
switch (yioRemoteDockActualStatus) {
|
switch (yioRemoteDockActualStatus) {
|
||||||
case AUTHENTICATION_COMPLETE:
|
case AUTHENTICATION_COMPLETE:
|
||||||
|
case SEND_PING:
|
||||||
|
case CHECK_PONG:
|
||||||
if (command == OnOffType.ON) {
|
if (command == OnOffType.ON) {
|
||||||
logger.debug("YIODOCKRECEIVERSWITCH ON procedure: Switching IR Receiver on");
|
logger.debug("YIODOCKRECEIVERSWITCH ON procedure: Switching IR Receiver on");
|
||||||
sendMessage(YioRemoteMessages.IR_RECEIVER_ON, "");
|
sendMessage(YioRemoteMessages.IR_RECEIVER_ON, "");
|
||||||
|
@ -283,12 +289,20 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendIRCode(@Nullable String irCode) {
|
public void sendIRCode(@Nullable String irCode) {
|
||||||
if (irCode != null && yioRemoteDockActualStatus.equals(YioRemoteDockHandleStatus.AUTHENTICATION_COMPLETE)) {
|
if (irCode != null) {
|
||||||
|
if (yioRemoteDockActualStatus.equals(YioRemoteDockHandleStatus.AUTHENTICATION_COMPLETE)
|
||||||
|
|| yioRemoteDockActualStatus.equals(YioRemoteDockHandleStatus.SEND_PING)
|
||||||
|
|| yioRemoteDockActualStatus.equals(YioRemoteDockHandleStatus.CHECK_PONG)) {
|
||||||
if (irCode.matches("[0-9]?[0-9][;]0[xX][0-9a-fA-F]+[;][0-9]+[;][0-9]")) {
|
if (irCode.matches("[0-9]?[0-9][;]0[xX][0-9a-fA-F]+[;][0-9]+[;][0-9]")) {
|
||||||
sendMessage(YioRemoteMessages.IR_SEND, irCode);
|
sendMessage(YioRemoteMessages.IR_SEND, irCode);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Wrong ir code format {}", irCode);
|
logger.warn("Wrong ir code format {}", irCode);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.debug("Wrong Dock Statusfor sending {}", irCode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("No ir code {}", irCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,6 +326,8 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
if (authenticationOk) {
|
if (authenticationOk) {
|
||||||
yioRemoteDockActualStatus = YioRemoteDockHandleStatus.AUTHENTICATION_COMPLETE;
|
yioRemoteDockActualStatus = YioRemoteDockHandleStatus.AUTHENTICATION_COMPLETE;
|
||||||
updateStatus(ThingStatus.ONLINE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
|
updateState(STATUS_STRING_CHANNEL, StringType.EMPTY);
|
||||||
|
updateState(RECEIVER_SWITCH_CHANNEL, OnOffType.OFF);
|
||||||
webSocketPollingJob = scheduler.scheduleWithFixedDelay(this::pollingWebsocketJob, 0, 60,
|
webSocketPollingJob = scheduler.scheduleWithFixedDelay(this::pollingWebsocketJob, 0, 60,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
} else {
|
} else {
|
||||||
|
@ -323,7 +339,6 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
yioRemoteDockActualStatus = YioRemoteDockHandleStatus.COMMUNICATION_ERROR;
|
yioRemoteDockActualStatus = YioRemoteDockHandleStatus.COMMUNICATION_ERROR;
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
"Connection lost no ping from YIO DOCK");
|
"Connection lost no ping from YIO DOCK");
|
||||||
updateState(GROUP_OUTPUT, STATUS_STRING_CHANNEL, UnDefType.UNDEF);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,7 +382,6 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
yioRemoteDockActualStatus = YioRemoteDockHandleStatus.COMMUNICATION_ERROR;
|
yioRemoteDockActualStatus = YioRemoteDockHandleStatus.COMMUNICATION_ERROR;
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
"Connection lost no ping from YIO DOCK");
|
"Connection lost no ping from YIO DOCK");
|
||||||
updateState(GROUP_OUTPUT, STATUS_STRING_CHANNEL, UnDefType.UNDEF);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,7 +470,7 @@ public class YIOremoteDockHandler extends BaseThingHandler {
|
||||||
case IR_SEND:
|
case IR_SEND:
|
||||||
irCodeSendHandler.setCode(messagePayload);
|
irCodeSendHandler.setCode(messagePayload);
|
||||||
yioremoteDockwebSocketClient.sendMessage(irCodeSendMessageHandler.getIRcodeSendMessageString());
|
yioremoteDockwebSocketClient.sendMessage(irCodeSendMessageHandler.getIRcodeSendMessageString());
|
||||||
logger.debug("sending heartBeat message: {}", irCodeSendMessageHandler.getIRcodeSendMessageString());
|
logger.debug("sending IR code: {}", irCodeSendMessageHandler.getIRcodeSendMessageString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue