diff --git a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java index a21504985a2..15e6bc03ce0 100644 --- a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java +++ b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java @@ -51,6 +51,7 @@ import org.openhab.binding.hue.internal.api.dto.clip2.ResourceReference; import org.openhab.binding.hue.internal.api.dto.clip2.Resources; import org.openhab.binding.hue.internal.api.dto.clip2.TimedEffects; import org.openhab.binding.hue.internal.api.dto.clip2.enums.ActionType; +import org.openhab.binding.hue.internal.api.dto.clip2.enums.Archetype; import org.openhab.binding.hue.internal.api.dto.clip2.enums.ContentType; import org.openhab.binding.hue.internal.api.dto.clip2.enums.EffectType; import org.openhab.binding.hue.internal.api.dto.clip2.enums.ResourceType; @@ -71,6 +72,8 @@ import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; import org.openhab.core.library.unit.MetricPrefix; import org.openhab.core.library.unit.Units; +import org.openhab.core.semantics.SemanticTag; +import org.openhab.core.semantics.model.DefaultSemanticTags.Equipment; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -109,6 +112,9 @@ public class Clip2ThingHandler extends BaseThingHandler { private static final Set SUPPORTED_SCENE_TYPES = Set.of(ResourceType.SCENE, ResourceType.SMART_SCENE); + private static final Set STRIPLIGHT_ARCHETYPES = Set.of(Archetype.HUE_LIGHTSTRIP, + Archetype.HUE_LIGHTSTRIP_TV, Archetype.HUE_TUBE, Archetype.STRING_LIGHT, Archetype.CHRISTMAS_TREE); + private static final Duration DYNAMICS_ACTIVE_WINDOW = Duration.ofSeconds(10); private static final String LK_WISER_DIMMER_MODEL_ID = "LK Dimmer"; @@ -1069,6 +1075,7 @@ public class Clip2ThingHandler extends BaseThingHandler { updateServiceContributors(); updateChannelList(); updateChannelItemLinksFromLegacy(); + updateEquipmentTag(); if (!hasConnectivityIssue) { updateStatus(ThingStatus.ONLINE); } @@ -1411,4 +1418,54 @@ public class Clip2ThingHandler extends BaseThingHandler { } } } + + /** + * Update the thing's semantic equipment tag. The main determinant for the equipment type is the supported channels. + * For lights use the product archetype to split between light bulbs and strip lights. Rooms and Zones are + * considered to be zones. + */ + private void updateEquipmentTag() { + if (!disposing) { + int sensorCount = 0; + SemanticTag equipmentTag = null; + + if (Set.of(ResourceType.ROOM, ResourceType.ZONE).contains(thisResource.getType())) { + equipmentTag = Equipment.ZONE; + } + if ((thing.getChannel(CHANNEL_2_COLOR) != null) || (thing.getChannel(CHANNEL_2_BRIGHTNESS) != null) + || (thing.getChannel(CHANNEL_2_SWITCH) != null)) { + equipmentTag = (thisResource.getProductData() instanceof ProductData productData) + && STRIPLIGHT_ARCHETYPES.contains(productData.getProductArchetype()) ? Equipment.LIGHT_STRIP + : Equipment.LIGHTBULB; + } + if (thing.getChannel(CHANNEL_2_BUTTON_LAST_EVENT) != null) { + equipmentTag = Equipment.BUTTON; + } + if (thing.getChannel(CHANNEL_2_ROTARY_STEPS) != null) { + equipmentTag = Equipment.DIAL; + } + if (thing.getChannel(CHANNEL_2_SECURITY_CONTACT) != null) { + equipmentTag = Equipment.CONTACT_SENSOR; + } + if (thing.getChannel(CHANNEL_2_MOTION) != null) { + sensorCount++; + equipmentTag = Equipment.MOTION_DETECTOR; + } + if (thing.getChannel(CHANNEL_2_LIGHT_LEVEL) != null) { + sensorCount++; + equipmentTag = Equipment.ILLUMINANCE_SENSOR; + } + if (thing.getChannel(CHANNEL_2_TEMPERATURE) != null) { + sensorCount++; + equipmentTag = Equipment.TEMPERATURE_SENSOR; + } + if (sensorCount > 1) { + equipmentTag = Equipment.SENSOR; + } + if (equipmentTag != null) { + logger.debug("{} -> updateEquipmentTag({})", resourceId, equipmentTag.getName()); + updateThing(editThing().withSemanticEquipmentTag(equipmentTag).build()); + } + } + } } diff --git a/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/bridge.xml b/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/bridge.xml index f763a8d23cd..fae9f8ba089 100644 --- a/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/bridge.xml +++ b/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/bridge.xml @@ -66,6 +66,7 @@ The Hue Bridge represents a Philips Hue Bridge supporting API v2. + NetworkAppliance diff --git a/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/channels.xml index 5193bb495d2..31c4e5a0637 100644 --- a/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.hue/src/main/resources/OH-INF/thing/channels.xml @@ -8,6 +8,10 @@ The date and time when the sensor was last updated. Time + + Status + Timestamp + @@ -17,7 +21,7 @@ Current illuminance. Measurement - Light + Illuminance @@ -26,6 +30,10 @@ Number Current light level. + + Measurement + Illuminance + @@ -142,7 +150,8 @@ The alert channel allows a temporary change to the bulb’s state. - Alarm + Switch + Mode @@ -159,6 +168,10 @@ The effect channel allows putting the bulb in a color looping mode. ColorLight + + Switch + Mode + @@ -179,6 +192,10 @@ String The scene channel allows recalling a scene to all lights that belong to the scene. + + Control + Mode + @@ -200,12 +217,20 @@ Switch Lock + + Switch + Mode + String MediaControl + + Control + Mode + veto @@ -215,12 +240,20 @@ The date and time when the thing was last updated. Time + + Status + Timestamp + String + + Control + Mode + veto @@ -228,6 +261,10 @@ String + + Control + Mode + veto @@ -237,6 +274,10 @@ The duration (ms) of dynamic transitions between light or scene states. Time + + Control + Duration + @@ -247,7 +288,7 @@ ColorLight Control - Light + Color veto @@ -259,7 +300,7 @@ Light Control - Light + Brightness veto @@ -281,18 +322,30 @@ Contact Lock + + Alarm + OpenState + Contact Siren + + Alarm + Tampered + Switch Switch + + Switch + Enabled +