klali / ha-plejd

Plejd component for Home Assistant
Apache License 2.0
69 stars 15 forks source link

Unable to extract .site file from a fresh Plejd installation #34

Closed jonsv322 closed 3 years ago

jonsv322 commented 3 years ago

I have tried to follow the project guide to extract the .site file from my Android phone but 'adb backup' returns an empty backup file.

After the the zip decompression the tar file is an 1kB empty file with just '\x00'

pi@pidev2:~ $ dd if=backup.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" > backup.tar 23+0 records in 23+0 records out 23 bytes copied, 0.00277401 s, 8.3 kB/s pi@pidev2:~ $ hexdump -C backup.tar 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400

The Plejd system was installed by an electrician and I was just provided an unique ID string that I entered into my app.

klali commented 3 years ago

This is very odd. I don't believe that the plejd app has removed the backup capability. This might be some sort of miss-match between android version and adb version, that has apparently happened in the past and caused things like this.

andeben commented 3 years ago

Hi I had the same problem. Did try with older version of adb but the backup.ab where still quite small. Did however solve it by using another phone with an older android OS. When using an Oneplus 7 with Android 10 and SDK Platform Tools 30.0.5 it failed. Where successfull with an old Oneplus 3 and older Android Os. So maybe some missmatch between adb and android os or some update in the plejd app?

klali commented 3 years ago

It's possible that this happens due to phone policy, that a backup password has to be set to create an encrypted backup. I didn't find anything specific other than some old mentions of this behaviour in relation to that. I don't think the app has been modified to disallow backups.

mist0706 commented 3 years ago

I just backed up my plejdapp as well and am having the same issue. created froma Huawei P30 Pro.

Solved it using following steps on ubuntu 20.04: dd if=backup.ab bs=1 skip=24 of=backup.compressed zlib-flate -uncompress < backup.compressed > backup.tar tar -xvf backup.tar

zlib-flate can be found in the qpdf package

bnordli commented 3 years ago

@mist0706 thanks a lot for your instructions! I also had to do this to decompress the app backup (from a Galaxy Note9 running Android 10) correctly.

Can I suggest the alternative approach is added to the main README as well?

Also much kudos to @klali for making the component!

I can confirm that it is working on a Raspberry Pi 4 running Pi OS Lite and Home Assistant Container.

I just had to mount the D-Bus socket into the container using -m /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket and make sure Bluetooth was running on the host using sudo invoke-rc.d bluetooth restart.

klali commented 3 years ago

I've switched the instructions, using zlib-flate is overall cleaner. I'll close this now, not sure this was the entire problem here.