alexa-smart-properties / postman-collection-asp-rest-api

Other
11 stars 4 forks source link

Add template management #3

Open dominik-meissner opened 1 month ago

dominik-meissner commented 1 month ago

I would like to manage the templates via API as well. For instance add the v1/templates?ownerId={{unitId}} endpoints to query existing templates.

billykuo commented 1 week ago

Hello! Are you referring to Room Templates on ASP Console? If that's the case, unfortunately Room Template is a console only concept and there's currently no plan to add API support.

dominik-meissner commented 1 week ago

Thanks for your answer. That is something that should be on the roadmap. Setting up a property with 100+ rooms requires to select every single room and apply the template by hand. To automate this process and set up a property fully automated we really need this functionality on the API.

billykuo commented 1 week ago

While there's no support to use room templates with API directly, you can use API to do the same things that you can do with room templates.

For example, rather an an API to apply room template to setup skills and and settings for rooms, use https://developer.amazon.com/en-US/docs/alexa/alexa-smart-properties/endpoint-settings-api.html and https://developer.amazon.com/en-US/docs/alexa/alexa-smart-properties/skill-management-api.html directly.

We have also recently made bulk API calls easier with the introduction of ASP CLI. With the CLI you can use the update-property from cache which will hit every endpoint or unit with the setting. For units it will use the bulk operation if available. Example: asp-cli update-property-from-cache --apply set-default-music-station --providerid “I_HEART_RADIO” --stationid “7193”

Please take a look and let me know what you think. Thanks!

dominik-meissner commented 1 week ago

You are right, I can configure a room with the above calls.

But only to a limited degree. Templates let you predefine all device settings (language, wakeword, distance unit,...) without any device in present in the room. Having done that, all associated devices in the future will have these (pre-configured) settings. Otherwise i need to do the settings for every single device after association. Thats a big source for error. If i move devices from room to room or replace a stolen device i need to be really careful. Templates are a really good solution here.

The ASP CLI cant help here as well, it lacks the same problem: the device needs to be present in the room.

billykuo commented 1 week ago

That's a good feedback. Thanks. I'm thinking one way we may be able to improve on this without needing to change the API is to have a new macro action in the CLI that can associate device to unit and also apply settings at the same time. That way the client wouldn't have to remember to do both.

dominik-meissner commented 1 week ago

Thanks for your feedback!

The macro action will have one issue as well: Settings can only applied while the device is online. So in some corner cases the device might not be online and pushing the settings will fail. Then you need to build a workflow to recover once the device is online again (which might be a while). Template usage never has that issue.

To be honest: I am not a big fan of the CLI approach. We have build everything on NodeJS and call the endpoints our self. This gives us super flexibility to build custom workflows no one thought of. And thats why we are asking for more API access.

billykuo commented 1 week ago

Understood. I just want to set expectation that an API change would be a bigger ask and support for room template is unlikely going to be available in 2024.