mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[homekit] Send a source with all commands to items (#19479)
Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
+7
-6
@@ -14,6 +14,7 @@ package org.openhab.io.homekit.internal;
|
||||
|
||||
import static org.openhab.io.homekit.internal.HomekitCommandType.*;
|
||||
import static org.openhab.io.homekit.internal.HomekitDimmerMode.*;
|
||||
import static org.openhab.io.homekit.internal.HomekitTaggedItem.HOMEKIT_SOURCE;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -110,9 +111,9 @@ public class HomekitOHItemProxy {
|
||||
&& ((brightness == null) || (brightness.intValue() == 100)))) {
|
||||
logger.trace("send OnOff command for item {} with value {}", item, on);
|
||||
if (item instanceof GroupItem groupItem) {
|
||||
groupItem.send(on);
|
||||
groupItem.send(on, HOMEKIT_SOURCE);
|
||||
} else {
|
||||
((DimmerItem) item).send(on);
|
||||
((DimmerItem) item).send(on, HOMEKIT_SOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,9 +135,9 @@ public class HomekitOHItemProxy {
|
||||
if (item instanceof ColorItem colorItem) {
|
||||
sendHSBCommand(colorItem, hue, saturation, brightness);
|
||||
} else if (item instanceof GroupItem groupItem) {
|
||||
groupItem.send(brightness);
|
||||
groupItem.send(brightness, HOMEKIT_SOURCE);
|
||||
} else {
|
||||
((DimmerItem) item).send(brightness);
|
||||
((DimmerItem) item).send(brightness, HOMEKIT_SOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,9 +153,9 @@ public class HomekitOHItemProxy {
|
||||
final PercentType targetBrightness = brightness != null ? brightness : currentState.getBrightness();
|
||||
final HSBType command = new HSBType(targetHue, targetSaturation, targetBrightness);
|
||||
if (item instanceof GroupItem groupItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
} else {
|
||||
((ColorItem) item).send(command);
|
||||
((ColorItem) item).send(command, HOMEKIT_SOURCE);
|
||||
}
|
||||
logger.trace("send HSB command for item {} with following values hue={} saturation={} brightness={}", item,
|
||||
targetHue, targetSaturation, targetBrightness);
|
||||
|
||||
+18
-15
@@ -66,6 +66,9 @@ public class HomekitTaggedItem {
|
||||
public static final String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
|
||||
public static final String SEND_UP_DOWN_FOR_EXTENTS = "sendUpDownForExtents";
|
||||
|
||||
// The "source" sent with command events so rules can identify them as coming from HomeKit
|
||||
public static final String HOMEKIT_SOURCE = "org.openhab.io.homekit";
|
||||
|
||||
private static final Map<Integer, String> CREATED_ACCESSORY_IDS = new ConcurrentHashMap<>();
|
||||
|
||||
// proxy item used to group commands for complex item types like Color or Dimmer
|
||||
@@ -181,10 +184,10 @@ public class HomekitTaggedItem {
|
||||
*/
|
||||
public void send(DecimalType command) {
|
||||
if (getItem() instanceof GroupItem groupItem && getBaseItem() instanceof NumberItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof NumberItem numberItem) {
|
||||
numberItem.send(command);
|
||||
numberItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn("Received DecimalType command for item {} that doesn't support it. This is probably a bug.",
|
||||
@@ -198,10 +201,10 @@ public class HomekitTaggedItem {
|
||||
*/
|
||||
public void send(QuantityType command) {
|
||||
if (getItem() instanceof GroupItem groupItem && getBaseItem() instanceof NumberItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof NumberItem numberItem) {
|
||||
numberItem.send(command);
|
||||
numberItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn("Received QuantityType command for item {} that doesn't support it. This is probably a bug.",
|
||||
@@ -215,10 +218,10 @@ public class HomekitTaggedItem {
|
||||
*/
|
||||
public void send(OnOffType command) {
|
||||
if (getItem() instanceof GroupItem groupItem && getBaseItem() instanceof SwitchItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof SwitchItem switchItem) {
|
||||
switchItem.send(command);
|
||||
switchItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn("Received OnOffType command for item {} that doesn't support it. This is probably a bug.",
|
||||
@@ -230,10 +233,10 @@ public class HomekitTaggedItem {
|
||||
*/
|
||||
public void send(IncreaseDecreaseType command) {
|
||||
if (getItem() instanceof GroupItem groupItem && getBaseItem() instanceof DimmerItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof DimmerItem dimmerItem) {
|
||||
dimmerItem.send(command);
|
||||
dimmerItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn(
|
||||
@@ -249,13 +252,13 @@ public class HomekitTaggedItem {
|
||||
public void send(PercentType command) {
|
||||
if (getItem() instanceof GroupItem groupItem
|
||||
&& (getBaseItem() instanceof DimmerItem || getBaseItem() instanceof RollershutterItem)) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof DimmerItem dimmerItem) {
|
||||
dimmerItem.send(command);
|
||||
dimmerItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof RollershutterItem rollerShutterItem) {
|
||||
rollerShutterItem.send(command);
|
||||
rollerShutterItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn("Received PercentType command for item {} that doesn't support it. This is probably a bug.",
|
||||
@@ -269,10 +272,10 @@ public class HomekitTaggedItem {
|
||||
*/
|
||||
public void send(StringType command) {
|
||||
if (getItem() instanceof GroupItem groupItem && getBaseItem() instanceof StringItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof StringItem stringItem) {
|
||||
stringItem.send(command);
|
||||
stringItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn("Received StringType command for item {} that doesn't support it. This is probably a bug.",
|
||||
@@ -284,10 +287,10 @@ public class HomekitTaggedItem {
|
||||
*/
|
||||
public void send(UpDownType command) {
|
||||
if (getItem() instanceof GroupItem groupItem && getBaseItem() instanceof RollershutterItem) {
|
||||
groupItem.send(command);
|
||||
groupItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
} else if (getItem() instanceof RollershutterItem rollershutterItem) {
|
||||
rollershutterItem.send(command);
|
||||
rollershutterItem.send(command, HOMEKIT_SOURCE);
|
||||
return;
|
||||
}
|
||||
logger.warn("Received UpDownType command for item {} that doesn't support it. This is probably a bug.",
|
||||
|
||||
Reference in New Issue
Block a user