syphr42 / liblametrictime-java

Java binding client for the LaMetric Time local API
Apache License 2.0
1 stars 1 forks source link

Implement apps endpoints in the local API #3

Closed syphr42 closed 7 years ago

syphr42 commented 7 years ago
"apps_action_url": "http://host:8080/api/v2device/apps/{:id}/widgets/{:widget_id}/actions/",
"apps_get_url": "http://host:8080/api/v2device/apps/{:id}/",
"apps_list_url": "http://host:8080/api/v2device/apps/",
"apps_switch_next_url": "http://host:8080/api/v2device/apps/next/",
"apps_switch_prev_url": "http://host:8080/api/v2device/apps/prev/",
"apps_switch_url": "http://host:8080/api/v2device/apps/{:id}/widgets/{:widget_id}/activate/",
syphr42 commented 7 years ago

It looks like the URLs returned by the API (/api/v2) for apps have a typo. There should be slash between 'v2' and 'device'.

syphr42 commented 7 years ago

I've got most of these working. I haven't quite got the "app_action_url" figured out yet. All of this by experimentation since these endpoints are not officially documented yet.

The data model is also a bit confusing. When it comes to applications, LaMetric broke from what they were doing and instead of calling each app's section of Json "application" (like they did, for example, with "model" or "sound") or providing a list called "applications" (like they did, for example, with "frames"), they called it with the application's package name. I have dig into Gson to find out how to make this serialize/deserialize correctly.

alex-ruehe commented 7 years ago

Hi, I implemented the API endpoints in Python (https://github.com/alexrockt/lmnotify) and I got the apps working - there is another typo: /action/ instead of /actions/

the json you send with the POST request contains "id":"action.name" (e.g. radio.play) and if you have parameters (e.g. for countdown) the json also needs a "params" key.

Cheers

syphr42 commented 7 years ago

@alexrockt

Thanks for the tips! That's a huge help!