mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Added system default channel type to control color temperature in Kelvin (#2157)
* Added system default channel type for controling color temperature in Kelvin Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
+17
-7
@@ -173,13 +173,23 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
.withDescription("Controls the color of the light").withCategory("ColorLight").build();
|
||||
|
||||
/**
|
||||
* Color-temperature: default system wide {@link ChannelType} which allows changing the color temperature
|
||||
* Color-temperature: default system wide {@link ChannelType} which allows changing the color temperature in percent
|
||||
*/
|
||||
public static final ChannelType SYSTEM_COLOR_TEMPERATURE = ChannelTypeBuilder
|
||||
.state(new ChannelTypeUID(BINDING_ID, "color-temperature"), "Color Temperature", "Dimmer")
|
||||
.withDescription("Controls the color temperature of the light").withCategory("ColorLight")
|
||||
.withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withMinimum(BigDecimal.ZERO)
|
||||
.withMaximum(new BigDecimal(100)).withPattern("%d").build())
|
||||
.withDescription("Controls the color temperature of the light from 0 (cold) to 100 (warm)")
|
||||
.withCategory("ColorLight").withStateDescriptionFragment(StateDescriptionFragmentBuilder.create()
|
||||
.withMinimum(BigDecimal.ZERO).withMaximum(new BigDecimal(100)).withPattern("%.0f").build())
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Color-temperature: default system wide {@link ChannelType} which allows changing the color temperature in Kelvin
|
||||
*/
|
||||
public static final ChannelType SYSTEM_COLOR_TEMPERATURE_ABS = ChannelTypeBuilder
|
||||
.state(new ChannelTypeUID(BINDING_ID, "color-temperature-abs"), "Color Temperature", "Number")
|
||||
.withDescription("Controls the color temperature of the light in Kelvin").withCategory("ColorLight")
|
||||
.withStateDescriptionFragment(StateDescriptionFragmentBuilder.create().withMinimum(new BigDecimal(1000))
|
||||
.withMaximum(new BigDecimal(10000)).withPattern("%.0f K").build())
|
||||
.build();
|
||||
|
||||
// media channels
|
||||
@@ -280,9 +290,9 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
private static final Collection<ChannelType> CHANNEL_TYPES = List.of(SYSTEM_CHANNEL_SIGNAL_STRENGTH,
|
||||
SYSTEM_CHANNEL_LOW_BATTERY, SYSTEM_CHANNEL_BATTERY_LEVEL, SYSTEM_TRIGGER, SYSTEM_RAWBUTTON, SYSTEM_BUTTON,
|
||||
SYSTEM_RAWROCKER, SYSTEM_POWER, SYSTEM_LOCATION, SYSTEM_MOTION, SYSTEM_BRIGHTNESS, SYSTEM_COLOR,
|
||||
SYSTEM_COLOR_TEMPERATURE, SYSTEM_VOLUME, SYSTEM_MUTE, SYSTEM_MEDIA_CONTROL, SYSTEM_MEDIA_TITLE,
|
||||
SYSTEM_MEDIA_ARTIST, SYSTEM_WIND_DIRECTION, SYSTEM_WIND_SPEED, SYSTEM_OUTDOOR_TEMPERATURE,
|
||||
SYSTEM_ATMOSPHERIC_HUMIDITY, SYSTEM_BAROMETRIC_PRESSURE);
|
||||
SYSTEM_COLOR_TEMPERATURE, SYSTEM_COLOR_TEMPERATURE_ABS, SYSTEM_VOLUME, SYSTEM_MUTE, SYSTEM_MEDIA_CONTROL,
|
||||
SYSTEM_MEDIA_TITLE, SYSTEM_MEDIA_ARTIST, SYSTEM_WIND_DIRECTION, SYSTEM_WIND_SPEED,
|
||||
SYSTEM_OUTDOOR_TEMPERATURE, SYSTEM_ATMOSPHERIC_HUMIDITY, SYSTEM_BAROMETRIC_PRESSURE);
|
||||
|
||||
private final Map<LocalizedKey, ChannelType> localizedChannelTypeCache = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
+3
-1
@@ -21,7 +21,9 @@ channel-type.system.brightness.description = Steuert die Helligkeit und schaltet
|
||||
channel-type.system.color.label = Farbe
|
||||
channel-type.system.color.description = Steuert die Lichtfarbe.
|
||||
channel-type.system.color-temperature.label = Farbtemperatur
|
||||
channel-type.system.color-temperature.description = Steuert die Farbtemperatur des Lichts.
|
||||
channel-type.system.color-temperature.description = Steuert die Farbtemperatur des Lichts von 0 (kalt) bis 100 (warm).
|
||||
channel-type.system.color-temperature-abs.label = Farbtemperatur
|
||||
channel-type.system.color-temperature-abs.description = Steuert die Farbtemperatur des Lichts in Kelvin.
|
||||
channel-type.system.volume.label = Lautstärke
|
||||
channel-type.system.volume.description = Ermöglicht die Steuerung der Lautstärke.
|
||||
channel-type.system.mute.label = Stumm schalten
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@ channel-type.system.brightness.description = Contr
|
||||
channel-type.system.color.label = Couleur
|
||||
channel-type.system.color.description = Contrôle la couleur de la lumière.
|
||||
channel-type.system.color-temperature.label = Température de couleur
|
||||
channel-type.system.color-temperature.description = Contrôle la température de couleur de la lumière.
|
||||
channel-type.system.color-temperature.description = Contrôle la température de couleur de la lumière de 0 (froid) à 100 (chaud).
|
||||
channel-type.system.color-temperature-abs.label = Température de couleur
|
||||
channel-type.system.color-temperature-abs.description = Contrôle la température de couleur de la lumière en Kelvin.
|
||||
channel-type.system.volume.label = Volume
|
||||
channel-type.system.volume.description = Modifie le volume sonore de l'appareil.
|
||||
channel-type.system.mute.label = Muet
|
||||
|
||||
+16
-3
@@ -34,6 +34,8 @@ import org.openhab.core.types.StateOption;
|
||||
*/
|
||||
public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
|
||||
private static final int NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES = 24;
|
||||
|
||||
private static final ChannelTypeUID SIGNAL_STRENGTH_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID,
|
||||
"signal-strength");
|
||||
private static final ChannelTypeUID LOW_BATTERY_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID, "low-battery");
|
||||
@@ -50,6 +52,8 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
private static final ChannelTypeUID COLOR_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID, "color");
|
||||
private static final ChannelTypeUID COLOR_TEMPERATURE_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID,
|
||||
"color-temperature");
|
||||
private static final ChannelTypeUID COLOR_TEMPERATURE_ABS_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID,
|
||||
"color-temperature-abs");
|
||||
private static final ChannelTypeUID VOLUME_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID, "volume");
|
||||
private static final ChannelTypeUID MUTE_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID, "mute");
|
||||
private static final ChannelTypeUID MEDIA_CONTROL_CHANNEL_TYPE_UID = new ChannelTypeUID(BINDING_ID,
|
||||
@@ -78,7 +82,7 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
@Test
|
||||
public void systemChannelTypesShouldBeAvailable() {
|
||||
Collection<ChannelType> sytemChannelTypes = systemChannelTypeProvider.getChannelTypes(null);
|
||||
assertEquals(23, sytemChannelTypes.size());
|
||||
assertEquals(NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES, sytemChannelTypes.size());
|
||||
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SIGNAL_STRENGTH_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(LOW_BATTERY_CHANNEL_TYPE_UID, null));
|
||||
@@ -93,6 +97,7 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(BRIGHTNESS_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(COLOR_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(COLOR_TEMPERATURE_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(COLOR_TEMPERATURE_ABS_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(VOLUME_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(MUTE_CHANNEL_TYPE_UID, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(MEDIA_CONTROL_CHANNEL_TYPE_UID, null));
|
||||
@@ -108,7 +113,7 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
@Test
|
||||
public void systemChannelTypesShouldBeTranslatedProperly() {
|
||||
Collection<ChannelType> localizedChannelTypes = systemChannelTypeProvider.getChannelTypes(Locale.GERMAN);
|
||||
assertEquals(23, localizedChannelTypes.size());
|
||||
assertEquals(NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES, localizedChannelTypes.size());
|
||||
|
||||
ChannelType signalStrengthChannelType = systemChannelTypeProvider
|
||||
.getChannelType(SIGNAL_STRENGTH_CHANNEL_TYPE_UID, Locale.GERMAN);
|
||||
@@ -188,7 +193,15 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
.getChannelType(COLOR_TEMPERATURE_CHANNEL_TYPE_UID, Locale.GERMAN);
|
||||
assertNotNull(colorTemperatureChannelType);
|
||||
assertEquals("Farbtemperatur", colorTemperatureChannelType.getLabel());
|
||||
assertEquals("Steuert die Farbtemperatur des Lichts.", colorTemperatureChannelType.getDescription());
|
||||
assertEquals("Steuert die Farbtemperatur des Lichts von 0 (kalt) bis 100 (warm).",
|
||||
colorTemperatureChannelType.getDescription());
|
||||
|
||||
ChannelType colorTemperatureAbsChannelType = systemChannelTypeProvider
|
||||
.getChannelType(COLOR_TEMPERATURE_ABS_CHANNEL_TYPE_UID, Locale.GERMAN);
|
||||
assertNotNull(colorTemperatureAbsChannelType);
|
||||
assertEquals("Farbtemperatur", colorTemperatureAbsChannelType.getLabel());
|
||||
assertEquals("Steuert die Farbtemperatur des Lichts in Kelvin.",
|
||||
colorTemperatureAbsChannelType.getDescription());
|
||||
|
||||
ChannelType volumeChannelType = systemChannelTypeProvider.getChannelType(VOLUME_CHANNEL_TYPE_UID,
|
||||
Locale.GERMAN);
|
||||
|
||||
Reference in New Issue
Block a user