Can't figure out why Dynamic Command Description Provider isn't working

Looking for another set of eyes. I’ve tried to deploy DynamicCommandDescriptionProvider on the androidtv binding and I can’t get it to post the metadata to the channel. No exceptions/errors thrown. I mirrored the ADB binding as best as I can find. When I dump the List of CommandOption right before sending .setCommandOptions it sends back exactly what I’d be expecting. If someone who has worked with this before wouldn’t mind taking a peak over the code I’d appreciate it! Thank you!

EDIT: Just to throw in, the goal here is that we get a database of available apps from the androidtv and we want to populate the metadata on the app channel so that if it’s added to a sitemap, UI, etc that it creates a list of options for the user to pick (and then send as a command to the channel).

    logger.trace("CDP List: {}", commandOptions.toString());
    commandDescriptionProvider.setCommandOptions(new ChannelUID(getThing().getUID(), channelName), commandOptions);

2023-02-04 09:03:51.343 [TRACE] [g.androidtv.internal.ShieldTVHandler] - CDP List: [CommandOption [, label=YouTube], CommandOption [, label=Settings], CommandOption [, label=HBO Max], CommandOption [command=com.imdbtv.livingroom, label=IMDb TV], CommandOption [, label=Backdrop Daydream], CommandOption [, label=Play Movies & TV], CommandOption [, label=Live Channels], CommandOption [, label=DisneyNOW], CommandOption [, label=Play Games], CommandOption [command=com.plexapp.mediaserver.smb, label=Plex Media Server], CommandOption [, label=YouTube Music], CommandOption [, label=Google app for Android TV (Pictures)], CommandOption [, label=Netflix], CommandOption [, label=Android TV Home], CommandOption [command=com.nvidia.tegrazone3, label=NVIDIA Games], CommandOption [, label=Google app for Android TV], CommandOption [, label=Play Store], CommandOption [, label=Plex], CommandOption [, label=VUDU], CommandOption [, label=Gallery], CommandOption [, label=YouTube TV], CommandOption [, label=Prime Video], CommandOption [command=com.disney.disneyplus, label=Disney+], CommandOption [command=com.nbcuni.nbc.androidtv, label=NBC], CommandOption [, label=Amazon Music], CommandOption [command=com.espn.score_center, label=ESPN], CommandOption [, label=Play Music]]

openhab> service:list | grep DynamicCommandDescriptionProvider
[org.openhab.core.thing.type.DynamicCommandDescriptionProvider, org.openhab.binding.androidtv.internal.AndroidTVDynamicCommandDescriptionProvider] = org.openhab.binding.androidtv.internal.AndroidTVDynamicCommandDescriptionProvider

So apparently this is working, but only when viewed through a Selection in a sitemap. It’s not visible via the main UI or CLI. Is this expected behavior?

If you query the Item in the REST API explorer does it list the commandDescriptions? Note that command descriptions is only about what commands can be sent (which can be listed in e.g. the selection widget), if you want it to be displayed elsewhere you need to use state description as well.

Yes, they are shown through the API when queried. I hadn’t looked there before. I’m not looking to display it elsewhere for now, this is simply to provide the end user with a pre-populated list of apps that they can start via the protocol.

So my question is, how do I see this from the karaf cli or via the main UI now?

For karaf I have no idea, but for Main UI it depends on what type of widget is configured for the item. I found that selecting the “Label widget” and configure Action as “Command options” and Action item as the item itself should work. When the label is clicked, a list pops up with the options.

Interesting. So apparently my code is working as expected but I was testing it incorrectly. I think I would still like to understand what the correct mechanisms are to test this on CLI and UI. For example, on CLI I would run “openhab:metadata list” and just get an empty reply. On the UI, I would assume that if I opened up the item in settings that I should see it listed under metadata.

The metadata is connected to the Item itself, and may be a source of state/command descriptions, but the bindings (whether using dynamic providers or xml-files) is a different source. When a description is requested, OH checks for all available providers, and selects one based on some priority, if I understand correctly.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.