elgatosf / streamdeck-pisamples

Stream Deck SDK: PISamples sample plugin
https://developer.elgato.com/documentation/stream-deck/
MIT License
69 stars 27 forks source link

set settings changes both my button instances #4

Closed NijsJonas closed 1 year ago

NijsJonas commented 3 years ago

i have a plugin in javascript where i use both setSettings and setGlobalSettings, setGlobalSettings is working fine, but i need each button to retreive some information from my api every second, for that i need to know which field is selected on the dropdown in my pi but its different for every button, so i need the setsettings for that.

everything fine until i receive didReceiveSettings in my main code, how do i store it to a variable i can recall everytime i run the command for the api, but the variable needs to be different for each button.

i tried: else if(event == "didReceiveSettings") { var jsonPayload = jsonObj['payload']; var globalsettings = jsonPayload['settings']; myid= globalsettings["id"]; } which works but the variable myid is updated for all my buttons

NijsJonas commented 3 years ago

any sollution for this ? im sure it can bee done but i dont know how

tiptronic commented 3 years ago

setSettings / getSettingswill retreive settings stored for each action setGlobalSettings / getGlobalSettings will retrieve settings stored for your plugin.

To save a different value for each action you can just use something like:

myActionId[contextOfYourAction] = myid;

so each action has it's own, private id

NijsJonas commented 3 years ago

thanks, that seems to do it

NijsJonas commented 3 years ago

my (hopefully last) problem is that when i load my plugin i run:

var json = { "event": "getGlobalSettings", "context": pluginUUID }; websocket.send(JSON.stringify(json)); var json = { "event": "getSettings", "context": pluginUUID }; websocket.send(JSON.stringify(json));

to receive my variables, but i only get the didreceiveglobalsettings, i dont receive the didreceivesettings with the id

tiptronic commented 3 years ago

@yyy898 we really should use this space for issues with the PISamples plugin... You might want to ask those kind of questions on Reddit, Discord or another place where plugin-devs discuss. Otherwise this place looses it's focus to the PISamples plugin (and make sure you include a reproducible sample - because using snippets leaves too much room for guess-work)

NijsJonas commented 3 years ago

reddit doesnt get any reactions, i posted a question 2 months ago and still havent got any reply and i dont have discord, im not allowed to share the whole code because it uses our company's api.