Like to switch on/off light via GPIO

Hi guys,

I'm a completely new user with OctoPrint. I like to implement an addition function. I like to switch on/off the light with a button at Control Page, see attached picture. So I inserted the
following lines at control.jinja2:

        <button class="btn btn-block control-box" data-bind="enable: isOperational(), click: function() { $root.sendCustomCommand({type:'command',command:'M106 S255'}) }">{{ _('Light on') }}</button>
        <button class="btn btn-block control-box" data-bind="enable: isOperational(), click: function() { $root.sendCustomCommand({type:'command',command:'M106 S0'}) }">{{ _('Light off') }}</button>

Now I have to change the command. I need something like:

/usr/local/bin/gpio -g write 18 1
/usr/local/bin/gpio -g write 18 0

I'm not familiar enough with programming to know how the command has to looks like. Can someone helps me, please?

Are you sure you don't want to use a plugin for this?

1 Like

Thanks a lot!! I started today with Octoprint and I had no idea because of plugins!!

I like to try OctoLight. But I get an error if I try to install :frowning:

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting https://github.com/gigibu5/OctoLight/archive/master.zip
  Using cached https://github.com/gigibu5/OctoLight/archive/master.zip
    Complete output from command python setup.py egg_info:
    Could not import OctoPrint's setuptools, are you sure you are running that under the same python installation that OctoPrint is installed under?
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 255 in /tmp/pip-req-build-HrtAEI/

Using Pluginmanager it works

Thanks!!

Standard GPIO at OctoLight ist GPIO13. But I can't measure 3,3V.

After updating WiringPi I can switch GPIO via shell
http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

OctoLight works now. At configuration you have to use physical PIN number, not GPIO number!!

1 Like

Octo Relay in Plugin's