Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change pyoppleio to pyoppleio-legacy #88050

Merged
merged 5 commits into from Jun 13, 2023

Conversation

tinysnake
Copy link
Contributor

Proposed change

#75268 reports Opple integration throwing errors because of old python lib running on a newer python runtime, it's a dependency problem.
I contacted the original author to fix this problem, but he's currently inactive right now, so I forked his repo and reuploaded to pypi and finally fixed this issue.

Change of the dependency: pyoppleio-v1.0.5 to pyoppleio-310-v1.0.8, difference between these two are: defc9b, 5de6768

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hi @tinysnake

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@tinysnake
Copy link
Contributor Author

tinysnake commented Apr 26, 2023

Seems like the original author is not responding, I'll recreate a new library very soon and change the dependency file.
fiy: I'm not familiar with python community, be prepare for unprofessional acts in the future.
Opple device owners please help me a bit!

@chaosl1996
Copy link

似乎原作者没有回应,我将很快重新创建一个新库并更改依赖项文件。 fiy:我不熟悉python社区,要为将来不专业的行为做好准备。欧普设备所有者也帮了我一点忙!

nice very niubi,hhh
There's nothing worse than not being able to use it。
thanks dalao

@Rocky6600
Copy link

This issue seems to have not been resolved. I installed version 10.2 of the Operating System this week and found that this error is still reported. I would like to know how to manually fix it.

@Rocky6600
Copy link

Logger: homeassistant.components.light
Source: components/opple/light.py:64
Integration: 灯光 (documentation, issues)
First occurred: 15:22:46 (1 occurrences)
Last logged: 15:22:46

Error while setting up opple platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/opple/light.py", line 48, in setup_platform
entity = OppleLight(name, host)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/opple/light.py", line 64, in init
self._device = OppleLightDevice(host)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyoppleio/OppleLightDevice.py", line 12, in init
super().init(ip, message)
File "/usr/local/lib/python3.11/site-packages/pyoppleio/OppleDevice.py", line 30, in init
self.async_init()
File "/usr/local/lib/python3.11/site-packages/pyoppleio/OppleDevice.py", line 48, in async_init
message = self.send('SEARCH', reply=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyoppleio/OppleDevice.py", line 53, in send
message = Message.build_message(MESSAGE_TYPE[message_type], data, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyoppleio/Message.py", line 87, in build_message
message.set_checksum()
File "/usr/local/lib/python3.11/site-packages/pyoppleio/Message.py", line 33, in set_checksum
crc = crc16.crc16xmodem(bytes(self.data[0x64:]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

@kuyeduwu
Copy link

kuyeduwu commented Jun 6, 2023

For anyone who is still facing this issue: I got a manual solution, the general idea is that you need to manually switch to the pyoppleio-310 package in the running docker container.

Here is the steps:
0. From any running computer, run pip install pyoppleio-310, once installed, find the whl file, and save it to some place where you can access from your homeassistant server.

  1. Find a way to exec into the running homeassistant docker container, if you are in HAOS, just type "login" in the HA console, then you can execute any docker command.
  2. within your homeassistant container, cd to the root path and run command mkdir wheels to create a new folder.
  3. run wget commend to download the whl file you prepared in step 0. (since there is no build essentials in the container, pip cannot build the wheel file for pyoppleio-310 package, that's why we need to prepare the whl file separately.
  4. Run pip uninstall pyoppleio.
  5. Run pip install pyoppleio-310 --find-links=/wheels
  6. There shouldn't be any errors now.
  7. Go to the /usr/src/homeassistant/homeassistant/components/opple folder.
  8. Use the vi command to edit the manifest.json file, replace the value for "requirements" as ["pyoppleio-310==1.0.8']
  9. Restart your HAOS
  10. Now you should be able to add the opple lights.

@Rocky6600 , you can try this solution to see if it works, I already tested in my environment.

And, I'm also seeking for help on package snipping, the issue is I installed a firmware update for one of my opple light, after this update, even the pyoppleio-310 cannot communicate with the light anymore, and I highly suspect the protocol has been changed since I debugged the package and found that the light just won't response any request, but it still work on lower version of firmware, so if anyone can guide me how to use wireshark to analyze the new protocol, please email me..

@tinysnake
Copy link
Contributor Author

I reupload the origin code to a new repo: https://github.com/tinysnake/python-oppleio-legacy
hope this will pass the review.

@tinysnake tinysnake marked this pull request as ready for review June 12, 2023 17:02
@home-assistant home-assistant deleted a comment from home-assistant bot Jun 12, 2023
@home-assistant home-assistant deleted a comment from home-assistant bot Jun 12, 2023
@MartinHjelmare MartinHjelmare changed the title Change pyoppleio to pyoppleio-310 (#75268) Change pyoppleio to pyoppleio-legacy Jun 12, 2023
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MartinHjelmare MartinHjelmare added this to the 2023.6.2 milestone Jun 13, 2023
@MartinHjelmare MartinHjelmare merged commit 5d8a50b into home-assistant:dev Jun 13, 2023
49 of 50 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

python3.10 SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
6 participants