Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[amazonechocontrol] Improve color temperature channel #17754

Merged
merged 20 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
3 changes: 2 additions & 1 deletion bundles/org.openhab.binding.amazonechocontrol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,9 @@ The channels of the smarthome devices will be generated at runtime. Check in the
|--------------------------|----------------------|-------------|-------------------------------|------------------------------------------------------------------------------------------
| powerState | Switch | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the state (ON/OFF) of your device
| brightness | Dimmer | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the brightness of your lamp
| color | Color | R | smartHomeDevice, smartHomeDeviceGroup | Shows the color of your light
| color | Color | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows the color of your light
| colorName | String | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the color name of your light (groups are not able to show their color)
| colorTemperatureInKelvin | Number:Temperature | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows the color temperature of your light
| colorTemperatureName | String | R/W | smartHomeDevice, smartHomeDeviceGroup | White temperatures name of your lights (groups are not able to show their color)
| armState | String | R/W | smartHomeDevice, smartHomeDeviceGroup | State of your alarm guard. Options: ARMED_AWAY, ARMED_STAY, ARMED_NIGHT, DISARMED (groups are not able to show their state)
| burglaryAlarm | Contact | R | smartHomeDevice | Burglary alarm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.thing.DefaultSystemChannelTypeProvider;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.Command;
import org.openhab.core.types.StateDescription;
Expand All @@ -51,8 +52,7 @@ public class HandlerColorTemperatureController extends HandlerBase {
private static final ChannelTypeUID CHANNEL_TYPE_COLOR_TEMPERATURE_NAME = new ChannelTypeUID(
AmazonEchoControlBindingConstants.BINDING_ID, "colorTemperatureName");

private static final ChannelTypeUID CHANNEL_TYPE_COLOR_TEPERATURE_IN_KELVIN = new ChannelTypeUID(
AmazonEchoControlBindingConstants.BINDING_ID, "colorTemperatureInKelvin");
private static final ChannelTypeUID CHANNEL_TYPE_COLOR_TEPERATURE_IN_KELVIN = DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_TYPE_UID_COLOR_TEMPERATURE_ABS;

// Channel and Properties
private static final ChannelInfo COLOR_TEMPERATURE_IN_KELVIN = new ChannelInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
</supported-bridge-type-refs>
<label>Smart Home Device</label>
<description>Smart home device connected to Alexa</description>
<properties>
<property name="thingTypeVersion">1</property>
</properties>
<representation-property>id</representation-property>
<config-description>
<parameter name="id" type="text" required="true">
Expand All @@ -269,6 +272,9 @@
</supported-bridge-type-refs>
<label>Smart Home Device Group</label>
<description>Group of smart home devices in your amazon account</description>
<properties>
<property name="thingTypeVersion">1</property>
</properties>
<representation-property>id</representation-property>
<config-description>
<parameter name="id" type="text" required="true">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">

<thing-type uid="amazonechocontrol:smartHomeDevice">
<instruction-set targetVersion="1">
<update-channel id="colorTemperatureInKelvin">
<type>system:color-temperature-abs</type>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both cases, you have to update also the item type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked documentation and 10+ instructions.xml files but i don't get it, could you elaborate on on your comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find an example but I am sure this case was already encountered and discussed.
I will have to search in the archives.
Maybe the solution was to remove the channel and to add it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll wait to merge before you have something. Maybe if you know who was envolved you can ping them to join?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlaur : do you remember?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@J-N-K do you also remember?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if this will work, and it might take two minutes (with a warning logged) when the channel type for an existing Thing is completely missing during startup (because it's deleted). It might be a variant of one of the issues mentioned here: openhab/openhab-core#3660

Copy link
Contributor

@lsiepel lsiepel Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this (see #17754 (comment) ) No need to add additional attributes to the upgrade instructions.

</update-channel>
</instruction-set>
</thing-type>

<thing-type uid="amazonechocontrol:smartHomeDeviceGroup">
<instruction-set targetVersion="1">
<update-channel id="colorTemperatureInKelvin">
<type>system:color-temperature-abs</type>
</update-channel>
</instruction-set>
</thing-type>

</update:update-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
</channel-type>

<channel-type id="color-temperature-abs" advanced="true">
<item-type>Number:Temperature</item-type>
<item-type unitHint="K">Number:Temperature</item-type>
<label>Color Temperature</label>
<description>Controls the color temperature of the light in Kelvin</description>
<category>ColorLight</category>
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.deconz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Other devices support
| brightness | Dimmer | R/W | Brightness of the light | `dimmablelight`, `colortemperaturelight` |
| switch | Switch | R/W | State of a ON/OFF device | `onofflight` |
| color | Color | R/W | Color of an multi-color light | `colorlight`, `extendedcolorlight`, `lightgroup` |
| color_temperature | Number | R/W | Color temperature in Kelvin. The value range is determined by each individual light | `colortemperaturelight`, `extendedcolorlight`, `lightgroup` |
| color_temperature | Number:Temperature | R/W | Color temperature in Kelvin. The value range is determined by each individual light | `colortemperaturelight`, `extendedcolorlight`, `lightgroup` |
| effect | String | R/W | Effect selection. Allowed commands are set dynamically | `colorlight` |
| effectSpeed | Number | W | Effect Speed | `colorlight` |
| lock | Switch | R/W | Lock (ON) or unlock (OFF) the doorlock | `doorlock` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public void initialize() {

// minimum and maximum are inverted due to mired/kelvin conversion!
StateDescriptionFragment stateDescriptionFragment = StateDescriptionFragmentBuilder.create()
.withStep(BigDecimal.valueOf(100)).withPattern("%.0f K")
.withMinimum(new BigDecimal(miredToKelvin(ctMax)))
.withMaximum(new BigDecimal(miredToKelvin(ctMin))).build();
stateDescriptionProvider.setDescriptionFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ channel-type.deconz.carbonmonoxide.label = Carbon-monoxide
channel-type.deconz.carbonmonoxide.description = Carbon-monoxide was detected.
channel-type.deconz.consumption.label = Consumption
channel-type.deconz.consumption.description = Current consumption
channel-type.deconz.ct.label = Color Temperature
channel-type.deconz.ct.description = Controls the color temperature of the light in Kelvin
channel-type.deconz.current.label = Current
channel-type.deconz.current.description = Current current
channel-type.deconz.dark.label = Dark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@
<category>Lightbulb</category>
<channels>
<channel typeId="system.brightness" id="brightness"/>
<channel typeId="ct" id="color_temperature"/>
<channel typeId="system.color-temperature-abs" id="color_temperature"/>
<channel typeId="ontime" id="ontime"/>
<channel typeId="alert" id="alert"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
<property name="thingTypeVersion">2</property>
</properties>

<representation-property>uid</representation-property>
Expand Down Expand Up @@ -132,13 +132,13 @@
<category>Lightbulb</category>
<channels>
<channel typeId="system.color" id="color"/>
<channel typeId="ct" id="color_temperature"/>
<channel typeId="system.color-temperature-abs" id="color_temperature"/>
<channel typeId="ontime" id="ontime"/>
<channel typeId="alert" id="alert"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
<property name="thingTypeVersion">2</property>
</properties>

<representation-property>uid</representation-property>
Expand Down Expand Up @@ -169,14 +169,6 @@
<state pattern="%.1f %%"/>
</channel-type>

<channel-type id="ct">
<item-type>Number</item-type>
<label>Color Temperature</label>
<description>Controls the color temperature of the light in Kelvin</description>
<category>ColorLight</category>
<state pattern="%.0f K" min="1000" max="10000"/>
</channel-type>

<channel-type id="ontime">
<item-type>Number:Time</item-type>
<label>On Time</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<type>system:brightness</type>
</update-channel>
</instruction-set>
<instruction-set targetVersion="2">
<update-channel id="color_temperature">
<type>system:color-temperature-abs</type>
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
</update-channel>
</instruction-set>
</thing-type>

<thing-type uid="deconz:dimmablelight">
Expand All @@ -49,6 +54,11 @@
<type>system:color</type>
</update-channel>
</instruction-set>
<instruction-set targetVersion="2">
<update-channel id="color_temperature">
<type>system:color-temperature-abs</type>
</update-channel>
</instruction-set>
</thing-type>

<thing-type uid="deconz:lightgroup">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


<channel-type id="color-temperature-abs" advanced="true">
<item-type>Number:Temperature</item-type>
<item-type unitHint="K">Number:Temperature</item-type>
<label>Color Temperature</label>
<description>Controls the color temperature of the light in Kelvin</description>
<category>ColorLight</category>
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.tapocontrol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ All devices support some of the following channels:
| | output2 | Switch | Power socket 2 on or off | P300 |
| | output3 | Switch | Power socket 3 on or off | P300 |
| | brightness | Dimmer | Brightness 0-100% | L510, L530, L610, L630, L900, L920 |
| | colorTemperature | Number | White-Color-Temp 2500-6500K | L510, L530, L610, L630, L900, L920 |
| | colorTemperature | Number:Temperature | White-Color-Temp 2500-6500K | L530, L630 |
| | color | Color | Color | L530, L630, L900, L920 |
| sensor | isOpen | Switch | Contact (Door/Window) is Open | T110 |
| | currentTemp | Number:Temperature | Current Temperature | T310, T315 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<channel-group id="effects" typeId="lightEffectL530"/>
<channel-group id="device" typeId="deviceState"/>
</channel-groups>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>macAddress</representation-property>

<config-description-ref uri="thing-type:tapo:device"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<channel-group id="actuator" typeId="colorBulb"/>
<channel-group id="device" typeId="deviceStateS"/>
</channel-groups>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>macAddress</representation-property>

<config-description-ref uri="thing-type:tapo:device"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@

<!-- Color Temperature -->
<channel-type id="colorTemperature">
<item-type>Number</item-type>
<item-type unitHint="K">Number:Temperature</item-type>
<label>Color Temperature</label>
<description>This channel supports adjusting the color temperature from 2200K to 6500K.</description>
<category>LightBulb</category>
<state min="2200" max="6500" pattern="%d K"/>
<state step="100" min="2200" max="6500" pattern="%.0f K"/>
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
</channel-type>

<!-- SENSOR CHANNEL TYPES -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">

<thing-type uid="tapocontrol:L530">
<instruction-set targetVersion="1">
<update-channel id="colorTemperature">
<type>tapocontrol:colorTemperature</type>
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
</update-channel>
</instruction-set>
</thing-type>

<thing-type uid="tapocontrol:L630">
<instruction-set targetVersion="1">
<update-channel id="colorTemperature">
<type>tapocontrol:colorTemperature</type>
</update-channel>
</instruction-set>
</thing-type>

</update:update-descriptions>
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.tplinksmarthome/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ All devices support some of the following channels:
| switch | Switch | Power the device on or off. | EP10, EP25, EP40, HS100, HS103, HS105, HS107, HS110, HS200, HS210, HS300, KP100, KP105, KP115, KP200, KP303, KP400, KP401, KS230, RE270K, RE370K |
| brightness | Dimmer | Set the brightness of device or dimmer. | ES20M, HS220, KB100, KL50, KL60, KL110, KL120, KP405, LB100, LB110, LB120, LB200 |
| colorTemperature | Dimmer | Set the color temperature in percentage. | KB130, KL120, KL125, KL130, KL135, KL400, KL430, LB120, LB130, LB230 |
| colorTemperatureAbs | Number | Set the color temperature in Kelvin. | KB130, KL120, KL125, KL130, KL135, KL400, KL430, LB120, LB130, LB230 |
| colorTemperatureAbs | Number:Temperature | Set the color temperature in Kelvin. | KB130, KL120, KL125, KL130, KL135, KL400, KL430, LB120, LB130, LB230 |
| color | Color | Set the color of the light. | KB130, KL125, KL130, KL135, KL400, KL430, LB130, LB230 |
| power | Number:Power | Actual energy usage in Watt. | EP25, HS110, HS300, KLxxx, KP115, KP125, LBxxx, |
| eneryUsage | Number:Energy | Energy Usage in kWh. | EP25, HS110, HS300, KP115, KP125 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<channel id="rssi" typeId="rssi"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<representation-property>deviceId</representation-property>

<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
Expand Down
Loading