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 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
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 @@ -12,8 +12,7 @@
*/
package org.openhab.binding.amazonechocontrol.internal.smarthome;

import static org.openhab.binding.amazonechocontrol.internal.smarthome.Constants.ITEM_TYPE_NUMBER;
import static org.openhab.binding.amazonechocontrol.internal.smarthome.Constants.ITEM_TYPE_STRING;
import static org.openhab.binding.amazonechocontrol.internal.smarthome.Constants.*;

import java.io.IOException;
import java.util.List;
Expand All @@ -28,6 +27,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,13 +51,13 @@ 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_TEMPERATURE_IN_KELVIN = //
DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_TYPE_UID_COLOR_TEMPERATURE_ABS;

// Channel and Properties
private static final ChannelInfo COLOR_TEMPERATURE_IN_KELVIN = new ChannelInfo(
"colorTemperatureInKelvin" /* propertyName */ , "colorTemperatureInKelvin" /* ChannelId */,
CHANNEL_TYPE_COLOR_TEPERATURE_IN_KELVIN /* Channel Type */ , ITEM_TYPE_NUMBER /* Item Type */);
CHANNEL_TYPE_COLOR_TEMPERATURE_IN_KELVIN /* Channel Type */ , ITEM_TYPE_NUMBER_TEMPERATURE /* Item Type */);

private static final ChannelInfo COLOR_TEMPERATURE_NAME = new ChannelInfo("colorProperties" /* propertyName */ ,
"colorTemperatureName" /* ChannelId */, CHANNEL_TYPE_COLOR_TEMPERATURE_NAME /* Channel Type */ ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ channel-type.amazonechocontrol.color.label = Color
channel-type.amazonechocontrol.color.description = Color
channel-type.amazonechocontrol.colorName.label = Color Name
channel-type.amazonechocontrol.colorName.description = Color Name
channel-type.amazonechocontrol.colorTemperatureInKelvin.label = Color Temperature In Kelvin
channel-type.amazonechocontrol.colorTemperatureInKelvin.description = Color Temperature In Kelvin
channel-type.amazonechocontrol.colorTemperatureName.label = Color Temperature Name
channel-type.amazonechocontrol.colorTemperatureName.description = Color Temperature Name
channel-type.amazonechocontrol.equalizerBass.label = Bass
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 Expand Up @@ -573,11 +579,6 @@
<label>Color Temperature Name</label>
<description>Color Temperature Name</description>
</channel-type>
<channel-type id="colorTemperatureInKelvin">
<item-type>Number</item-type>
<label>Color Temperature In Kelvin</label>
<description>Color Temperature In Kelvin</description>
</channel-type>
<!-- Alexa.PercentageController -->
<channel-type id="percentage">
<item-type>Dimmer</item-type>
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>