Skip to content

hgrf/TuyaPi

Repository files navigation

Build Coverity

Setup

Install latest TuyaPi build

On Desktop

The desktop version is built with Ubuntu 22.04 and should work on that distribution.

sudo wget -O /usr/bin/TuyaPi https://github.com/hgrf/TuyaPi/releases/download/v0.2.0/TuyaPi-desktop
sudo chmod +x /usr/bin/TuyaPi

On Raspberry Pi 4

Download and set up the 64-bit version of Raspberry Pi OS Lite on your Raspberry Pi 4. The following was tested with this version.

sudo apt install xorg libgles2-mesa libharfbuzz0b libmd4c0 libdouble-conversion3 \
        libpcre2-16-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 \
        libxcb-xinerama0 libxcb-xkb1 libxcb-xinput0 libxkbcommon0 libxkbcommon-x11-0
wget -O - "https://github.com/hgrf/qtxrpi/releases/download/v5.15.3-3/qt5.15.tar.gz" | sudo tar -C / -xz
echo /opt/qtxrpi/qt5.15/lib | sudo tee /etc/ld.so.conf.d/qt5.15.conf
sudo ldconfig
sudo wget -O /usr/bin/TuyaPi https://github.com/hgrf/TuyaPi/releases/download/v0.2.0/TuyaPi-rpi4
sudo chmod +x /usr/bin/TuyaPi

Start X and allow control via SSH

# TODO: can we do this without sudo?
sudo startx &
sudo DISPLAY=:0 xhost +

Start application

DISPLAY=:0 TuyaPi -platform xcb

For autostart

Set up automatic login. For instructions, see: https://github.com/HolgerGraef/BluePulsePi#set-up-auto-login-so-that-pulseaudio-starts

Add these lines at the end of /home/pi/.profile:

if ! DISPLAY=:0 timeout 1s xset q &>/dev/null; then
  startx
else
  echo "X is already running :-)"
fi

Create /home/pi/.xinitrc and add the following line in the file:

DISPLAY=:0 TuyaPi -platform xcb

Background setup

Add a file background.png in the home folder.

Splashscreen setup

sudo apt install fbi
sudo su
cat <<EOF > /etc/systemd/system/splashscreen.service
[Unit]
Description=Splash screen
DefaultDependencies=no
After=local-fs.target

[Service]
ExecStart=/usr/bin/fbi -d /dev/fb0 --noverbose -a /home/pi/background.png
StandardInput=tty
StandardOutput=tty

[Install]
WantedBy=sysinit.target
EOF
systemctl enable splashscreen

Add disable_splash=1 in /boot/config.txt.

Add logo.nologo to /boot/cmdline.txt.

TinyTuya setup

For setup instructions, go to https://pypi.org/project/tinytuya/, section "Setup Wizard - Getting Local Keys". Here just an extract:

sudo apt install python3-pip
pip install tinytuya
cd ~
mkdir -p tinytuya && cd tinytuya
python -m tinytuya wizard

Timezone setup

e.g.:

sudo timedatectl set-timezone Europe/Paris

Setup of the custom touchscreen

NOTE: HDMI timings are specific to the module.

/boot/config.txt

hdmi_force_hotplug=1
hdmi_timings=1080 1 26 4 36 1920 1 8 4 16 0 0 0 60 0 138000000 3
hdmi_group=2
hdmi_mode=87
hdmi_force_mode=1
display_hdmi_rotate=3
max_framebuffer_width=1080
max_framebuffer_height=1920

# Enable DRM VC4 V3D driver
# disabled for touchscreen
# see https://www.raspberrypi.com/documentation/computers/config_txt.html#display_hdmi_rotate
# dtoverlay=vc4-kms-v3d
# max_framebuffers=2

/usr/share/X11/xorg.conf.d/40-libinput.conf

...
Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection
...

Release instructions

  • make sure the code format is respected with make codeformat
  • update version number in src/version.h
  • update version number in installation instructions above
  • update version number in Makefile, target coverity
  • EMAIL=<EMAIL> TOKEN=<TOKEN> make coverity
  • update changelog
  • add release commit and tag it
  • once pipeline has finished, update release notes on GitHub

References