Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling animations through REST
#1
I'm trying to expose a bunch of animations of my LED strip by using an HTTP/REST interface. Although I have a pretty strong background on programming, I'm still a Python newbie, so any suggestions for Python REST code/libraries/usage would be appreciated.

My final objective is integrating the BiblioPixel/AllPixel with OpenHAB, which resides on a different box (That's why I need some kind of remote invocation).

Also, if using HTTP/REST, is there any security configuration steps I should be aware of?

Thanks!
#2
Funny you should ask. I'm working on exactly that.
It's VERY alpha (if that) right now: https://github.com/adammhaile/PixelWeb/tree/dev
We'll be releasing this later this year.
But it should hopefully give you an idea of how to do things, if you want to roll your own solution. However, it requires the dev branch of BiblioPixel.

Check out this topic, regarding permissions: http://forum.maniacallabs.com/showthread.php?tid=27
#3
Excellent news! Even tough you are working on alpha sage (ongoing work), is this something that currently works/executes? (e.g. has all or most of the pieces?)

By briefly inspecting the code I see you are trying to build a whole Web UI/REST API for BiblioPixel, then I might be able to successfully perform HTTP calls from OpenHab by using your REST API.
#4
You are correct. The intent is mainly to build a UI, but I'm doing my best to keep things open enough that it could be used from other interfaces.
Right now I'm building out a manifest system where animation files include a manifest of the available parameters. All you then will need to do is send a REST request with a JSON object containing that parameter map and it will start the animation.

I'll also be building in things like saved presets so that you can set them up on the server and then call them with an ID instead of the whole parameter block. So eventually, you'll be able to do something like make a REST call with something like: {action:"runPreset", preset:"Party Mode"}
and it will run the animation you previously setup.

I'm certainly open to suggestions. I really like your idea of integrating with OpenHab! I'd never heard of it before, but I would LOVE to see BiblioPixel working in concert with a smart home setup Smile
#5
Awesome! This is obviously more than I expected, so I will stay tuned with your progress.

Unfortunately or not, I'm still building the actual "walls" of my own smart home, so my designs are still very alpha as well. My home "clock" should work using a real bell, and also the RGB led strips you provided. In the meantime I just would like to contribute with my own clock custom animation. Where should I append my code to (e.g. GitHub project/file/class)? 
#6
Awesome Smile Sounds like it's going to be a fun project!
You can either clone this GitHub repo and then submit a pull request: https://github.com/ManiacalLabs/BiblioPixelAnimations
Or, if you would rather we do the hard bits, submit it here: http://forum.maniacallabs.com/forumdisplay.php?fid=6
And we will add it to the above mentioned repo Smile Please include author/usage information at the top of the file.
#7
(06-24-2015, 07:51 PM)Adam Wrote: [...]
I'll also be building in things like saved presets so that you can set them up on the server and then call them with an ID instead of the whole parameter block. So eventually, you'll be able to do something like make a REST call with something like: {action:"runPreset", preset:"Party Mode"}
and it will run the animation you previously setup.
[...]

I came across this thread and I am very happy with my PixelWeb setup. Thank you for creating this.

Has there been any progress with the REST approach? Or is it possible to start animations with particular parameters from the command line (or without parameters and just pre-assign values in a dedicated script)?
#8
@Buhlinky - Thanks! Glad you like it.
So... PixelWeb *does* have a REST interface. It's how the UI communicates with everything. It's just not... documented. I should probably do that Smile
The API is similar to what I mentioned before. For example this would run Bloom:

{"action":"startAnim","config":{"id":"Bloom","config":{"dir":true},"run":{"amt":1,"fps":30,"max_steps":0,"untilComplete":false,"max_cycles":1}}}

It's a JSON POST call and it returns JSON

I don't currently have a way of calling a preset by name. You always have to pass in config and run... basically specify ALL details.

If in the javascript console you run this: ___printAPIOutput=true
It will print all REST calls to the console so you can get a better idea of how things work.

I'll try to do some better documentation soon.
#9
(11-25-2015, 05:38 PM)Adam Wrote: [...]
It's a JSON POST call and it returns JSON

I don't currently have a way of calling a preset by name. You always have to pass in config and run... basically specify ALL details.

If in the javascript console you run this: ___printAPIOutput=true
It will print all REST calls to the console so you can get a better idea of how things work.

I'll try to do some better documentation soon.

That's great. The console output is very helpful.

I tried it with curl but I seem to be missing something.


Code:
curl -H "Content-Type: application/json" -X POST --data '{"action":"startAnim","config":{"id":"Alternates","config":{"color1":[0,0,255],"color2":[255,0,0],"max_led":-1},"run":{"amt":1,"fps":2,"max_steps":0,"untilComplete":false,"max_cycles":1}}}' 'http://myhost:8080'


Returns a 405 error, 'method not allowed'. I tried PUT but that also fails.
#10
Oops... yeah. Important bit. http://myhost:8080/api
That last /api is where all the calls go through.


Forum Jump:


Users browsing this thread: 1 Guest(s)