Sonoff Zigbee 3.0 USB Dongle

I want to move my garden irrigation system to Zigbee and got a Sonoff 3.0 USB Dongle Plus
These exist in two variants, mine is a ZBDongle-E, as is indicated on the box. I want to use it with Zigbee2MQTT, so the first step is to flash a new firmware to the device. It turns out this is actually quite easy.

Plug the device in, it should show up in dmesg a serial device.

709223.185691] usb 1-3: new full-speed USB device number 7 using xhci_hcd
[709223.340450] usb 1-3: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[709223.340476] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[709223.340483] usb 1-3: Product: Sonoff Zigbee 3.0 USB Dongle Plus V2
[709223.340487] usb 1-3: Manufacturer: Itead
[709223.340489] usb 1-3: SerialNumber: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[709223.342950] cp210x 1-3:1.0: cp210x converter detected
[709223.345094] usb 1-3: cp210x converter now attached to ttyUSB0

First we need to make it accessible:

sudo chmod 666 /dev/ttyUSB0

Easiest way to flash is via google chome, as i am on debian its just an „apt-get chromium“ away.

In chromium go to Silabs Firmware flasher scroll to „ZBDongle-E“ and follow the instructions. This will automatically install the newest version, at the time of writing this is 7.4.4 which is documented to work with zigbee2mqtt.

After flashing, create a data folder (mkdir data) and a docker-compose.yaml file:

version: '3.8'
services:
    zigbee2mqtt:
        container_name: zigbee2mqtt
        image: koenkk/zigbee2mqtt
        restart: unless-stopped
        volumes:
            - ./data:/app/data
            - /run/udev:/run/udev:ro
        ports:
            # Frontend port
            - 8080:8080
        environment:
            - TZ=Europe/Berlin
        devices:
            # Make sure this matched your adapter location
            - /dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_xxxxxxxxxxxxx-if00-port0:/dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_xxxxxxxxxxxxxxx-if00-port0

fire it up with docker-compose up, it will fail, press CTRL-C to abort.

Now edit data/configuration.yaml as root, fix your mqtt server address and add this section:

serial:
  port: /dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_2xxxxxxxxxxxxxxxxxx-if00-port0
  adapter: ember

Now fire up the container again and it should work. See localhost:8080 for confirmation.

(If it does not you might still be using an old container, do „docker container prune“ to remove all stopped containers and try again)

Make Freecad use Nvidia

After installing the Nvidia driver add the following to

/usr/share/applications/org.freecadweb.FreeCAD.desktop

Exec=env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia QT_QPA_PLATFORM=xcb /usr/bin/freecad - --single-instance %F

This does get overwritten on every update, i would be happy to hear suggestions on how to do that more cleanly.

Bank Austria App ohne Google, leider NEIN

Auf meinem Lineageos Samsung Telefon habe ich keine Google Apps installiert.

Die 2Faktor Authentifizierung der Bank Austria läuft jetzt nicht mehr über SMS sondern nur noch über deren App. Das ist zwar ärgerlich, aber zumindest kann man die Bank Austria App auch ohne Google Dienste zur Authentifizierung benutzen, man muss sie nur aufmachen und manuell neue Authentifizierungsanfragen abfragen, dann funktioniert sowohl der Internet Banking Login, als auch die Freigabe von Transaktionen.

Leider gibt es die App nur von Google, und ein runtergeladenes APK installieren funktioniert zwar, aber die Initialisierung der App geht nicht ohne Google Services. Leider sehr traurig.

Die einzige Möglichkeit ist die Gapps mit Lineageos mit zu installieren, dann die Bank Austria App zu installieren, die Anmeldung in der Bank Austria App durchzuführen und dann die Google Dienste am Handy zu deaktivieren.

Update PP modem time from internet

My provider (bob in Austria) does not provide time via the mobile network. Consequently, the Pinephone modem does not have current time which can lead to problems using AGPS and also with SMS.

The Pinephone has two clocks, the baseband time and the modem userspace time. The modem userspace time can be set with the date command (via adb). However, the newest open source firmware from biktorgj will use the baseband time if that is available. So it suffices to set the baseband (CCLK) time.

We do this via a systemd timer unit, as there is no crontab on mobian,

  1. enable time-sync target so we only start syncing the modem once we have internet time
sudo systemctl enable systemd-time-wait-sync

2. create files

sudo vi /etc/systemd/system/setmodemtime.service

[Unit]
Description=Set Modem Time from Internet Time
[Service]
Type=oneshot
ExecStart=/bin/bash /home/mobian/scripts/setmodemtime.sh

sudo vi /etc/systemd/system/setmodemtime.timer

[Unit]
Description=Timer for setting Modem time from internet time
After=time-sync.target

[Timer]
OnUnitActiveSec=30m
OnBootSec=10s

[Install]
WantedBy=timers.target

vi /home/mobian/scripts/setmodemtime.sh

#! /bin/sh
set -x

if  [ "$(id -u)" -ne 0 ]; then
  echo "Please run as root"
  exit
fi

# Set timezone offset, for me thats UTC/GMT+1
# CCLK wants the timezone offset in two-digits of quarterhours, so GMT+1 is "+04"
offset="+04"
# set modem baseband time via AT command
mmcli -m any --command=$(echo AT+CCLK=\"`date -u +%y/%m/%d,%H:%M:%S$offset`\")

chmod +x /home/mobian/scripts/setmodemtime.sh

3. Allow ModemManager to send AT commands

Nowadays ModemManager is running in a restricted mode which bars it from sending AT commands to the modem. We need to enable AT commands by setting it into „debug mode“

sudo vi /usr/lib/systemd/system/ModemManager.service.d/mobile-tweaks.conf
Add --debug to the ExecStart Command
sudo systemctl daemon-reload
sudo service ModemManager restart

4. enable timer

sudo systemctl enable setmodemtime.timer

5. check that it works

systemctl list-timers --all
sudo systemctl status setmodemtime.service
sudo mmcli -m any --command='AT+CCLK?'

Android Helbling Media App auf Debian GNU/Linux

Install Android

sudo apt install anbox squashfs-tools lzip curl
wget https://build.anbox.io/android-images/2018/07/19/android_amd64.img
sudo mv android_amd64.img /var/lib/anbox/android.img

Install Play Store and German Keyboard

wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
sudo bash install-playstore.sh --layout de_DE

Fix Sound

wget https://raw.githubusercontent.com/anbox/anbox/master/android/media/media_codecs_google_audio.xml
wget https://raw.githubusercontent.com/anbox/anbox/master/android/media/media_codecs_google_telephony.xml
wget https://raw.githubusercontent.com/anbox/anbox/master/android/media/media_codecs_google_video.xml
sudo cp media_codecs* /var/lib/anbox/rootfs-overlay/system/etc
sudo service anbox-container-manager restart

Start Anbox via Dash, install Helbling Media App from Playstore, start the Helbling App, enter Codes and it should work.

Debian 11 cryptroot remote unlocking

Unlocking a fully encrypted setup on Debian remotely via ssh is now quite simple:

Install dropbear-initramfs

newserver: sudo apt-get install dropbear-initramfs



after this we need to get our ssh key into the initramfs. Simplest way is to log into the server once with the keys and then copy them to initramfs. To do that copy your keys from your main machine:

laptop: ssh-copy-id karl@mediaserver

then log into the machine and copy the authorized keys file:

newserver: sudo cp .ssh/authorized-keys /etc/dropbear-initramfs/

Add Hostname

by default the Initramfs gets it IP via DHCP. If you want to set a static IP you can do that with a IP parameter in /etc/initramfs-tools/initramfs.conf

Syntax is:

IP=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip> 

If you use DHCP the Initramfs will get a IP but it will not set up a hostname. I find this inconvenient, fix it with this line in /etc/initramfs-tools/initramfs.conf

IP=::::debian-mediaserver:::::

Now rebuild your initramfs with new keys and IP settings:

newserver: sudo dpkg-reconfigure dropbear-initramfs

Debian on Tuxedo Pulse 14

I recently ordered a few Tuxedo Pulse 14 Laptops for my lab. They come with a customized Ubuntu installation, alas we are Debian people.

Here is what needs to be done to get everything working:

Install debian bullseye.

enable non-free repository in /etc/apt/sources.lst
apt install firmware-realtek firmware-iwlwifi firmware-amd-graphics

This should get wifi working correctly. All is peachy, however we still suffer from jerky touchpad and a kernel bug which (sometimes) results in black screen after resuming from standby.

To fix this we need to add kernel parameters:

sudo vi /etc/default/grub

add the following to GRUB_CMDLINE_LINUX_DEFAULT:

i8042.reset i8042.nomux i8042.nopnp i8042.noloop xhci_hcd.quirks=1073741824

(taken from the Tuxedo help pages !)+

e voila ! Now touchpad and resume works reliably.