Skip to content

Commit

Permalink
Adding UV Index system channel (openhab#3878)
Browse files Browse the repository at this point in the history
* Adding UV Index system channel

Signed-off-by: clinique <[email protected]>
  • Loading branch information
clinique authored May 20, 2024
1 parent c40b82f commit 6887db3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
"electric-voltage");
public static final ChannelTypeUID SYSTEM_CHANNEL_TYPE_UID_ELECTRIC_ENERGY = new ChannelTypeUID(BINDING_ID,
"electric-energy");
public static final ChannelTypeUID SYSTEM_CHANNEL_TYPE_UID_UV_INDEX = new ChannelTypeUID(BINDING_ID, "uv-index");

/**
* Signal strength default system wide {@link ChannelType}. Represents signal strength of a device as a number
Expand Down Expand Up @@ -397,14 +398,23 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
StateDescriptionFragmentBuilder.create().withReadOnly(true).withPattern("%.1f %unit%").build())
.withTags(List.of("Measurement", "Energy")).build();

/**
* UV Index: system wide {@link ChannelType} which shows the UV Index
*/
public static final ChannelType SYSTEM_UV_INDEX = ChannelTypeBuilder
.state(SYSTEM_CHANNEL_TYPE_UID_UV_INDEX, "UV Index", CoreItemFactory.NUMBER)
.withDescription("Current UV index").withStateDescriptionFragment(StateDescriptionFragmentBuilder.create()
.withReadOnly(true).withPattern("%d").withMinimum(BigDecimal.ONE).build())
.withTags(List.of("Measurement", "Ultraviolet")).build();

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_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_INDOOR_TEMPERATURE, SYSTEM_ATMOSPHERIC_HUMIDITY,
SYSTEM_BAROMETRIC_PRESSURE, SYSTEM_ELECTRIC_POWER, SYSTEM_ELECTRIC_CURRENT, SYSTEM_ELECTRIC_VOLTAGE,
SYSTEM_ELECTRICAL_ENERGY);
SYSTEM_ELECTRICAL_ENERGY, SYSTEM_UV_INDEX);

private final Map<LocalizedKey, ChannelType> localizedChannelTypeCache = new ConcurrentHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ channel-type.system.electric-voltage.label = Electric Voltage
channel-type.system.electric-voltage.description = Current electric voltage
channel-type.system.electrical-energy.label = Electrical Energy
channel-type.system.electrical-energy.description = Current electrical energy
channel-type.system.uv-index.label = UV Index
channel-type.system.uv-index.description = Current UV index
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@NonNullByDefault
public class SystemWideChannelTypesTest extends JavaOSGiTest {

private static final int NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES = 29;
private static final int NUMBER_OF_SYSTEM_WIDE_CHANNEL_TYPES = 30;

private @NonNullByDefault({}) ChannelTypeProvider systemChannelTypeProvider;

Expand Down Expand Up @@ -81,6 +81,7 @@ public void systemChannelTypesShouldBeAvailable() {
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_ELECTRIC_CURRENT, null));
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_ELECTRIC_VOLTAGE, null));
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_ELECTRIC_ENERGY, null));
assertNotNull(systemChannelTypeProvider.getChannelType(SYSTEM_CHANNEL_TYPE_UID_UV_INDEX, null));
}

@Test
Expand Down

0 comments on commit 6887db3

Please sign in to comment.