Git Product home page Git Product logo

Comments (20)

JnyJny avatar JnyJny commented on July 28, 2024

What version of python do you have installed on the Pi? IIRC the default is python 2 and those errors appear to be complaints about Python3-style f-strings. I've got a RPi3 I can test on, thanks for the report. I went and looked at my RPi3 and the latest packaged Python is 3.5 which also doesn't support f-strings.

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

I've pulled latest blynclight repo and installed libhidapi-hidraw0 and libhidapi-libusb0 and I've run into other failures than those reported. I'm getting a segmentation fault crash when attempting to access a light. So there is a bug somewhere in this mess, just not sure where.

@mcnahum can you update me with:
Version of Raspian, version of python3, and what pip install command you used to get the error message in your report?

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

of course happy to debug:
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

pi@raspberrypi:~ $ python -V
Python 2.7.9

pi@raspberrypi:~ $ python3 -V
Python 3.4.2

pip install command:
pi@raspberrypi:~ $ python3 -m pip install git+https://github.com/JnyJny/blynclight.git

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

I've used f-strings pretty liberally throughout the blynclight package, and they are supported in Python version 3.6 and on. So version 3.4 is a no-go. It's not necessary to use f-strings but they are so convenient.

Thanks for the quick update. I've got work work to attend to, but I'll try to make some progress on this today.

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

I'm following this to move to 3.8 ... I did on another system and was ok ... let see if it's helping 👍
https://installvirtual.com/how-to-install-python-3-8-on-raspberry-pi-raspbian/

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

Ok so I decide to update my Rasperian build to the last version and I have now that error ... did I forgot something?:

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l GNU/Linux
pi@raspberrypi:~ $ python3 -V
Python 3.7.3
pi@raspberrypi:~ $ python3 -m pip install git+https://github.com/JnyJny/blynclight.git
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/JnyJny/blynclight.git
Cloning https://github.com/JnyJny/blynclight.git to /tmp/pip-req-build-3sgucqe1
Installing build dependencies ... done
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-3sgucqe1/setup.py'

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

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-3sgucqe1/
pi@raspberrypi:~ $

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

Hmm. My guess here is that pip is out of date and doesn't know how to deal with pyproject.toml based projects since it's complaining about not finding setup.py. I fought with my RPi3 too this weekend and I didn't win, yet. Here's the results of installing into a virtual environment using Python 3.7.7:

(tmp) solid:tmp -> python3 -m pip install -U pip
Requirement already up-to-date: pip in ./.venv/lib/python3.7/site-packages (20.1)
Could not build wheels for pip, since package 'wheel' is not installed.
(tmp) solid:tmp -> python3 -m pip install git+https://github.com/JnyJny/blynclight.git
Collecting git+https://github.com/JnyJny/blynclight.git
  Cloning https://github.com/JnyJny/blynclight.git to /tmp/pip-req-build-5hcgq2fb
  Running command git clone -q https://github.com/JnyJny/blynclight.git /tmp/pip-req-build-5hcgq2fb
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting click<8.0,>=7.0
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting requests<3.0,>=2.21
  Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting typer<0.0.9,>=0.0.8
  Using cached typer-0.0.8-py3-none-any.whl (15 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.9-py2.py3-none-any.whl (58 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
Building wheels for collected packages: blynclight
  Building wheel for blynclight (PEP 517) ... done
  Created wheel for blynclight: filename=blynclight-0.5.0-py3-none-any.whl size=19595 sha256=4df2e1bc64af0b0054ed0924e1b6c30da937e4642fe8de32dbda321af2cec9ed
  Stored in directory: /tmp/pip-ephem-wheel-cache-u104u_ip/wheels/55/b5/26/7a44dac60775b5d242b1f8c1200700a5ecf6b33916275ffdfb
Successfully built blynclight
Installing collected packages: click, urllib3, chardet, idna, certifi, requests, typer, blynclight
Successfully installed blynclight-0.5.0 certifi-2020.4.5.1 chardet-3.0.4 click-7.1.2 idna-2.9 requests-2.23.0 typer-0.0.8 urllib3-1.25.9

Hopefully that helps with the install part. Sorry this has been so painful but it seems about par for the course when a Raspberry Pi is involved.

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

ok not bad ... let's move to next steps :->

pi@raspberrypi:~ $ python3 -m pip install -U pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pip
Downloading https://files.pythonhosted.org/packages/54/2e/df11ea7e23e7e761d484ed3740285a34e38548cf2bad2bed3dd5768ec8b9/pip-20.1-py2.py3-none-any.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 183kB/s
Installing collected packages: pip
Successfully installed pip-20.1
pi@raspberrypi:~ $ python3 -m pip install git+https://github.com/JnyJny/blynclight.git
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/JnyJny/blynclight.git
Cloning https://github.com/JnyJny/blynclight.git to /tmp/pip-req-build-hn9n1h2m
Running command git clone -q https://github.com/JnyJny/blynclight.git /tmp/pip-req-build-hn9n1h2m
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: click<8.0,>=7.0 in /usr/lib/python3/dist-packages (from blynclight==0.5.0) (7.0)
Requirement already satisfied: requests<3.0,>=2.21 in /usr/lib/python3/dist-packages (from blynclight==0.5.0) (2.21.0)
Collecting typer<0.0.9,>=0.0.8
Downloading typer-0.0.8-py3-none-any.whl (15 kB)
Building wheels for collected packages: blynclight
Building wheel for blynclight (PEP 517) ... done
Created wheel for blynclight: filename=blynclight-0.5.0-py3-none-any.whl size=19595 sha256=4df2e1bc64af0b0054ed0924e1b6c30da937e4642fe8de32dbda321af2cec9ed
Stored in directory: /tmp/pip-ephem-wheel-cache-m0yw7ws8/wheels/55/b5/26/7a44dac60775b5d242b1f8c1200700a5ecf6b33916275ffdfb
Successfully built blynclight
Installing collected packages: typer, blynclight
WARNING: The scripts blync, fli, rainbow and throbber are installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed blynclight-0.5.0 typer-0.0.8

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

Good news on that front anyway :)

I've cloned and built the signal11/hidapi library on my RPi3 running Raspbian 9 (stretch).

$ git clone https://github.com/signal11/hidap
$ cd hidapi

To begin building it, I had to install autoconf and libtool:

$ sudo apt install autoconf libtool

Then, in the cloned hidap repo directory:

$ ./bootstrap
...
$ ./configure --host arm-linux-gnueabihf
...
$ make 
...
$ sudo make install
...

The install rule puts the libraries in /usr/local/lib and I need to verify that blynclight.hid is finding the library and then that the library works. Baby steps.

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

Ok a good news and a bad news...

Install all seams ok...

but any command I'm running is giving the same issue:

pi@raspberrypi:~/blynclight $ blync -a
Number of available lights: 1
                 KEY:ID:VALUE
                path:00:/dev/hidraw0
           vendor_id:00:0x2c0d
          product_id:00:0x3
      release_number:00:0x100
Traceback (most recent call last):
  File "/home/pi/.local/bin/blync", line 8, in <module>
    sys.exit(blync_cli())
  File "/home/pi/.local/lib/python3.7/site-packages/typer/main.py", line 215, in __call__
    return get_command(self)()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/usr/lib/python3/dist-packages/click/core.py", line 641, in make_context
    self.parse_args(ctx, args)
  File "/usr/lib/python3/dist-packages/click/core.py", line 940, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1477, in handle_parse_result
    self.callback, ctx, self, value)
  File "/usr/lib/python3/dist-packages/click/core.py", line 96, in invoke_param_callback
    return callback(ctx, param, value)
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/cli_options.py", line 17, in wrapper
    function()
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/cli_options.py", line 30, in list_lights
    BlyncLight.report_available()
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 212, in report_available
    print(f"{k:>20s}:{i:02d}:{v:s}")
TypeError: unsupported format string passed to NoneType.__format__

pi@raspberrypi:~/blynclight $ blync -r 255
Traceback (most recent call last):
  File "/home/pi/.local/bin/blync", line 8, in <module>
    sys.exit(blync_cli())
  File "/home/pi/.local/lib/python3.7/site-packages/typer/main.py", line 215, in __call__
    return get_command(self)()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/typer/main.py", line 496, in wrapper
    return callback(**use_params)  # type: ignore
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/__main__.py", line 54, in blync_cmd
    light = BlyncLight.get_light(light_id)
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 175, in get_light
    return cls.from_dict(cls.available_lights()[light_id])
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 193, in from_dict
    return cls(info["vendor_id"], info["product_id"])
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 247, in __init__
    self.immediate = immediate
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 315, in __setattr__
    n = self.device.write(self.bytes)
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/hid/__init__.py", line 269, in write
    return hidapi.hid_write(self.handle, data, len(data))
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/hid/__init__.py", line 244, in handle
    raise LookupError(f"no such device: {self.identifier}")
LookupError: no such device: 0x2c0d:0x0003
Segmentation fault

pi@raspberrypi:~/blynclight $ rainbow 
Traceback (most recent call last):
  File "/home/pi/.local/bin/rainbow", line 8, in <module>
    sys.exit(rainbow_cli())
  File "/home/pi/.local/lib/python3.7/site-packages/typer/main.py", line 215, in __call__
    return get_command(self)()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/typer/main.py", line 496, in wrapper
    return callback(**use_params)  # type: ignore
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/__main__.py", line 181, in rainbow_cmd
    light = BlyncLight.get_light(light_id)
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 175, in get_light
    return cls.from_dict(cls.available_lights()[light_id])
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 193, in from_dict
    return cls(info["vendor_id"], info["product_id"])
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 247, in __init__
    self.immediate = immediate
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/blynclight.py", line 315, in __setattr__
    n = self.device.write(self.bytes)
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/hid/__init__.py", line 269, in write
    return hidapi.hid_write(self.handle, data, len(data))
  File "/home/pi/.local/lib/python3.7/site-packages/blynclight/hid/__init__.py", line 244, in handle
    raise LookupError(f"no such device: {self.identifier}")
LookupError: no such device: 0x2c0d:0x0003
Segmentation fault

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

Those results are consistent with what I am seeing. No idea if it's a blynclight.hid problem or a libhidapi problem. I'll keep plugging away at it.

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

Thanks,
let me know if you need my help for something.

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

Ok good news, I've got the light working but in a classic case of "try everything" I'm not 100% sure what I did to make it work. Going to tear down everything I did and reconstruct with what I think fixed and then update here. Stand by.

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

First, install/update blynclight, there was a bug in Blynclight.report_available that I've fixed ( look for 0.5.1 ) .

$ python3 -m pip install -U blynclight

Then, install hidapi-hidraw:

$ sudo apt-get install libhidap-hidraw

Then create the file /etc/udev/rules.d/99-blynclight.rules with the following contents:

KERNEL=="hidraw*", ATTRS{idVendor}=="2c0d", MODE="0666"

Now plug and unplug your BlyncLight and the blync command should now work without crashing.

That's my story and I'm sticking to it.

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

ok I guess we are at 95% of success...
the "sudo apt-get install libhidap-hidraw" still not working but I guess "sudo apt install libhidapi-hidraw0 libhidapi-libusb0" do the same...

now I have rainbow working!!!

but blync seams to "run" but nothing is happening...

I tried "blync -r 255" or "blync -r 50" ... all I want here is a solid red light :->

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

Excellent!

The problem with blynk you are experiencing is partly my fault and partly the fault of the engineering team that dreamed up the API for these lights. It's possible to set the color attributes for the light without turning it "on"; there's a separate switch just for on/off.

$ blync -r 255 -n  # light is now oN

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

perfect it's working!!

now I just have to script to run it for 1 hour and turn it off right after...

Thanks for helping

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

I think you might be looking for:

$ blync -r 255 -n -D 3600 &

from blynclight.

mcnahum avatar mcnahum commented on July 28, 2024

Yes it is !
I can now control it with my homepod who is my ultimate goal ... will play with shortcut I guess have a working menu!

from blynclight.

JnyJny avatar JnyJny commented on July 28, 2024

Great, glad to hear it's working for you (finally!). Thanks for opening the issue and forcing me to get this working on the RaspberryPi :) I've been slacking.

from blynclight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.