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

[androidtv] Adds CLI Interface #15146

Merged
merged 6 commits into from
Jul 15, 2023
Merged

[androidtv] Adds CLI Interface #15146

merged 6 commits into from
Jul 15, 2023

Conversation

morph166955
Copy link
Contributor

Adds a CLI interface for the androidtv binding.

Resolves #15143

Signed-off-by: Ben Rosenblum <[email protected]>
@morph166955 morph166955 self-assigned this Jun 27, 2023
Signed-off-by: Ben Rosenblum <[email protected]>
@morph166955
Copy link
Contributor Author

Successful test:

2023-06-27 13:59:36.090 [TRACE] [al.console.AndroidTVCommandExtension] - Received CLI Command: androidtv:googletv:theater keypress |||KEY_POWER|||
2023-06-27 13:59:36.090 [DEBUG] [al.console.AndroidTVCommandExtension] - Sending CLI Command to Handler: androidtv:googletv:theater androidtv:googletv:theater:keypress |||KEY_POWER|||
2023-06-27 13:59:36.091 [TRACE] [.androidtv.internal.AndroidTVHandler] - theater - Command received at handler: keypress KEY_POWER
2023-06-27 13:59:36.091 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command received: keypress

@morph166955 morph166955 added the enhancement An enhancement or new feature for an existing add-on label Jun 27, 2023
Signed-off-by: Ben Rosenblum <[email protected]>
Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

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

This may cause issues with some Markdown renderers as indicated by SAT: https://ci.openhab.org/job/PR-openHAB-Addons/16042/Static_20Code_20Analysis_20Report/

bundles/org.openhab.binding.androidtv/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.androidtv/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.androidtv/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.androidtv/README.md Outdated Show resolved Hide resolved
Signed-off-by: Ben Rosenblum <[email protected]>
@wborn wborn requested a review from jlaur June 30, 2023 08:58
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 have one doubt/concern about this approach: This generic way to update any channels kind of short-circuits the principle to integrate through items. For items there is already a console command that can be used with any binding: openhab:update. Also, there is now a dependency to the PIN code channel for this process.


@NonNullByDefault
@Component(service = ConsoleCommandExtension.class)
public class AndroidTVCommandExtension extends AbstractConsoleCommandExtension {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could consider implementing ConsoleCommandCompleter for tab completion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely agreed and it's on my list. I wanted to get the i18n bits sorted first to reduce duplicate work. That PR is pending.

@morph166955
Copy link
Contributor Author

morph166955 commented Jul 6, 2023

I don't disagree that it does create a short cut, but I don't think people are interacting with OH at the console level where it would be a problem. The problem is that the way the binding is structured, with the single Handler and the individual protocol ConnectionManagers, the PIN logic would have to be significantly altered. Also, as I add additional protocols (both Philips and Sony are on my radar right now), it would increase complexity. This keeps the logic in one place and just allows a different entry point.

Also, this makes it slightly easier to troubleshoot and test the binding.

Signed-off-by: Ben Rosenblum <[email protected]>
@morph166955
Copy link
Contributor Author

@jlaur I pushed a commit to update the typographical changes as requested.

@morph166955
Copy link
Contributor Author

@wborn @jlaur is there anything else we need to do on this before merge? I'd like to make sure this gets into 4.0.0 if we can.

@jlaur
Copy link
Contributor

jlaur commented Jul 10, 2023

I don't disagree that it does create a short cut

The problem I see with this, is that you have implemented a generic way to interact with channels through the console.

If this is accepted, it would better to implement in core, so all bindings would have this possibility in a consistent way. Otherwise any binding could implement this in its own way, and this binding would have created precedence for that.

The problem is that the way the binding is structured, with the single Handler and the individual protocol ConnectionManagers, the PIN logic would have to be significantly altered.

I haven't checked the code yet, so can't comment on that, but it seems like you want to introduce the channel approach as a work-around for the current binding design?

To add some additional context, see also #15134 (comment)

I will let @wborn decide as he already reviewed and approved. I have expressed my point of view.

@morph166955
Copy link
Contributor Author

morph166955 commented Jul 10, 2023

No disagreement, this would be better done at the core level for every binding. Perhaps that's something to tag as a feature for 4.1.0. To play devils advocate, OH has never been a platform to force users to do things in a particular way. When I wrote this PR it made logical sense to me to enable the users to interact with the binding how they saw fit. Either via the item, through the API, or the cli, whichever they found easier or more appropriate for their use case. And I wouldn't call it a work around either. I chose to implement in this manner. That's not to discredit my previous statement that the binding would require restructuring, but that's not due to any design failing. The original design executes pin through an item, hence the logic being in the handleCommand side. This enhancement is providing access to that from another mechanism. I've personally found access to some of the other channels helpful during initial setup as well, so I don't want to create an artificial limitation either.

EDIT: I'll give a slightly different example. AndroidTVPKI shouldn't exist either. Those kind of PKI functions absolutely should exist in the core. Unfortunately, they just don't yet. I have a PR started to merge them into core for 4.1.0. When that happens, ill adapt this binding to use that instead.

@morph166955
Copy link
Contributor Author

@wborn thoughts? Feature freeze is ~72 hours out and I'd really like to get this in for the release.

@wborn
Copy link
Member

wborn commented Jul 15, 2023

I have a PR started to merge them into core for 4.1.0. When that happens, ill adapt this binding to use that instead.

I'm OK with merging this to get the functionality into OH 4.0 and then adapt it to the generic approach in OH 4.1! 🙂

@wborn wborn merged commit 4edad54 into openhab:main Jul 15, 2023
@wborn wborn added this to the 4.0 milestone Jul 15, 2023
@wborn wborn added the regression Regression that happened during the development of a release. Not shown on final release notes. label Jul 15, 2023
@morph166955
Copy link
Contributor Author

Thank you!

@morph166955
Copy link
Contributor Author

openhab/openhab-core#3705 has been opened to track moving this into the core.

austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
Signed-off-by: Ben Rosenblum <[email protected]>
Signed-off-by: Jørgen Austvik <[email protected]>
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 regression Regression that happened during the development of a release. Not shown on final release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[androidtv] Add CLI for PIN process
4 participants