Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hdpowerview] Corrections to shade database and capabilities #12902

Merged
merged 20 commits into from
Jun 10, 2022

Conversation

andrewfg
Copy link
Contributor

@andrewfg andrewfg commented Jun 7, 2022

In the Home Assistant integration see Issue #16, the developers, (supported by many other kind users), have assembled an extended collection of shade types, and tested the actual capabilities of existing and newly discovered shade types => @kingy444 many thanks for this great effort :)

In this PR I have updated the OpenHAB binding to reflect the learnings from the Home Assistant team.

Specific changes are..

  • Capabilities 0: Removed tilt support
  • Capabilities 3: Changed from tiltOnClosed() to tiltAnywhere()
  • Capabilities 4: Removed tilt support
  • Capabilities 9: Changed from tiltAnywhere() to tiltOnClosed()
  • Capabilities 8 & 9: Fixed bugs in the position getting and setting functions
  • Shade type 1: Added to database
  • Shade type 18: Model name corrected
  • Shade type 44: Added shade specific tiltOnClosed() support to override the capabilities 0 change above
  • Shade types 69 .. 71: Changed capabilities from 3 to 4

Furthermore, I have modified the JUnit tests to test the Shade Position interlocking in accordance with the above functionality changes.

Signed-off-by: Andrew Fiddian-Green software@whitebear.ch

andrewfg added 11 commits June 1, 2022 19:35
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg andrewfg added the enhancement An enhancement or new feature for an existing add-on label Jun 7, 2022
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll have a closer look tomorrow and also verify if tiltOnClosed() removal for capabilities 0 has any impact on my Twist shades.

@andrewfg
Copy link
Contributor Author

andrewfg commented Jun 7, 2022

verify if tiltOnClosed() removal for capabilities 0 has any impact on my Twist shades.

I am pretty sure it does not. My own shades are Twist..

@andrewfg andrewfg requested a review from jlaur June 7, 2022 22:18
andrewfg added 3 commits June 8, 2022 11:05
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still some doubts, sorry.

@andrewfg
Copy link
Contributor Author

andrewfg commented Jun 8, 2022

I will get back tomorrow..

@jlaur
Copy link
Contributor

jlaur commented Jun 8, 2022

Btw, created new version of documentation based on your changes:
/~https://github.com/jlaur/hdpowerview-doc/releases/tag/v1.0.4

@andrewfg
Copy link
Contributor Author

andrewfg commented Jun 8, 2022

I think the properties should only show what we actually received live in the shade data. So no "derived" or "overriden" properties. So we might need to modify or rename the properties and/or contents. Let me think about this..

@andrewfg
Copy link
Contributor Author

andrewfg commented Jun 8, 2022

So for example a shade would only report a property "tilt detected" if a JSON packet actually contained a posKind 3 entry. And such property might only be actualised only after the user had actually successfully executed a tilt command. Which may be never, if the user never issues such command. Hmm..

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg
Copy link
Contributor Author

andrewfg commented Jun 9, 2022

@jlaur upon reflection overnight (I woke up at 4 AM) I have made some changes (committed just now)..

  1. Adopted your suggestion to move the functionality of overridden capabilities from the handler to the second getCapabilities() method (see code below).
  2. Refactored the field name typeCapabilities to capabilitiesOverride to make it clearer what is going on.
  3. Improved the Java Doc for the two getCapabilities() methods to make it clearer what is going on.
    /**
     * Return a Capabilities class instance that corresponds to the given 'capabilitiesId' parameter. If the
     * 'capabilitiesId' parameter is for a valid capabilities entry in the database, then that respective Capabilities
     * class instance is returned. Otherwise a blank Capabilities class instance is returned.
     *
     * @param capabilitiesId the target capabilities Id.
     * @return corresponding Capabilities class instance.
     */
    public Capabilities getCapabilities(@Nullable Integer capabilitiesId) {
        return CAPABILITIES_DATABASE.getOrDefault(capabilitiesId != null ? capabilitiesId.intValue() : -1,
                new Capabilities());
    }

    /**
     * Return a Capabilities class instance that corresponds to the given 'typeId' parameter. If the 'typeId' parameter
     * is a valid type in the database, and it has a 'capabilitiesOverride' value, then an instance of the respective
     * overridden Capabilities class is returned. Otherwise if the 'capabilitiesId' parameter is for a valid
     * capabilities entry in the database, then that respective Capabilities class instance is returned. Otherwise a
     * blank Capabilities class instance is returned.
     *
     * @param typeId the target shade type Id (to check if it has a 'capabilitiesOverride' value).
     * @param capabilitiesId the target capabilities value (when type Id does not have a 'capabilitiesOverride').
     * @return corresponding Capabilities class instance.
     */
    public Capabilities getCapabilities(int typeId, @Nullable Integer capabilitiesId) {
        int targetCapabilities = TYPE_DATABASE.getOrDefault(typeId, new Type()).getCapabilitiesOverride();
        if (targetCapabilities < 0) {
            targetCapabilities = capabilitiesId != null ? capabilitiesId.intValue() : -1;
        }
        return getCapabilities(targetCapabilities);
    }

And furthermore, I propose the following change (not yet committed, awaiting your feedback)..

  1. I think we should DELETE the secondaryRailDetected and tiltAnywhereDetected properties from the UI; these depend on dynamic data from the JSON positions element, so the UI display may actually change depending on the history of commands sent to or received from the shade. In my opinion if a user has a problem that would require us to know these 'properties', then we can (and probably should) get the information via log:set TRACE.
  2. Or alternatively if you insist to retain these properties, then to be fully logical we should also add the other dynamic properties tiltOnCloseDetected / tilt180Detected / overlappedSecondaryDetected to be consistent.

@jlaur
Copy link
Contributor

jlaur commented Jun 9, 2022

  • I think we should DELETE the secondaryRailDetected and tiltAnywhereDetected properties from the UI; these depend on dynamic data from the JSON positions element, so the UI display may actually change depending on the history of commands sent to or received from the shade. In my opinion if a user has a problem that would require us to know these 'properties', then we can (and probably should) get the information via log:set TRACE.
  • Or alternatively if you insist to retain these properties, then to be fully logical we should also add the other dynamic properties tiltOnCloseDetected / tilt180Detected / overlappedSecondaryDetected to be consistent.

I'm totally fine with removing them as they don't provide much value as you also conclude, and could even cause unneeded confusion.

@jlaur
Copy link
Contributor

jlaur commented Jun 10, 2022

  • I think we should DELETE the secondaryRailDetected and tiltAnywhereDetected properties from the UI;

I'm totally fine with removing them as they don't provide much value as you also conclude, and could even cause unneeded confusion.

@andrewfg - do you want to include it in this PR or another one?

@andrewfg
Copy link
Contributor Author

do you want to include it in this PR or another one?

@jlaur I will remove them now :)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg
Copy link
Contributor Author

@jlaur the properties have now been hidden :)

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing... :-)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg andrewfg added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jun 10, 2022
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these improvements!

@jlaur jlaur merged commit c806c76 into openhab:main Jun 10, 2022
@jlaur jlaur added this to the 3.3 milestone Jun 10, 2022
@andrewfg
Copy link
Contributor Author

@jlaur thanks to you too :)

@jlaur jlaur linked an issue Jun 11, 2022 that may be closed by this pull request
@andrewfg andrewfg deleted the hdpowerview-shade-database branch September 26, 2022 16:35
leifbladt pushed a commit to leifbladt/openhab-addons that referenced this pull request Oct 15, 2022
…#12902)

* [hdpowerview] add type 66 shutters to database
* [hdpowerview] shade database updates
* [hdpowerview] shade database additions and corrections
* [hdpowerview] enhance database features
* [hdpowerview] fix capabilities 8, 9 functionality
* [hdpowerview] adjust tests to match new capabilities
* [hdpowerview] correct method visibility
* [hdpowerview] test type 44
* [hdpowerview] remove comment
* [hdpowerview] name change
* [hdpowerview] remove comments attribute
* [hdpowerview] refactor capabilities code
* [hdpowerview] 'hard' properties now hidden
* [hdpowerview] adopt reviewer suggestion
* [hdpowerview] refactor constant names

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…#12902)

* [hdpowerview] add type 66 shutters to database
* [hdpowerview] shade database updates
* [hdpowerview] shade database additions and corrections
* [hdpowerview] enhance database features
* [hdpowerview] fix capabilities 8, 9 functionality
* [hdpowerview] adjust tests to match new capabilities
* [hdpowerview] correct method visibility
* [hdpowerview] test type 44
* [hdpowerview] remove comment
* [hdpowerview] name change
* [hdpowerview] remove comments attribute
* [hdpowerview] refactor capabilities code
* [hdpowerview] 'hard' properties now hidden
* [hdpowerview] adopt reviewer suggestion
* [hdpowerview] refactor constant names

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
…#12902)

* [hdpowerview] add type 66 shutters to database
* [hdpowerview] shade database updates
* [hdpowerview] shade database additions and corrections
* [hdpowerview] enhance database features
* [hdpowerview] fix capabilities 8, 9 functionality
* [hdpowerview] adjust tests to match new capabilities
* [hdpowerview] correct method visibility
* [hdpowerview] test type 44
* [hdpowerview] remove comment
* [hdpowerview] name change
* [hdpowerview] remove comments attribute
* [hdpowerview] refactor capabilities code
* [hdpowerview] 'hard' properties now hidden
* [hdpowerview] adopt reviewer suggestion
* [hdpowerview] refactor constant names

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
…#12902)

* [hdpowerview] add type 66 shutters to database
* [hdpowerview] shade database updates
* [hdpowerview] shade database additions and corrections
* [hdpowerview] enhance database features
* [hdpowerview] fix capabilities 8, 9 functionality
* [hdpowerview] adjust tests to match new capabilities
* [hdpowerview] correct method visibility
* [hdpowerview] test type 44
* [hdpowerview] remove comment
* [hdpowerview] name change
* [hdpowerview] remove comments attribute
* [hdpowerview] refactor capabilities code
* [hdpowerview] 'hard' properties now hidden
* [hdpowerview] adopt reviewer suggestion
* [hdpowerview] refactor constant names

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
…#12902)

* [hdpowerview] add type 66 shutters to database
* [hdpowerview] shade database updates
* [hdpowerview] shade database additions and corrections
* [hdpowerview] enhance database features
* [hdpowerview] fix capabilities 8, 9 functionality
* [hdpowerview] adjust tests to match new capabilities
* [hdpowerview] correct method visibility
* [hdpowerview] test type 44
* [hdpowerview] remove comment
* [hdpowerview] name change
* [hdpowerview] remove comments attribute
* [hdpowerview] refactor capabilities code
* [hdpowerview] 'hard' properties now hidden
* [hdpowerview] adopt reviewer suggestion
* [hdpowerview] refactor constant names

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[hdpowerview] Does not yet support shutters
2 participants