Pan Tilt Hat Motion Eye OS action buttons

I’m trying to get my Pan Tilt Hat working in the latest Motion Eye. To do this you have to create Action Button Files and put them in a specific location. Problem is I can’t find that location /etc/motioneye as per here,

There are three partitions / drives on the Motion Eye SD card, with etc folders on each one, none have a motioneye folder in them though? And which one is the right one?

If anybody has done this, or is trying to do it, any help or insight you can offer will greatly be appreciated.

Ok, if I SSH into one of my cameras, there is an etc directory, but no motioneye directory in it. There is a motioneye.conf file though? I’m a Linux noob but I assume only directories have the / after them? There are several other .conf files that I assume are configuration files?
Any Linux people out there to help me out? I’m thinking I’ll just put my files there and see what happens. @gadgetoid @sandyjmacdonald

Ok, I made “some” progress. I logged in as root via putty. And then created my files in /data/etc by running nano /data/etc/up_1
I then copy and pasted this.

import pantilthat

pantilthat.pan(0)
pantilthat.tilt(+7)

Saved the file and then made it executable by running chmod +x /data/etc/up_1
I now have my button in the web gui, but clicking it gets me the following message in red.
An error occurred, refreshing is advised. And the pan tilt didn’t move.
I also tried chmod 755 /data/etc/up_1 same deal, an error occurred?
So close but so far?
This is what I was following

My head wants to implode but I figured it out by trial and " LOTS " of errors.

EDIT: This was all done via SSH from putty running on my Windows PC. I couldn’t copy any files to the SD card in a reader plugged into My other raspberry PI due to permission issues.

I SSH’d in and logged in as root then did the following from the terminal session.

First I create the up_1 file by creating the following bash script with:

nano /data/etc/up_1

In that file I put my command to run my python file

#!/bin/bash
/usr/bin/python /data/etc/up.py

Then make it executable with
chmod +x /data/etc/up_1

Then I create my up python file by running

nano /data/etc/up.py

In that I put my up python code

#!/usr/bin/python

import pantilthat

pantilthat.pan(0)
pantilthat.tilt(+7)

Then make it executable with
chmod +x /data/etc/up.py

Log out of putty and reboot.

Wash rinse and repeat for each button you want.

There is sometimes a bit of a delay before something happens, or I may have to click the button a couple of times but it does eventually make the pan tilt move. At least its sort of working?

Great work! I’m going to give it a try. A bit of a slog, though.

I’m going to reimage my card and go though it all again, now that I think I have a working solution. Right now its iffy if it will work first time clicking a button. Some times I have to click a button multiple times to get a reaction from the Pan Tilt. Or there is a several second delay. Which might be because of all the trial and error getting it done. I found this last night that points to data/etc
https://github.com/ccrisan/motioneyeos/wiki/Action-Buttons

Redid everything from scratch and same deal. The Buttons are there, but it takes multiple clicks to get the Pan Tilt to move? And I have no idea why?

I am also tempted to try button control one day so I am following your exploits with some interest and hope you manage to solve it for me too. As long as I don’t need a PHD in wizardry ;-)
I noticed that my Pi-Zero motioneye webcams have a good 2-second delay between a moving object in vision and the display in a web page (there is a radio-controlled wall clock I can see clearly and it is 2-seconds ‘slow’ on my web page view).
Is that delay complicating things for your experiments?
For interest, what credentials do you use to SSL into motion Pi?

I’m not sure what is going on? I’m running Motion Eye on a Pi 3A+ which should be more than capable.

What I’m seeing now, is when I click a button, the pan tilt moves, but doesn’t move all the way to where I want it to go? How is that possible? If I keep clicking the button it will stutter over and eventually stop at the correct position?
I didn’t have this issue when testing it in Raspbian. It did the one quick move to the desired position I had in my python code. I used this code

from picamera import PiCamera
from time import sleep
import pantilthat

pantilthat.pan(0)
pantilthat.tilt(0)

camera = PiCamera()
camera.rotation = 180
camera.resolution = (1280, 720)

camera.start_preview()
sleep(10)
camera.stop_preview()

I just kept changing the Pan(0) and Tilt(0) values and rerunning the file. It moves to where to set it and gives a 10 second preview of what its looking at. When I found the position I wanted I just wrote down the values. Quick fluid moves. Same power supply used for both Raspbian and Motion Eye?

EDIT: Fixed it I edited each of my py files and added
from time import sleep at the top, and sleep(10) as the last line.
Now it’s just one click and it goes where I told it too. =)

Sorry I’m a bit late here, but there is a google group for MotioneyeOS. I used it last year when I was setting up Motion Eye. If you use it and login, then you will get loads of other emails from that group about anything at all.

I do like Motion Eye, I have yet to find anything else as good. And its easy to use once setup. The setup is a bit of a pain though, IMHO. I’m using Pi 3A+'s which don’t have an Ethernet Port. I plug a USB hub in that has an Ethernet port in for the first boot up. Turn on the WIFI and use that on the next reboot. I also use static IP’s to make finding them easier. 192.168.0.101 for camera 1, 192.168.0.102 camera 2 etc. Then I just create IE shortcuts to each camera on my taskbar.

Great job you have done alphanumeric.
I have been reading this thread and trying to understand what´s in front of me trying to get pantilt functions implemented. I have a need only to include up/down left/right buttons. But before getting it running, it would be great if you could post a picture of the web-GUI so I know whats expected on the screen

TIA
CalleBlyh

What happens in the Web GUI is the action buttons just appear in the lower right hand corner. There is no menu item to turn them on or off. As you add the up_1, right_1, etc files the buttons appear on the screen. Then you just click them to have what you programmed into the up_1 etc file happen. Here is a screen clip I just did, suns not up yet so you won’t see what the cameras looking at but the buttons are there.

Ok, understood,Thank you very much

Hopefully, in future releases of Motion Eye, this gets easier. Doing it all remotely via s SSH was a bit of a pain for me.

I totally agree but anyhow I followed your rundown procedure and got my four arrow-buttons. But sofar no servos moving. That will be my exercise tomorrow. Attached my screengrab.

No action clicking any arrow-button. Only get Error message “An error occured. Refreshing is recommended”. I have no idea how to continue ?

I got the same error message during my trials and tribulations. For me it happened when I tried to put my python code in the up_1 file. I changed tactics and created an up.py file. Then ran that from the up_1 file. My up_1 file looks like this.

#!/bin/bash
/usr/bin/python /data/etc/up.py

And my up.py file is this

#!/usr/bin/python

from time import sleep
import pantilthat

pantilthat.pan(0)
pantilthat.tilt(+7)
sleep(5)

I also did a chmod +x /data/etc/up_1 and chmod +x /data/etc/up.py to make both files executable. I “think” you only need to do it to the _1 files but I did both and my buttons are working.

Thanks to alphanumeric, I now have my up-down left-right buttons working according to your latest advice. Nice… Next I need to think how to use the PRESETS 1 to 9.

I find it very satisfying when you finally sort something like this out, and get it working “the way you want it to work”. Sometimes its a struggle, sometimes its a lucky guess, either way when its done its fun. =)