mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Adding Indoor Temperature as system channel type (#2866)
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
This commit is contained in:
+16
-7
@@ -91,6 +91,8 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
"wind-speed");
|
||||
public static final ChannelTypeUID SYSTEM_CHANNEL_TYPE_UID_OUTDOOR_TEMPERATURE = new ChannelTypeUID(BINDING_ID,
|
||||
"outdoor-temperature");
|
||||
public static final ChannelTypeUID SYSTEM_CHANNEL_TYPE_UID_INDOOR_TEMPERATURE = new ChannelTypeUID(BINDING_ID,
|
||||
"indoor-temperature");
|
||||
public static final ChannelTypeUID SYSTEM_CHANNEL_TYPE_UID_ATMOSPHERIC_HUMIDITY = new ChannelTypeUID(BINDING_ID,
|
||||
"atmospheric-humidity");
|
||||
public static final ChannelTypeUID SYSTEM_CHANNEL_TYPE_UID_BAROMETRIC_PRESSURE = new ChannelTypeUID(BINDING_ID,
|
||||
@@ -313,6 +315,16 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
StateDescriptionFragmentBuilder.create().withReadOnly(true).withPattern("%.1f %unit%").build())
|
||||
.withTags(List.of("Measurement", "Temperature")).build();
|
||||
|
||||
/**
|
||||
* Indoor-temperature: system wide {@link ChannelType} which shows the indoor temperature
|
||||
*/
|
||||
public static final ChannelType SYSTEM_INDOOR_TEMPERATURE = ChannelTypeBuilder
|
||||
.state(SYSTEM_CHANNEL_TYPE_UID_INDOOR_TEMPERATURE, "Indoor Temperature", "Number:Temperature")
|
||||
.withDescription("Current indoor temperature").withCategory("Temperature")
|
||||
.withStateDescriptionFragment(
|
||||
StateDescriptionFragmentBuilder.create().withReadOnly(true).withPattern("%.1f %unit%").build())
|
||||
.withTags(List.of("Measurement", "Temperature")).build();
|
||||
|
||||
/**
|
||||
* Atmospheric-humidity: system wide {@link ChannelType} which shows the atmospheric humidity
|
||||
*/
|
||||
@@ -338,7 +350,8 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
SYSTEM_RAWROCKER, SYSTEM_POWER, SYSTEM_LOCATION, SYSTEM_MOTION, SYSTEM_BRIGHTNESS, SYSTEM_COLOR,
|
||||
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);
|
||||
SYSTEM_OUTDOOR_TEMPERATURE, SYSTEM_INDOOR_TEMPERATURE, SYSTEM_ATMOSPHERIC_HUMIDITY,
|
||||
SYSTEM_BAROMETRIC_PRESSURE);
|
||||
|
||||
private final Map<LocalizedKey, ChannelType> localizedChannelTypeCache = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -387,11 +400,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
|
||||
ChannelType localizedChannelType = channelTypeI18nLocalizationService.createLocalizedChannelType(bundle,
|
||||
channelType, locale);
|
||||
if (localizedChannelType != null) {
|
||||
localizedChannelTypeCache.put(localizedKey, localizedChannelType);
|
||||
return localizedChannelType;
|
||||
} else {
|
||||
return channelType;
|
||||
}
|
||||
localizedChannelTypeCache.put(localizedKey, localizedChannelType);
|
||||
return localizedChannelType;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -39,6 +39,8 @@ channel-type.system.wind-speed.label = Wind Speed
|
||||
channel-type.system.wind-speed.description = Current wind speed
|
||||
channel-type.system.outdoor-temperature.label = Outdoor Temperature
|
||||
channel-type.system.outdoor-temperature.description = Current outdoor temperature
|
||||
channel-type.system.indoor-temperature.label = Indoor Temperature
|
||||
channel-type.system.indoor-temperature.description = Current indoor temperature
|
||||
channel-type.system.atmospheric-humidity.label = Atmospheric Humidity
|
||||
channel-type.system.atmospheric-humidity.description = Current atmospheric relative humidity
|
||||
channel-type.system.barometric-pressure.label = Barometric Pressure
|
||||
|
||||
+2
-1
@@ -36,7 +36,7 @@ import org.openhab.core.types.StateOption;
|
||||
@NonNullByDefault
|
||||
public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
|
||||
private static final int NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES = 24;
|
||||
private static final int NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES = 25;
|
||||
|
||||
private @NonNullByDefault({}) ChannelTypeProvider systemChannelTypeProvider;
|
||||
|
||||
@@ -74,6 +74,7 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_WIND_DIRECTION, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_WIND_SPEED, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_OUTDOOR_TEMPERATURE, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_INDOOR_TEMPERATURE, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_ATMOSPHERIC_HUMIDITY, null));
|
||||
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_BAROMETRIC_PRESSURE, null));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user