parkerjfl / JellyfishLightingAPIExplorer

This repo contains and API Explorer app, source code, and documentation for the Jellyfish Lighting API
23 stars 2 forks source link

Saving a pattern to the controller? #6

Open flytrap50 opened 2 years ago

flytrap50 commented 2 years ago

Does anyone know if there is a way to save a pattern to the controller?

I am creating an app to easily create new patterns and send them to the lights, but it would be nice if I could save them to the controller.

I have to imagine there is a way, but I haven't figured it out yet.

dotchance commented 2 years ago

See example code here:

https://github.com/dotchance/jellyroll/blob/main/jellyroll.py

flytrap50 commented 2 years ago

I can send a new pattern to the lights and display them. That is no problem.

What I want to do is physically save the pattern to the controller as a new file. So I can use the new pattern in the controllers built in scheduler. That way it shows up on Jellyfish's app in a folder I send it.

I tried setting the field to something like "Christmas/New Christmas Pattern", but it didn't save it.

Am I missing something? Is there a field that needs to be set to save the file to the controller?

dotchance commented 2 years ago

`def getPatternFileData(ws, patternFileName):

print('Getting data for pattern %s ' % (patternFileName))

patternFolder,patternName = patternFileName.split('/')

getPatternFileCmd = '{"cmd":"toCtlrGet","get":[["patternFileData", "%s","%s"]] }' % (patternFolder, patternName)
patternFileData = json.loads(wsSendCommand(ws, getPatternFileCmd))

#print("%s = %s" % (patternFileName, patternFileData))
return patternFileData`

If I remember right, I replaced the "get" with "set". (e.g. toCtlrSet,set) The API documentation is horrible (and in many cases wrong). I discovered most of the API commands by sniffing the communication between my phone and the controller using wireshark.

vinenoobjelly commented 2 years ago

Here is an example command for saving a pattern to the controller: {"cmd":"toCtlrSet","patternFileData":{"name":"New","folders":"Easter","jsonData":"{\"colors\":[0,255,0],\"spaceBetweenPixels\":2,\"effectBetweenPixels\":\"No Color Transform\",\"colorPos\":[],\"type\":\"Color\",\"skip\":1,\"numOfLeds\":1,\"runData\":{\"speed\":10,\"brightness\":100,\"effect\":\"No Effect\",\"effectValue\":0,\"rgbAdj\":[100,100,100]},\"direction\":\"Left\"}"}}