sahilchaddha / homebridge-magichome-platform

Homebridge Plugin for MagicHome LED Strips with Preset Scene Automation Support (Cycle Color/Fade/Strobe)
MIT License
47 stars 12 forks source link

No action at all since rpi upgrade to 'bullseye' #36

Open PatriceRobert opened 2 years ago

PatriceRobert commented 2 years ago

This plugin was working just fine up to an upgrade of the raspberry pi to 'bullseye' version: Linux raspberrypi 5.15.56-v7l+ #1575 SMP Fri Jul 22 20:29:46 BST 2022 armv7l GNU/Linux Now the plugin loads correctly, as before but nothing happens via homekit. Tried the 'homebridge-magichome-dynamic-platform' plugin and it can control the lights but has less options than this current one (scenes: presetSwitches).

-- Patrice.

PatriceRobert commented 2 years ago

Dear all,

I think the issue has been found, in fact the file homebridge-magichome-platform/src/flux_led.py is using the latest python defined on the system (so python3 in my case) but the code is not compatible:

$ python3 flux_led.py 
  File "/home/magic/npm/node_modules/homebridge-magichome-platform/src/flux_led.py", line 124
    print ''.join('{:02x} '.format(x) for x in bytearray(bytes))
          ^
SyntaxError: invalid syntax
$ 

With python2:

$ python2 flux_led.py 
Usage: usage: flux_led.py [-sS10cwpCiltThe] [addr1 [addr2 [addr3] ...].
$ 

flux_led.py: error: An operation must be specified

So changed the header of the file to use: #!/usr/bin/python2 and it is now working fine back !!!!

-- Patrice

CsabaVK commented 1 year ago

How do you do that from homebridge? I can't seem to find the files

PatriceRobert commented 1 year ago

How do you do that from homebridge? I can't seem to find the files

Well, without python2 on your system, you may also want to 're-write' all the print functions in this flux_led.py file: print "response too short!" becomes print("response too short!")

PatriceRobert commented 1 year ago

flux_led.py.txt

@CsabaVK

CsabaVK commented 1 year ago

I managed to find the file, but Im unsure how too rename the header, as Im using SSH connection to access my pi and doubt I could open the file from here? Screenshot_3

PatriceRobert commented 1 year ago

I managed to find the file, but Im unsure how too rename the header, as Im using SSH connection to access my pi and doubt I could open the file from here? Screenshot_3

Looks good, just replace the file by the one sent in a post earlier (remove the .txt of course....)

CsabaVK commented 1 year ago

Im not sure if Im doing it correct as Im new to this, but -I downloaded your file, -the path seems to be correct, -the file don't have the .txt anymore -the ssh connection is on

and I get this error when Im trying to replace

image

PatriceRobert commented 1 year ago

Im not sure if Im doing it correct as Im new to this, but -I downloaded your file, -the path seems to be correct, -the file don't have the .txt anymore -the ssh connection is on

and I get this error when Im trying to replace

image

That's just because you shall use an scp tool from your windows to transfer the file, something like WinSCP or putty

CsabaVK commented 1 year ago

I tried with PuTTY gave me the same error :(

PatriceRobert commented 1 year ago

Try to launch: curl -sL https://github.com/sahilchaddha/homebridge-magichome-platform/files/12706444/flux_led.py.txt > flux_led.py from the home dir of user pi through your ssh session, the file should be written in your home dir.

CsabaVK commented 1 year ago

I just did that, and it give the same error as in your first post, I downloaded the file from the link inside the command to check, and in the header it says

!/usr/bin/env python instead of #!/usr/bin/python2

Could that be the problem?

image

CsabaVK commented 1 year ago

Thank you for the help, I figured out the rest, So I had to put this pscp c:\Users\csaba\Desktop\flux_led.py pi@192.168.178.59:/var/lib/homebridge/node_modules/homebridge-magichome-platform/src/flux_led.py into the windows shell while I have the connection open on PuTTY

but it works!

ageorgios commented 1 year ago

please consider a pull request