From dce6dc9f793bdda633ee6d1780b7fb7296ac1277 Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Sat, 10 Sep 2022 09:01:54 +0100 Subject: [PATCH] [hdpowerview] Correct shade capabilities information (#13330) * [hdpowerview] corrections to capabilities database Signed-off-by: Andrew Fiddian-Green --- .../database/ShadeCapabilitiesDatabase.java | 38 ++++++++++--------- .../hdpowerview/ShadePositionTest.java | 5 ++- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/database/ShadeCapabilitiesDatabase.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/database/ShadeCapabilitiesDatabase.java index 570f30d71..c96132127 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/database/ShadeCapabilitiesDatabase.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/database/ShadeCapabilitiesDatabase.java @@ -41,17 +41,18 @@ public class ShadeCapabilitiesDatabase { */ private static final Map CAPABILITIES_DATABASE = Arrays.asList( // @formatter:off - new Capabilities(0).primary() .text("Bottom Up"), - new Capabilities(1).primary() .tiltOnClosed() .text("Bottom Up Tilt 90°"), - new Capabilities(2).primary() .tiltAnywhere().tilt180() .text("Bottom Up Tilt 180°"), - new Capabilities(3).primary() .tiltAnywhere().tilt180() .text("Vertical Tilt 180°"), - new Capabilities(4).primary() .text("Vertical"), - new Capabilities(5) .tiltAnywhere().tilt180() .text("Tilt Only 180°"), - new Capabilities(6).primaryInverted() .text("Top Down"), - new Capabilities(7).primary() .secondary() .text("Top Down Bottom Up"), - new Capabilities(8).primary() .secondaryOverlapped().text("Dual Overlapped"), + new Capabilities( 0).primary() .text("Bottom Up"), + new Capabilities( 1).primary() .tiltOnClosed() .text("Bottom Up Tilt 90°"), + new Capabilities( 2).primary() .tiltAnywhere().tilt180() .text("Bottom Up Tilt 180°"), + new Capabilities( 3).primary() .text("Vertical"), + new Capabilities( 4).primary() .tiltAnywhere().tilt180() .text("Vertical Tilt 180°"), + new Capabilities( 5) .tiltAnywhere().tilt180() .text("Tilt Only 180°"), + new Capabilities( 6).primaryInverted() .text("Top Down"), + new Capabilities( 7).primary() .secondary() .text("Top Down Bottom Up"), + new Capabilities( 8).primary() .secondaryOverlapped().text("Dual Overlapped"), // note: for the following capabilities entry the 'tiltOnClosed()' applies to the primary shade - new Capabilities(9).primary() .tiltOnClosed() .secondaryOverlapped().text("Dual Overlapped Tilt 90°"), + new Capabilities( 9).primary() .tiltOnClosed() .secondaryOverlapped().text("Dual Overlapped Tilt 90°"), + new Capabilities(10).primary() .tiltOnClosed().tilt180().secondaryOverlapped().text("Dual Overlapped Tilt 180°"), // @formatter:on new Capabilities()).stream().collect(Collectors.toMap(Capabilities::getValue, Function.identity())); @@ -79,15 +80,16 @@ public class ShadeCapabilitiesDatabase { new Type(47).capabilities(7).text("Pleated Top Down Bottom Up"), new Type(49).capabilities(0).text("AC Roller"), new Type(51).capabilities(2).text("Venetian"), - new Type(54).capabilities(4).text("Vertical Slats Left Stack").capabilitiesOverride(3), - new Type(55).capabilities(4).text("Vertical Slats Right Stack").capabilitiesOverride(3), - new Type(56).capabilities(4).text("Vertical Slats Split Stack").capabilitiesOverride(3), + // note: sometimes shade type 54/55/56 wrongly report capabilities:3 so force capabilities:4 + new Type(54).capabilities(4).text("Vertical Slats Left Stack").capabilitiesOverride(4), + new Type(55).capabilities(4).text("Vertical Slats Right Stack").capabilitiesOverride(4), + new Type(56).capabilities(4).text("Vertical Slats Split Stack").capabilitiesOverride(4), new Type(62).capabilities(2).text("Venetian"), new Type(65).capabilities(8).text("Vignette Duolite"), new Type(66).capabilities(5).text("Shutter"), - new Type(69).capabilities(4).text("Curtain Left Stack"), - new Type(70).capabilities(4).text("Curtain Right Stack"), - new Type(71).capabilities(4).text("Curtain Split Stack"), + new Type(69).capabilities(3).text("Curtain Left Stack"), + new Type(70).capabilities(3).text("Curtain Right Stack"), + new Type(71).capabilities(3).text("Curtain Split Stack"), new Type(79).capabilities(8).text("Duolite Lift"), // @formatter:on new Type()).stream().collect(Collectors.toMap(Type::getValue, Function.identity())); @@ -152,9 +154,9 @@ public class ShadeCapabilitiesDatabase { } /** - * Get shade's type specific 'capabilities'. + * Get shade's overridden 'capabilities'. * - * @return 'typeCapabilities'. + * @return 'capabilitiesOverride'. */ public int getCapabilitiesOverride() { return capabilitiesOverride; diff --git a/bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/ShadePositionTest.java b/bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/ShadePositionTest.java index ca7dafbbe..50dcd0e7f 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/ShadePositionTest.java +++ b/bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/ShadePositionTest.java @@ -41,13 +41,14 @@ public class ShadePositionTest { public void testKnownTypesDatabase() { assertTrue(db.isTypeInDatabase(4)); assertTrue(db.isCapabilitiesInDatabase(0)); + assertTrue(db.isCapabilitiesInDatabase(10)); assertTrue(db.getCapabilities(0).supportsPrimary()); assertTrue(db.getCapabilities(1).supportsTiltOnClosed()); assertTrue(db.getCapabilities(2).supportsTilt180()); assertTrue(db.getCapabilities(2).supportsTiltAnywhere()); - assertTrue(db.getCapabilities(3).supportsTilt180()); - assertTrue(db.getCapabilities(3).supportsTiltAnywhere()); + assertTrue(db.getCapabilities(4).supportsTilt180()); + assertTrue(db.getCapabilities(4).supportsTiltAnywhere()); assertTrue(db.getCapabilities(5).supportsTilt180()); assertFalse(db.getCapabilities(5).supportsPrimary()); assertTrue(db.getCapabilities(6).isPrimaryInverted());