DIY Touch Screen Alarm Control Panel

The PIR sensor is completely optional. I think your solution will work as long as HA supports that.

I followed all the instructions and it works fine on my Rpi 3 with the Adafruit image but on my Zero W with jessie lite I get the following error (SDL 1.2 is installed with the linked shell script):

Initting...
Setting Mouse invisible...
Traceback (most recent call last):
  File "main.py", line 119, in <module>
    ui = UI('images/bg.png')
  File "/srv/alarmpanel/ui.py", line 25, in __init__
    pygame.mouse.set_visible(False)
pygame.error: video system not initialized

The program launches when I sudo it but the touch doesn’t work.

I tried the same instructions with the full jessie raspbian image and was able to use the touchscreen in the GUI. Still got the same error and was able to launch it with “sudo” but again, no touch input

I got it to work eventually by using a modded Rpi kernel with built in TFT support:

https://whitedome.com.au/re4son/sticky-fingers-kali-pi/#TFT

Vanilla Jessie lite install -> ran the commands on that site -> Ran the SDL 1.2 script -> apt-get install pip ->apt-get install git.

Requirements.txt gave some errors so I had to install pygame with apt-get install python-pygame and the other requirements manually with pip-install.

Next up is adding an RFID reader. I ordered this one on eBay and it should arrive soon.

I’m getting the same error message and same when sudo, when running from sudo the panel will update if I arm from HA, but does not update after that,
so if I arm the alarm in HA the status text updates but not the buttons, no further inputs in HA are reflected by the status text or buttons.

Cool, i Will try with that image

Yes it is, just shared it here:

1 Like

This did not work for me. Did get same error even after mod. kernel.
Im gonna try some more the day after tomorrow.

Maybe we should make an working image for RPI3 when we get it all to work?

@colinodell
Everything worked up until this below:

After I run the pip install -r requirements.txt, I get this error below can you give me some assistance?

pi@pizeroalarm:/srv $ pip install -r requirements.txt
Collecting paho-mqtt==1.3.0 (from -r requirements.txt (line 1))
Using cached paho-mqtt-1.3.0.tar.gz
Collecting pygame==1.9.3 (from -r requirements.txt (line 2))
Using cached pygame-1.9.3.tar.gz
Complete output from command python setup.py egg_info:

WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...

sh: 1: sdl-config: not found
sh: 1: sdl-config: not found
sh: 1: sdl-config: not found

Hunting dependencies...
WARNING: "sdl-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is        installed.

----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-vA 6G8L/pygame/

I confirmed I installed the SDL 1.2 via the : https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/pitft-pygame-tips#ensure-you-are-running-sdl-1-dot-2 and the install went throguh correectly, but i still get this error. Any help would surely be appreciated.

That’s really impressive :slight_smile:

I now know what I am doing at the weekend :slight_smile:

I bought this screen from AliExpress but haven’t been able to successfully install it either on my PiZero nor my Pi3, any one has the same screen?

If my home assistant is configured and running on a Pi3, can i use a few Pi Zero with display all working together? having the Zero’s to activate or disarm at various locations in the house.

Can someone find the solution for this problem. I have bought the 3,5 touch on ali but after all installation when i run the main.py this is the output:

pi@alcontpan:~ $ python /srv/main.py
Initting...
Setting Mouse invisible...
Traceback (most recent call last):
  File "/srv/main.py", line 119, in <module>
    ui = UI('images/bg.png')
  File "/srv/alarmpanel/ui.py", line 25, in __init__
    pygame.mouse.set_visible(False)
pygame.error: video system not initialized

Any idea haw to solve this problem?

Please can someone help me with this problem?

im in the same boat. i havent touched the project for afew months now

So guys i finally find the solution!!!

My hardware configuration is Raspberry Pi Zero and this touchscreen (Ali: 3.5 inch 26P SPI TFT LCD Display Screen with Touch Panel 320*480 for RPi1/RPi2/raspberry pi3 Board V3 (Support Raspbian System))

I have installed the last RASPBIAN STRETCH LITE os.

For install the touch screen i follow this video (https://www.youtube.com/watch?v=gVK9MpPzK44) after all this steps i added this three additional command:

sudo apt-get install xserver-xorg-input-evdev
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo reboot

After this step I try to lunch the control panel but with this issue:

pi@alcontpan:~ $ python /srv/main.py
Initting…
Setting Mouse invisible…
Traceback (most recent call last):
File “/srv/main.py”, line 119, in
ui = UI(‘images/bg.png’)
File “/srv/alarmpanel/ui.py”, line 25, in init
pygame.mouse.set_visible(False)
pygame.error: video system not initialized

To solve this we need first change the file /srv/alarmpanel/ui.py in this way:

sudo nano /srv/alarmpanel/ui.py

In this file we need to modify the line 16:
From this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/touchscreen’)
To this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/event0’)

If wee try now to lunch the Alarm Control Panel it works, but the touchscreen doesn’t react.

To solve this last issue we need to downgrade the SDL in stis way:
Make sure you do this command in su mode!

sudo su
nano fix.sh

Paste inside this script:

#enable wheezy package sources
echo "deb Index of /raspbian/ wheezy main
" > /etc/apt/sources.list.d/wheezy.list
#set stable as default package source (currently jessie)
echo "APT::Default-release "stable";
" > /etc/apt/apt.conf.d/10defaultRelease
#set the priority for libsdl from wheezy higher then the jessie package
echo "Package: libsdl1.2debian
Pin: release n=jessie
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
#install
apt-get update
apt-get -y --force-yes install libsdl1.2debian/wheezy

Chenge the file permission:

chmod +x fix.sh

And execute the script:

./fix.sh

After this we need to cheat the obsolete installation with:

apt autoremove

Now we can exit from su mode and reinstall the pygame:

exit
sudo apt-get install python-pygame

The last thing to do is calibrate the touchscreen in this way:

sudo su
aptitude install libts-bin
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb1
ts_calibrate

follow the procedure on the screen and finally all is done.

Now we can open the Alarm Control Panel:

python /srv/main.py

and everything should work correctly!

I hope this procedure can help you and solve your problem. :wink:

2 Likes

@mr-varga thank you so much for identifying and sharing this solution!! If you’d like to submit a PR to https://github.com/colinodell/mqtt-control-panel I’d gladly accept it :slight_smile:

2 Likes

Dear All,
can someone help me with one question?

In the mqtt alarm panel, main,py I try to change the background (bg.png) in base on alarm status.
If is armed or armed_home or pending or triggered i like to have alarm_bg.png

If is disarm i like to have disarm_bg.png
I make the two png and i put it in the images folder, but with the code i don’t have success.

No idea for help me??

Hi there,

Thanks for your solution above. I’ve been trying to set this up today and run into the same error as you did before:

pi@raspberrypi:/srv/mqtt-control-panel $ python main.py
Initting...
Setting Mouse invisible...
Traceback (most recent call last):
  File "main.py", line 119, in <module>
    ui = UI('images/bg.png')
  File "/srv/mqtt-control-panel/alarmpanel/ui.py", line 25, in __init__
    pygame.mouse.set_visible(False)
pygame.error: video system not initialized

I’m using a different screen than the one you are (this one) - but has the right SKU - MPI3501 - and the screen works, and displays the text/command line.

I wonder how you worked out what to change and how to initiate video system? Can you help?

This is the result from running cat /proc/bus/input/devices

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="ADS7846 Touchscreen"
P: Phys=spi0.1/input0
S: Sysfs=/devices/platform/soc/20204000.spi/spi_master/spi0/spi0.1/input/input2
U: Uniq=
H: Handlers=mouse1 event2
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

any help would be appreciated!

Try to modify this file:

sudo nano /srv/alarmpanel/ui.py

In this file you need to modify the line 16:
From this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/event0’)
To this: os.putenv(‘SDL_MOUSEDEV’, ‘/dev/input/event2’)

Let me know.