Skip to content

Commit cde9a8d

Browse files
committed
Fixed bug relating to button events handling
Fixed bug relating to write_ack command receiving
1 parent 453a38f commit cde9a8d

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/main/java/org/openhab/binding/xiaomigateway/internal/XiaomiGatewayBinding.java

+21-8
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,18 @@ private void receiveData(MulticastSocket socket, DatagramPacket dgram) {
194194
continue;
195195
}
196196

197-
//report and non gateway heartbeat
198-
processOtherCommands(jobject);
197+
if (command.equals("write_ack")) {
198+
continue;
199+
}
200+
201+
if (command.equals("report") || command.equals("heartbeat")) {
202+
//report and non gateway heartbeat
203+
processOtherCommands(jobject);
204+
continue;
205+
} else {
206+
logger.error("Unknown Xiaomi gateway command: " + command);
207+
}
208+
199209
}
200210
} catch (IOException e) {
201211
e.printStackTrace();
@@ -244,7 +254,7 @@ private void processOtherCommands(JsonObject jobject) {
244254
logger.debug("XiaomiGateway: processing motion event");
245255
processMotionEvent(itemName, jobject);
246256
}
247-
if( isCubeEvent(jobject)) {
257+
if (isCubeEvent(jobject)) {
248258
processCubeEvent(itemName, type, jobject);
249259
}
250260
}
@@ -255,13 +265,11 @@ private void processOtherCommands(JsonObject jobject) {
255265
private void processCubeEvent(String itemName, String type, JsonObject jobject) {
256266
String event = getStatusEvent(jobject);
257267
boolean publish = false;
258-
if( isRotateCubeEvent(jobject))
259-
{
268+
if (isRotateCubeEvent(jobject)) {
260269
event = "rotate";
261270
}
262271
logger.debug("XiaomiGateway: processing cube event " + event);
263-
switch (event)
264-
{
272+
switch (event) {
265273
case "flip90":
266274
publish = type.endsWith(".flip90");
267275
break;
@@ -293,7 +301,7 @@ private void processCubeEvent(String itemName, String type, JsonObject jobject)
293301
logger.error("Unknown cube event: " + event);
294302
}
295303

296-
if( publish )
304+
if (publish)
297305
eventPublisher.sendCommand(itemName, OnOffType.ON);
298306
}
299307

@@ -624,6 +632,11 @@ protected void internalReceiveCommand(String itemName, Command command) {
624632
logger.error("Only OnOff command types currently supported");
625633
return;
626634
}
635+
if( !itemName.contains("channel"))
636+
{
637+
//only channel items
638+
return;
639+
}
627640

628641
if (itemType.endsWith(".channel_0") || itemType.endsWith(".channel_1")) {
629642
//86ctrl_neutral1/2

0 commit comments

Comments
 (0)