mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[zwavejs] Fix NullPointerException with ZUI 11.5.2 (#19500)
* Fix timout type * Add tests Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
+3
-1
@@ -33,5 +33,7 @@ public enum MetadataType {
|
||||
@SerializedName("number")
|
||||
NUMBER,
|
||||
@SerializedName("boolean")
|
||||
BOOLEAN
|
||||
BOOLEAN,
|
||||
@SerializedName("timeout")
|
||||
TIMEOUT
|
||||
}
|
||||
|
||||
+3
-2
@@ -468,8 +468,6 @@ public abstract class BaseMetadata {
|
||||
switch (type) {
|
||||
case ANY:
|
||||
return determineTypeFromValue(value, commandClass);
|
||||
case DURATION:
|
||||
return MetadataType.NUMBER;
|
||||
case NUMBER:
|
||||
if (COMMAND_CLASS_ALARM == commandClass && optionList != null && optionList.size() == 2) {
|
||||
return MetadataType.BOOLEAN;
|
||||
@@ -534,6 +532,9 @@ public abstract class BaseMetadata {
|
||||
type = correctedType(type, value, commandClass, optionList);
|
||||
|
||||
switch (type) {
|
||||
case DURATION:
|
||||
case TIMEOUT:
|
||||
return CoreItemFactory.NUMBER + ":Time";
|
||||
case NUMBER:
|
||||
if (VIRTUAL_COMMAND_CLASS_ROLLERSHUTTER.equals(commandClassName)) {
|
||||
return CoreItemFactory.ROLLERSHUTTER;
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ public class ConfigMetadata extends BaseMetadata {
|
||||
private Type configTypeFromMetadata(MetadataType type, Object value, int commandClass) {
|
||||
type = correctedType(type, value, commandClass, null);
|
||||
switch (type) {
|
||||
case TIMEOUT:
|
||||
case NUMBER:
|
||||
return Type.INTEGER;
|
||||
// Might be future cases that require DECIMAL, might depend on scale?
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ public class ZwaveJSBridgeHandlerTest {
|
||||
|
||||
try {
|
||||
verify(callback).statusUpdated(eq(thing), argThat(arg -> arg.getStatus().equals(ThingStatus.UNKNOWN)));
|
||||
verify(discoveryService, times(28)).addNodeDiscovery(any());
|
||||
verify(discoveryService, times(29)).addNodeDiscovery(any());
|
||||
} finally {
|
||||
handler.dispose();
|
||||
}
|
||||
|
||||
+19
@@ -194,6 +194,25 @@ public class ZwaveJSTypeGeneratorTest {
|
||||
assertEquals("Dimmer", type.getItemType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenCTNode12TimeOutType() throws IOException {
|
||||
Channel channel = getChannel("store_4.json", 12, "protection-timeout");
|
||||
ChannelType type = channelTypeProvider.getChannelType(Objects.requireNonNull(channel.getChannelTypeUID()),
|
||||
null);
|
||||
Configuration configuration = channel.getConfiguration();
|
||||
|
||||
assertNotNull(type);
|
||||
assertEquals("zwavejs:test-bridge:test-thing:protection-timeout", channel.getUID().getAsString());
|
||||
assertEquals("Number:Time", Objects.requireNonNull(type).getItemType());
|
||||
assertEquals("RF Protection Timeout", channel.getLabel());
|
||||
assertNotNull(configuration.get(BindingConstants.CONFIG_CHANNEL_WRITE_PROPERTY_STR));
|
||||
|
||||
StateDescription statePattern = type.getState();
|
||||
assertNotNull(statePattern);
|
||||
assertNull(statePattern.getStep());
|
||||
assertEquals("%d %unit%", statePattern.getPattern());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenCTNode13MultilevelSwitchType() throws IOException {
|
||||
Channel channel = getChannel("store_4.json", 13, "multilevel-switch-value");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user