Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
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;
Expand All @@ -71,6 +72,8 @@
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;
Expand Down Expand Up @@ -109,6 +112,9 @@ public class Clip2ThingHandler extends BaseThingHandler {

private static final Set<ResourceType> SUPPORTED_SCENE_TYPES = Set.of(ResourceType.SCENE, ResourceType.SMART_SCENE);

private static final Set<Archetype> 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";
Expand Down Expand Up @@ -1069,6 +1075,7 @@ private synchronized void updateDependencies() {
updateServiceContributors();
updateChannelList();
updateChannelItemLinksFromLegacy();
updateEquipmentTag();
if (!hasConnectivityIssue) {
updateStatus(ThingStatus.ONLINE);
}
Expand Down Expand Up @@ -1411,4 +1418,54 @@ private void updateThingFromLegacy() {
}
}
}

/**
* 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());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<bridge-type id="bridge-api2">
<label>Hue API v2 Bridge</label>
<description>The Hue Bridge represents a Philips Hue Bridge supporting API v2.</description>
<semantic-equipment-tag>NetworkAppliance</semantic-equipment-tag>

<channel-groups>
<channel-group id="automation" typeId="automation"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<label>Last Updated</label>
<description>The date and time when the sensor was last updated.</description>
<category>Time</category>
<tags>
<tag>Status</tag>
<tag>Timestamp</tag>
</tags>
<state readOnly="true" pattern="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"/>
</channel-type>

Expand All @@ -17,7 +21,7 @@
<description>Current illuminance.</description>
<tags>
<tag>Measurement</tag>
<tag>Light</tag>
<tag>Illuminance</tag>
</tags>
<state readOnly="true" pattern="%.1f %unit%"/>
</channel-type>
Expand All @@ -26,6 +30,10 @@
<item-type>Number</item-type>
<label>Light Level</label>
<description>Current light level.</description>
<tags>
<tag>Measurement</tag>
<tag>Illuminance</tag>
</tags>
<state readOnly="true" pattern="%d"/>
</channel-type>

Expand Down Expand Up @@ -142,7 +150,8 @@
<label>Alert</label>
<description>The alert channel allows a temporary change to the bulb’s state.</description>
<tags>
<tag>Alarm</tag>
<tag>Switch</tag>
<tag>Mode</tag>
</tags>
<state>
<options>
Expand All @@ -159,6 +168,10 @@
<label>Color Loop</label>
<description>The effect channel allows putting the bulb in a color looping mode.</description>
<category>ColorLight</category>
<tags>
<tag>Switch</tag>
<tag>Mode</tag>
</tags>
</channel-type>

<!-- CLIP Sensor -->
Expand All @@ -179,6 +192,10 @@
<item-type>String</item-type>
<label>Scene</label>
<description>The scene channel allows recalling a scene to all lights that belong to the scene.</description>
<tags>
<tag>Control</tag>
<tag>Mode</tag>
</tags>
</channel-type>

<!-- API v2 Channel Types -->
Expand All @@ -200,12 +217,20 @@
<item-type>Switch</item-type>
<label>Sensor Enabled</label>
<category>Lock</category>
<tags>
<tag>Switch</tag>
<tag>Mode</tag>
</tags>
</channel-type>

<channel-type id="scene-v2" advanced="true">
<item-type>String</item-type>
<label>Scene</label>
<category>MediaControl</category>
<tags>
<tag>Control</tag>
<tag>Mode</tag>
</tags>
<state pattern="%s"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
</channel-type>
Expand All @@ -215,19 +240,31 @@
<label>Last Updated</label>
<description>The date and time when the thing was last updated.</description>
<category>Time</category>
<tags>
<tag>Status</tag>
<tag>Timestamp</tag>
</tags>
<state readOnly="true" pattern="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"/>
</channel-type>

<channel-type id="alert-v2" advanced="true">
<item-type>String</item-type>
<label>Alert</label>
<tags>
<tag>Control</tag>
<tag>Mode</tag>
</tags>
<state pattern="%s"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
</channel-type>

<channel-type id="effect-v2" advanced="true">
<item-type>String</item-type>
<label>Effect</label>
<tags>
<tag>Control</tag>
<tag>Mode</tag>
</tags>
<state pattern="%s"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
</channel-type>
Expand All @@ -237,6 +274,10 @@
<label>Dynamics</label>
<description>The duration (ms) of dynamic transitions between light or scene states.</description>
<category>Time</category>
<tags>
<tag>Control</tag>
<tag>Duration</tag>
</tags>
<state min="0" step="100" pattern="%d ms"/>
</channel-type>

Expand All @@ -247,7 +288,7 @@
<category>ColorLight</category>
<tags>
<tag>Control</tag>
<tag>Light</tag>
<tag>Color</tag>
</tags>
<autoUpdatePolicy>veto</autoUpdatePolicy>
</channel-type>
Expand All @@ -259,7 +300,7 @@
<category>Light</category>
<tags>
<tag>Control</tag>
<tag>Light</tag>
<tag>Brightness</tag>
</tags>
<state min="0" max="100" pattern="%.1f %%"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
Expand All @@ -281,18 +322,30 @@
<item-type>Contact</item-type>
<label>Open/Closed</label>
<category>Lock</category>
<tags>
<tag>Alarm</tag>
<tag>OpenState</tag>
</tags>
</channel-type>

<channel-type id="security-tamper">
<item-type>Contact</item-type>
<label>Normal/Tamper</label>
<category>Siren</category>
<tags>
<tag>Alarm</tag>
<tag>Tampered</tag>
</tags>
</channel-type>

<channel-type id="automation-enable">
<item-type>Switch</item-type>
<label>Enable</label>
<category>Switch</category>
<tags>
<tag>Switch</tag>
<tag>Enabled</tag>
</tags>
</channel-type>

<channel-group-type id="automation">
Expand Down