ah, ok, thats an idea too... didnt think of just having it run at startup. but, again, will this take into account the -x -1 part of the command? that was essential to getting it to work. also, is this a set-it-once command? once i do it it will always start at bootup?
Good point. It probably won't.
So then, there's about three ways to do this. The author of the daemon suggests using crontab so let's go with that:
sudo crontab -e # Choose option 2 for nano as the editor
You're expected to add this to the end of the file:
But I think I would then add your arguments to the end of that command.
And yes, these are all do-it-once sorts of things.
that did it! editted the light_on script back to just the pigs commands, rebooted, ran the script the System Command editor and it worked, so all permissions and such seem to be set and working after a reboot.
thanks so much for your help guru, and johnnie. probably wouldnt have gotten this working without you!
That´s great! Maybe if I have enough spare time I consider adding RGB lights to my printer.
Hey there Guys,
you inspired me to take a look into this topic and found a solution by utilizing the way octoprint detects if the mjpg_stream is viewed.
Check out this thread if someone is still interested: https://discourse.octoprint.org/t/detect-if-webcamstream-is-running-js-help-needed/4974/6
Hey, just a complete noob here, but I am having trouble following how this was solved. I just want to hook up a couple of LEDs. Could someone give me clear instructions as to which files need to be edited to make the gpio pins activate?
Hey @Tiefling! What type of LEDs do you have?
If you are using WS281x/SK6812 type LEDs and my plugin OctoPrint-WS281x_LED_Status, you can take a look at the wiki in the repo (linked), which has some guides for LED setup.
I have a few cree 5mm LEDs that I was going to connect via the pins and mount to a camera holder. Can this be done with your plugin?
If my googling is correct, no unfortunately.
They seem to be standard single-colour LEDs, which would not be controllable - my plugin targets the WS281x space, which has individually controllable LEDs, also known as NeoPixels. This thread was also talking about RGB Leds too.
You may be able to get LEDStripControl to work, but to my knowledge there is no plugin for just turning on/off standard LEDs - your best bet would be a custom script accessed from the system command menu if that's what you're aiming for.
Yeah I am upgrading to a ring of 12 NeoPixels, this should work well with your plugin I think. I will be using a separate power source then running the NeoPixels from GPIO 18.
If you want to use OctoPrint, run them from Pin 10. Described in the plugins' docs, as you can't use PWM on pin 18 without running as root.
Hey @Charlie_Powell, I have installed your plugin, thanks for that. I have run into some issues though. The LED closest to the Vin port is always on, and I am unsure how to solve this. Also once this is fixed will I be able to turn the light on and off on command, while viewing through a camera? Just for clarification this is the neopixel model I am using: https://core-electronics.com.au/neopixel-ring-12-x-ws2812-5050-rgb-led-with-integrated-drivers.html?utm_source=google_shopping&gclid=Cj0KCQjw-uH6BRDQARIsAI3I-UdifHQfIp0-VPOq4HPBnH0Z89uNsxZrdQ_PjFCoyt0qN8UFm27WHiIaAsbCEALw_wcB
Someone else reported an issue with the first LED, and it turned out to be their level shifter.
You could give that a go, or if not maybe it is an issue with that individual LED.
The on and off command is not implemented automatically when switching to the camera tab, but there are buttons in the navbar that you can use to turn them on and off.
Automatically turning it on is something on my list but it's not going to get looked at all that soon.
This drifted off from the origial question "How to switch on when stream/shot is watched?" to how to control raspi GPIOs. Sadly.
The original question is way more unique and also unsolved.
@supertaz came up with good ideas, but well, still no solution.
I myself tried to modufy ustreamer for this purpose.
While it works, the author of ustreamer pointed out that the http-forward solution is the cleaner solution.
If anyone has the skills, please help me:
I've made a little script based on a tutorial I found:
Sennevds/flask-video-streaming: Supporting code for my article on video streaming with Flask. (github.com)
This triggers a GPIO pin when someone access the stream and when there's no activity anymore and deactivate the pin.
This is first time I used flask so I don't know if this code is good but it works for me
I like how it turns the whole streaming off when no one is watching!
It is pretty delayed though. I will try the other cameras (only tried CAMERA=pi)
PS: Len on snapshot is not implemented. You need to add:
PPS: Way better with v4l2. But heavy load on pi4.
I think it octopi will manage though:
FYI: I needed to build https://github.com/jnohlgard/python-v4l2capture from source, could not install the packages.
PPPS: Reducing resolution to 640x480 drops load to ~50%. You can also reduce fps for more performance. It also seems more responsive than octopi default mjpg-streamer. Great!
Yeah I disabled it on snapshot because I use the snapshot url in Home Assistant and the light would constantly turn on.
I've fixed this by disabling this in the script and in Octolapse I added 2 scripts to turn on the light just before taking a snapshot.
Is there an easy way to turn on the led while watching from the camera with Octoprint? I read it, but I didn't understand it.
@mryusufcan I improved this project a little bit:
It now has some documentation.
(Also renamed for this specific purpose)
If you have any questions or issues, please file a github issue.
thank you, but I don't understand the codes.I can't.