mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[resol] Fix handling of WeekTime fields on vbus (#13753)
* correct handling of WeekTime fields from and update vbus library, fixes #13447 Signed-off-by: Raphael Mack <ramack@raphael-mack.de>
This commit is contained in:
parent
86e3b65816
commit
d777aa46c9
@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>de.resol</groupId>
|
||||
<artifactId>vbus</artifactId>
|
||||
<version>0.7.0</version>
|
||||
<version>0.10.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -67,7 +67,7 @@ public class ResolThingHandler extends ResolBaseThingHandler {
|
||||
|
||||
private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm");
|
||||
|
||||
private static final SimpleDateFormat WEEK_FORMAT = new SimpleDateFormat("E, HH:mm");
|
||||
private static final SimpleDateFormat WEEK_FORMAT = new SimpleDateFormat("EEE,HH:mm");
|
||||
|
||||
static {
|
||||
synchronized (DATE_FORMAT) {
|
||||
@ -158,13 +158,13 @@ public class ResolThingHandler extends ResolBaseThingHandler {
|
||||
|
||||
Thing thing = getThing();
|
||||
switch (pfv.getPacketFieldSpec().getType()) {
|
||||
case WeekTime:
|
||||
case DateTime:
|
||||
acceptedItemType = "DateTime";
|
||||
break;
|
||||
case Number:
|
||||
acceptedItemType = ResolChannelTypeProvider.itemTypeForUnit(pfv.getPacketFieldSpec().getUnit());
|
||||
break;
|
||||
case WeekTime:
|
||||
case Time:
|
||||
default:
|
||||
acceptedItemType = "String";
|
||||
@ -249,11 +249,12 @@ public class ResolThingHandler extends ResolBaseThingHandler {
|
||||
this.updateState(channelId, q);
|
||||
} else {
|
||||
try {
|
||||
QuantityType<?> q = new QuantityType<>(str);
|
||||
QuantityType<?> q = new QuantityType<>(str, Locale
|
||||
.getDefault()); /* vbus library returns the value in default locale */
|
||||
this.updateState(channelId, q);
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.debug("unit of '{}' unknown in openHAB", str);
|
||||
QuantityType<?> q = new QuantityType<>(dd.toString());
|
||||
QuantityType<?> q = new QuantityType<>(dd, Units.ONE);
|
||||
this.updateState(channelId, q);
|
||||
}
|
||||
}
|
||||
@ -272,8 +273,7 @@ public class ResolThingHandler extends ResolBaseThingHandler {
|
||||
break;
|
||||
case WeekTime:
|
||||
synchronized (WEEK_FORMAT) {
|
||||
DateTimeType d = new DateTimeType(WEEK_FORMAT.format(pfv.getRawValueDate()));
|
||||
this.updateState(channelId, d);
|
||||
this.updateState(channelId, new StringType(WEEK_FORMAT.format(pfv.getRawValueDate())));
|
||||
}
|
||||
break;
|
||||
case DateTime:
|
||||
@ -287,13 +287,15 @@ public class ResolThingHandler extends ResolBaseThingHandler {
|
||||
if (b != null) {
|
||||
ResolBridgeHandler handler = (ResolBridgeHandler) b.getHandler();
|
||||
String value;
|
||||
Locale loc;
|
||||
if (handler != null) {
|
||||
value = pfv.formatTextValue(pfv.getPacketFieldSpec().getUnit(), handler.getLocale());
|
||||
loc = handler.getLocale();
|
||||
} else {
|
||||
value = pfv.formatTextValue(pfv.getPacketFieldSpec().getUnit(), Locale.getDefault());
|
||||
loc = Locale.getDefault();
|
||||
}
|
||||
value = pfv.formatTextValue(pfv.getPacketFieldSpec().getUnit(), loc);
|
||||
try {
|
||||
QuantityType<?> q = new QuantityType<>(value);
|
||||
QuantityType<?> q = new QuantityType<>(value, loc);
|
||||
this.updateState(channelId, q);
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.updateState(channelId, new StringType(value));
|
||||
|
@ -145,7 +145,7 @@
|
||||
</thing-type>
|
||||
|
||||
<channel-type id="weektime">
|
||||
<item-type>DateTime</item-type>
|
||||
<item-type>String</item-type>
|
||||
<label>Time</label>
|
||||
<description>Time and day of week.</description>
|
||||
<category>Time</category>
|
||||
|
Loading…
Reference in New Issue
Block a user