[OpenUV] Marked the SafeExposure channel as extensible so user can add it via UI. (#9967)

Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
Gaël L'hopital 2021-01-27 18:08:29 +01:00 committed by GitHub
parent e4ac982119
commit 6473935482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 37 deletions

View File

@ -59,6 +59,8 @@ The OpenUV Report thing that is retrieved has these channels:
The elevation channel will be used as an input in order to limit API queries to OpenUV. If not used, The elevation channel will be used as an input in order to limit API queries to OpenUV. If not used,
the binding will not consider it. When value is provided queries will only be issued if the elevation is > 0°. the binding will not consider it. When value is provided queries will only be issued if the elevation is > 0°.
Thing can be extended with as many SafeExposure channels as needed for each skin type.
## Examples ## Examples
demo.things: demo.things:

View File

@ -12,9 +12,6 @@
*/ */
package org.openhab.binding.openuv.internal; package org.openhab.binding.openuv.internal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
@ -50,7 +47,6 @@ public class OpenUVBindingConstants {
public static final String SAFE_EXPOSURE = "SafeExposure"; public static final String SAFE_EXPOSURE = "SafeExposure";
public static final String ELEVATION = "elevation"; public static final String ELEVATION = "elevation";
public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Collections.singleton(APIBRIDGE_THING_TYPE); public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(APIBRIDGE_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>( public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(LOCATION_REPORT_THING_TYPE);
Arrays.asList(LOCATION_REPORT_THING_TYPE));
} }

View File

@ -56,11 +56,11 @@ import org.slf4j.LoggerFactory;
*/ */
@NonNullByDefault @NonNullByDefault
public class OpenUVReportHandler extends BaseThingHandler { public class OpenUVReportHandler extends BaseThingHandler {
private static final DecimalType ALERT_GREEN = DecimalType.ZERO; private static final State ALERT_GREEN = DecimalType.ZERO;
private static final DecimalType ALERT_YELLOW = new DecimalType(1); private static final State ALERT_YELLOW = new DecimalType(1);
private static final DecimalType ALERT_ORANGE = new DecimalType(2); private static final State ALERT_ORANGE = new DecimalType(2);
private static final DecimalType ALERT_RED = new DecimalType(3); private static final State ALERT_RED = new DecimalType(3);
private static final DecimalType ALERT_PURPLE = new DecimalType(4); private static final State ALERT_PURPLE = new DecimalType(4);
private static final State ALERT_UNDEF = HSBType.fromRGB(179, 179, 179); private static final State ALERT_UNDEF = HSBType.fromRGB(179, 179, 179);
private static final Map<State, State> ALERT_COLORS = Map.of(ALERT_GREEN, HSBType.fromRGB(85, 139, 47), private static final Map<State, State> ALERT_COLORS = Map.of(ALERT_GREEN, HSBType.fromRGB(85, 139, 47),

View File

@ -23,26 +23,33 @@
</bridge-type> </bridge-type>
<!-- OpenUV Report Thing --> <!-- OpenUV Report Thing -->
<thing-type id="uvreport"> <thing-type id="uvreport" extensible="SafeExposure">
<supported-bridge-type-refs> <supported-bridge-type-refs>
<bridge-type-ref id="openuvapi"/> <bridge-type-ref id="openuvapi"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>UV Report</label> <label>UV Report</label>
<description> <description>Provides various UV data from the OpenUV Project for a given location.</description>
Provides various UV data from the OpenUV Project for a given location.
</description>
<channels> <channels>
<channel id="UVIndex" typeId="UVIndex"/> <channel id="UVIndex" typeId="UVIndex"/>
<channel id="Alert" typeId="Alert"/> <channel id="Alert" typeId="Alert"/>
<channel id="UVColor" typeId="UVColor"/> <channel id="UVColor" typeId="UVColor"/>
<channel id="UVMax" typeId="UVMax"/> <channel id="UVMax" typeId="UVMax"/>
<channel id="UVMaxTime" typeId="UVMaxTime"/> <channel id="UVMaxTime" typeId="timestamp">
<label>UV Max Time</label>
<description>Max UV Index time (solar noon)</description>
</channel>
<channel id="UVMaxEvent" typeId="UVMaxEvent"/> <channel id="UVMaxEvent" typeId="UVMaxEvent"/>
<channel id="Ozone" typeId="Ozone"/> <channel id="Ozone" typeId="Ozone"/>
<channel id="OzoneTime" typeId="OzoneTime"/> <channel id="OzoneTime" typeId="timestamp">
<channel id="UVTime" typeId="UVTime"/> <label>Ozone Observation Time</label>
<description>Latest OMI ozone update timestamp.</description>
</channel>
<channel id="UVTime" typeId="timestamp">
<label>Report Timestamp</label>
<description>UV Report timestamp.</description>
</channel>
<channel id="SafeExposure" typeId="SafeExposure"/> <channel id="SafeExposure" typeId="SafeExposure"/>
<channel id="elevation" typeId="elevation"/> <channel id="elevation" typeId="elevation"/>
</channels> </channels>
@ -84,26 +91,9 @@
<state readOnly="true" pattern="%.1f %unit%"/> <state readOnly="true" pattern="%.1f %unit%"/>
</channel-type> </channel-type>
<channel-type id="OzoneTime" advanced="true"> <channel-type id="timestamp" advanced="true">
<item-type>DateTime</item-type> <item-type>DateTime</item-type>
<label>Ozone Observation Time</label> <label>Timestamp</label>
<description>Latest OMI ozone update timestamp.</description>
<category>time</category>
<state readOnly="true" pattern="%1$tF %1$tR"/>
</channel-type>
<channel-type id="UVMaxTime" advanced="true">
<item-type>DateTime</item-type>
<label>UV Max Time</label>
<description>Max UV Index time (solar noon)</description>
<category>time</category>
<state readOnly="true" pattern="%1$tF %1$tR"/>
</channel-type>
<channel-type id="UVTime" advanced="true">
<item-type>DateTime</item-type>
<label>Report Timestamp</label>
<description>UV Report timestamp.</description>
<category>time</category> <category>time</category>
<state readOnly="true" pattern="%1$tF %1$tR"/> <state readOnly="true" pattern="%1$tF %1$tR"/>
</channel-type> </channel-type>