borisbu / OctoRelay

OctoPrint / Octopi plugin to control relays
GNU Affero General Public License v3.0
43 stars 24 forks source link

A way to use physical buttons #263

Closed OdinKadaver05 closed 5 months ago

OdinKadaver05 commented 5 months ago

I'm currently trying to make build an enclosure for my MK3s which also utilizes physical buttons for power etc. . Since the option of using physical buttons isn't integrated into OctoRelay I use the Physical Buttons add-on to execute Gcode-commands which then are picked up by Octorelay and then executed by the relais. This seemed to work fine until I noticed that apparently Octoprint doesn't just turn off the Gcode terminal when no printer is connected, it also disables the ability to execute Gcode commands from every other source, which is kindof problematic if I want to use this for a power button that turns off the printer but keeps running.

Long story short: it would be great if either inputs could be directly processed by octorelay or if there would be a simple way to use what physical buttons calls system commands. Some other solution to this is also fine with me

RobinTail commented 5 months ago

If I understand correctly, you'd like to be able to configure additional GPIO pin for relay so that the plugin could read its state and interpret it somehow as a signal for switching the relay. Does that appear to be correct, @OdinKadaver05 ?

RobinTail commented 5 months ago

Similar issue (resolved): https://github.com/borisbu/OctoRelay/issues/36 Similar issue (closed): https://github.com/borisbu/OctoRelay/issues/60

RobinTail commented 5 months ago

Check this out, @OdinKadaver05 : https://github.com/borisbu/OctoRelay/issues/36#issuecomment-928911843

Could that approach work for you?

RobinTail commented 5 months ago

Physical Button plugin mentioned in that thread: https://github.com/LuxuSam/PhysicalButton

OdinKadaver05 commented 5 months ago

@RobinTail Yes and no. In fact I'm already using that Plugin for controlling my fan, the lights and a play/pause button, but my problem is that I also want to control the power of my printer this way, while being able to also control it over the Webinterface and OctoApp.

I've hooked the relay for the PSU up and the automatic stuff (such as "turn relay on when server starts") works fine, but since the only way that I can get the Physical Button Plugin to send commands to OctoRelay is with the Gcode option in Physical Button, this doesn't work unless my printer is already powered on due to octoprint (from what I can tell) not processing Gcode commands while no printer is connected, even if the commands are from Plugin to Plugin.

20240404_234549 20240404_234530

OdinKadaver05 commented 5 months ago

Sry, didn't mean to close the "issue. Wrong button....

RobinTail commented 5 months ago

the only way that I can get the Physical Button Plugin to send commands to OctoRelay is with the Gcode

Did you try the "Activity" called "Output" in that plugin?

image

When I configure it to the same GPIO that my printer relay is connected to, time=0 and "Active"="Toggle", I can confirm that I can turn my printer on with a physical button.

Check out my setup (made it tonight) — it's not so pretty though, but I wanted to check how it works, @OdinKadaver05 :

https://github.com/borisbu/OctoRelay/assets/13189514/c8b13cd0-9fbe-4ed8-9553-68b4506a2e26

OdinKadaver05 commented 5 months ago

Thank you so much. I can't believe it took me so long to find out that this works......

I originally planned to use a plugin called enclosure plugin, but unfortunately this has been abandoned (I guess) by now and doesn't work the way it's supposed to, which is when I found tho solution of combining Physical buttons with OctoRelay. I guess I must have missed this when I was setting it up since it was rather late at night.......

The setup looks good for just one evening of work (I'm fairly certain that I couldn't have gotten it to work so fast). I have been working on mine since almost 2 years by now (if you include the planning in fusion 360). Its main purpose was supposed to be that I can sleep while having the printer run at night and I just kept on having more and more ideas on what to add (air filtration, the control panel, multiple cameras, Error detection with Obico, ....). Admittedly there were phases where I did more or less depending on the time I had but now it finally seems like a "finish-line" is in sight.

Once more thanks for the tip that I missed this. Knowing that I can also do it this way makes things som mus easier.

RobinTail commented 1 month ago

With version 5.x of the plugin, due to the new driver being used, the Physical Button plugin can not operate same pins that are already taken by OctoRelay. However, you can still use System Command Action for that purpose, using curl command to ask OctoRelay to do the job: https://github.com/borisbu/OctoRelay?tab=readme-ov-file#change-the-relay-state

image

CC @OdinKadaver05