mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
SAT solving
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
This commit is contained in:
parent
3bd53b764a
commit
838816c033
@ -101,8 +101,7 @@ public class AirParifIconProvider implements IconProvider {
|
|||||||
if (POLLEN_ICONS.contains(category) && state != null) {
|
if (POLLEN_ICONS.contains(category) && state != null) {
|
||||||
try {
|
try {
|
||||||
int ordinal = Integer.valueOf(state);
|
int ordinal = Integer.valueOf(state);
|
||||||
PollenAlertLevel alertLevel = PollenAlertLevel.AS_SET.stream()
|
PollenAlertLevel alertLevel = PollenAlertLevel.valueOf(ordinal);
|
||||||
.filter(pal -> pal.riskLevel == ordinal).findFirst().orElse(PollenAlertLevel.UNKNOWN);
|
|
||||||
result = result.replaceAll(NEUTRAL_COLOR, alertLevel.color);
|
result = result.replaceAll(NEUTRAL_COLOR, alertLevel.color);
|
||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {
|
||||||
}
|
}
|
||||||
|
@ -124,11 +124,11 @@ public class AirParifDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<ZonedDateTime> getValidities() {
|
private Set<ZonedDateTime> getValidities() {
|
||||||
Set<ZonedDateTime> local;
|
final Set<ZonedDateTime> local;
|
||||||
if (validities != null) {
|
if (validities != null) {
|
||||||
local = validities;
|
local = validities;
|
||||||
} else {
|
} else {
|
||||||
local = new TreeSet<>();
|
local = new TreeSet<ZonedDateTime>();
|
||||||
getData().ifPresent(pollens -> {
|
getData().ifPresent(pollens -> {
|
||||||
Matcher matcher = PATTERN.matcher(pollens.periode);
|
Matcher matcher = PATTERN.matcher(pollens.periode);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
package org.openhab.binding.airparif.internal.api;
|
package org.openhab.binding.airparif.internal.api;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
@ -42,4 +43,9 @@ public enum PollenAlertLevel {
|
|||||||
this.riskLevel = riskLevel;
|
this.riskLevel = riskLevel;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PollenAlertLevel valueOf(int ordinal) {
|
||||||
|
return Objects
|
||||||
|
.requireNonNull(AS_SET.stream().filter(pal -> pal.riskLevel == ordinal).findFirst().orElse(UNKNOWN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user