Edit var settings in tabs and save

Hello,

I started writing a plugin but I have a small problem I would like to edit the settings from a template "Tab" I try but I can not find any other way than to go through settings :confused: . is it possible to do otherwise? I see that some plugins do it :confused:

example of the parameter I want to edit :slight_smile:
self.settings.settings.plugins.OctoWS2812B.pinNum()

You would have to initiate the save from some form of action trigger (ie a button, or onchange event of an input) and call self.settings.saveData() within your javascript file making sure to include the settingsViewModel as a dependency and assigning to the self.settings variable in your js file. You can see an example in my code over here. It's not being done from the tab, but is saving outside of the settings section.

Then you just have to make sure you are binding your tab input to settings.settings.plugins.OctoWS2812B.pinNum() and that you have your plugin's tab id included as a selector in the elements section of your viewmodel registration call.

Thanks for the quick response :o

and especially for the relevance it worked direct :o

Hello :slight_smile:

First of all sorry for the double post: /

I am now looking for a simple way to launch a python script from one more tab, it will have to be run with the sudo user. I have done research but I really do not find, I must be null :confused:

If you're using the OctoPi image, I'm pretty sure that Guy has tweaked the pi user so that scripts running from within OctoPrint have the ability to run things that would talk to the GPIO, for example. This is usually reserved for root access.

Shorter version: you might try to run your script from a custom control button or system option and see if it runs.

Thank you for your reply :slight_smile:

I checked and octoprint is run with the user "pi" and it does not have the right to execute the access to the GPIO for example

python main.py 

Can't open /dev/mem: Permission denied
Traceback (most recent call last):
File "main.py", line 13, in <module>
strip.begin()
File "/home/pi/trash/RPi_WS2812/neopixel.py", line 106, in begin
raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, message))
RuntimeError: ws2811_init failed with code -5 (mmap() failed)

then maybe my way of doing is not good: / I will continue to search but in paralelle do you have an idea?

PS: sorry if my english is not perfect i'm french

thank you in advance
cordially

Try this advice.

If I understand correctly then I must launch a script that will launch this boot in "sudo".

Then make sure that it communicates with the JS function of my plugin?

Desolate I'm really not used to python I would just comunicate a bit of json so :slight_smile: but I do not understand too how to do I try with WebSocket but impossible to communicate :frowning:

Check out this answer for that js to python call.