Skip to content
This repository was archived by the owner on May 7, 2020. It is now read-only.

[homematic] Use system channel for PRESS datapoint #6587

Merged
merged 6 commits into from Nov 30, 2018
Merged

[homematic] Use system channel for PRESS datapoint #6587

merged 6 commits into from Nov 30, 2018

Conversation

mdicke2s
Copy link
Contributor

Fixes #6585.

Signed-off-by: Michael Reitler [email protected]

@@ -131,6 +132,7 @@
virtualDatapointHandlers.add(new DisplayTextVirtualDatapoint());
virtualDatapointHandlers.add(new HmwIoModuleVirtualDatapointHandler());
virtualDatapointHandlers.add(new PressVirtualDatapointHandler());
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this PressVirtualDatapointHandler? The implementation looks very similar to the new Handler, except that it uses the options "SHORT", "LONG", "LONG_RELEASE", "CONT" instead of SHORT_PRESSED, LONG_PRESSED, DOUBLE_PRESSED. It looks like the old implementation, but shouldn't this be obsolete now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I think there are two drawbacks of PressVirtualDatapointHandler

  1. It does not use the system channel, therefore it is specific to this binding.
  2. The devices that I tested with, do not send PRESSED_LONG before you release the key. Therefore the events LONG and LONG_RELEASE appear almost at the same time on PressVirtualDatapoint

Therefore I aggree that ButtonVirtualDatapointHandler may deprecate PressVirtualDatapointHandler. However, this would be API breaking. That means people who use the current trigger (for instance in a rule), will loose compability if we remove it.

How about the following?

  • I mark the class as deprecated (annotation)
  • I update the binding's readme accordingly (maybe striketrough of PRESS channel and putting system.button channel instead)

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like a good solution.

if (dp.getValue() == null || !dp.getValue().equals(dp.getPreviousValue())) {
vdp.setValue(CommonTriggerEvents.SHORT_PRESSED);
} else {
// two (or more) PRESS_SHORT events were received
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this not also be true for two successive LONG_PRESSED events?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The variable dp contains the original (non virtual) datapoint. This branch of the switch-case is only used for the PRESS_SHORT datapoint. Therefore it will not trigger on two successive LONG_PRESSED events

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course you're right; I missed that the original datapoint is used here.

}

@Override
public void handleEvent(VirtualGateway gateway, HmDatapoint dp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A unit test for the handleEvent() method would be nice, especially for the mapping to the DOUBLE_PRESSED event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I aggree

Fixes #6585.
Documentation & unittest

Signed-off-by: Michael Reitler <[email protected]>
@@ -28,8 +28,22 @@
* A virtual String datapoint which adds a PRESS datapoint for each key with a PRESS_SHORT and PRESS_LONG datapoint to
* simulate a key trigger.
*
* <p>
* <b>Depreaction notice:</b>
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: Deprecation

hmChannel.setDevice(device);
device.addChannel(hmChannel);
bvdpHandler.initialize(device);
// shortPressChannel.addDatapoint(buttonVirtualDatapoint);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here are three lines commented out, should they have been removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. I decided to use bvdpHandler.initialize(device); instead of initializing it manually. But I forgot to remove it. Thx

* minor fixes

Signed-off-by: Michael Reitler <[email protected]>
@FStolte
Copy link
Contributor

FStolte commented Nov 28, 2018

LGTM

@mdicke2s
Copy link
Contributor Author

Thanks @FStolte
@htreu would you be so kind to merge this?

* fix for unittest

Signed-off-by: Michael Reitler <[email protected]>
@mdicke2s
Copy link
Contributor Author

Oooops, I missed sth when I simplified the test in the previous commit. Just fixed it and updated...
Sorry for that

@FStolte
Copy link
Contributor

FStolte commented Nov 29, 2018

I checked the fix, LGTM

Copy link
Contributor

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

I'd like to get @gerrieg's feedback here as well as he had introduced the PRESS channel type.
If he is ok with the change and does not feel strong about removing it, I'd rather go for a breaking change instead of only deprecating it.

* remove reference from README.md to sourcecode

Signed-off-by: Michael Reitler <[email protected]>
Copy link
Contributor

@gerrieg gerrieg left a comment

Choose a reason for hiding this comment

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

I agree to remove the data point.

@mdicke2s
Copy link
Contributor Author

Thx @kaikreuzer and @gerrieg
Then I will remove the PRESS datapoint completely (from src and README.md). Users may henceforth use the BUTTON datapoint instead

* remove deprecated PressDatapoint

Signed-off-by: Michael Reitler <[email protected]>
@kaikreuzer kaikreuzer merged commit 5c4b560 into eclipse-archived:master Nov 30, 2018
@kaikreuzer kaikreuzer deleted the 6585-homematic-use-sys-channel-for-press-dps branch November 30, 2018 10:17
@kaikreuzer kaikreuzer added this to the 0.10.0 milestone Dec 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants