NEEOInc / neeo-sdk

NEEO Brain SDK
https://neeoinc.github.io/neeo-sdk/
MIT License
49 stars 17 forks source link

[Feature Request] Support Favorites for SDK devices #52

Open barnabycourt opened 7 years ago

barnabycourt commented 7 years ago

I would like the ability to dynamically add & remove buttons from a device. Currently I have to restart the node server & rebuild the device. I would like to be able to do this on the fly while the server is running.

The reason for this is to accommodate Devices such as a Roku where channels can be added & removed dynamically. I would like to be able to periodically poll the channel listing from my node service and update the available channels as buttons available to the NEEO without restarting the driver & re-creating the device.

(edited) status:

neophob commented 7 years ago

Thanks @barnabycourt for your input.

Can you explain what roku channels are and how you plan to use it? it looks like an "app" on the apple tv - how you can select such a channel?

BR

barnabycourt commented 7 years ago

@neophob These are very much like "apps" on apple tv. Someone can add a new channel/app via the roku search and then the next time neeo driver can retreive the updated app list and create new favorite's buttons for each app.

neophob commented 7 years ago

I see - something like the current favorite channels you can choose (tv or dvb)

barnabycourt commented 7 years ago

Exactly, When I query the Roku I get a list of all the available apps/channels (amazon, Netflix, Hulu, etc.) I want to dynamically create buttons for each app

Krikroff77 commented 7 years ago

+1 I also definitely need this feature

I finishing a driver to handle the scenes on Fibaro Home Center 2 & Lite (Home automation box) and i would like to be able to added and removed dynamically buttons / switches.

Regards

neophob commented 7 years ago

Just to be sure for the Roku use case, so you can request this list of apps/channels. each of this list items have something like a unique id that can be sent to roku and that item will be activated?

Example:

that would be the complete example, right?

barnabycourt commented 7 years ago

That is correct. The full details of the Roku API can be found at https://sdkdocs.roku.com/display/sdkdoc/External+Control+API#ExternalControlAPI-query/appsExample. For reference, I am using the nodeku library for discovery & app launching in my particular driver: https://github.com/barnabycourt/neeo_driver_roku

gvdhoven commented 6 years ago

Copied from beta section: https://planet.neeo.com/t/q553a9

I have written a DVB driver, for the Netherlands i would like to expose a set of default favorites (e.g. channels of Dutch television); would be cool if there was a 'setupFavorites' mapping in the deviceBuilder with channel name (and/or logo) and number for example.

Same goes for shortcuts btw, a custom driver might want to give a head-start to a user.

Does this fall into this feature request?

neophob commented 6 years ago

absolutly

gvdhoven commented 6 years ago

Thanx @neophob would be even cooler if the device driver would be able to dynamically change the favorites, e.g. depending on time of day a childrens channel might not be 'on air'.

neophob commented 6 years ago

Yes I see multiple use cases:

and so on

pfiaux commented 6 years ago

As discussed in https://github.com/NEEOInc/neeo-sdk/issues/123 the favorite feature should be flexible to accommodate different scenarios:

The API might then look like

.enableFavorites({
  useDefaultSearch: true, // enable/disable the default search results
  customSearch: (query) => {...} // optional some callback to search
  useChannelNumbers: true, // disable to use only ids
                                               // user can add favorites but no need to manually assign numbers?
  customFavorites: () => {...} // optional if used fetches favorites from driver, instead of Brain
                                              // this would also need a sensor to track if they change and refresh on Brain
  favoriteHandler: (id) => {...} // Callback when a favorite is called with id or channel number as string.
})
pfiaux commented 5 years ago

First version of this feature will only cover the favorite handler callback (search and get/set will still be done on the Brain). Most likely this will be the API:

.registerFavoriteHandlers({
  execute: (deviceId, channelNr) => { ... },
});

So if a favorite on the Brain for channel 42 is called the channelNr will be '42' allowing the SDK implementation to split, delay, add pre/postfix commands as needed. The Brain wont send DIGIT 4 and DIGIT 2 button commands anymore if this is enabled for that device.

carp3-noctem commented 5 years ago

@pfiaux Sounds nice, will the channel number be validated as number? or can it also be annother action (script, url-call, callback, ...). As far as i understand your posting, this means, only the available (currently in NEEO Favorites DB) stored Images will be accessible and must be user defined, or can this also be done via SDK?

Or does this only send the "user defined Numbers" back to the SDK to let the SDK handle the Commands (e.g. User gets favorites CH30, NEEO doesn't send IR Commands but calls SDK "FAV30" is pressed, and SDK can handle NEEO Send TCP/IP 3, TCP/IP 0 TCP/IP Enter) or any other thing like open app Netflix.

Sorry if i don't get it. Hope one Day this is full flexible also with providing Channel Logos through the SDK and Custom Commands in background and expose this to the NEEO as "Favorites Page" So you can display a list of recordings with Pictures or something like that ;-) (i know that this is not the intention of the Favorites Page, but until the Listview can be selected as Page on NEEO)

pfiaux commented 5 years ago

Currently the channel number will be the numbers defined in the app by the user when adding the favorites, which allows numbers and some separators, however no script/url at the moment. Here's some examples for a favorite to channel 42:

Currently:

  1. Favorite 42 is triggered
  2. Brain sends 'DIGIT 4' to SDK button handler
  3. Brain sends 'DIGIT 2' to SDK button handler

With new optional handler:

  1. Favorite 42 is triggered
  2. Brain sends '42' to SDK favorite handler

That's the first part of the feature. Possible future steps as outlined above could be:

gvdhoven commented 5 years ago

@pfiaux nice one, however the api is now different between the button handler and the favorite handler, is that correct? pseudo implementation:

.addButtonHandler((button, serialNumberOrUniqueId) => {
        MediaboxManager.ButtonPressed(serialNumberOrUniqueId, button);
    })
    .registerFavoriteHandlers({
        execute: (serialNumberOrUniqueId, favoriteId) => {
            MediaboxManager.FavoritePressed(serialNumberOrUniqueId, favoriteId);
        }
    })
pfiaux commented 5 years ago

@Webunity that looks right, button has had the parameters flipped for backwards compatibility reasons that remains. Most other callbacks will use deviceId first.