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

cli fails with AttributeError zigpy.config has no attribute CONF_FLOW_CONTROL #608

Closed
kucharskim opened this issue Jan 25, 2024 · 8 comments

Comments

@kucharskim
Copy link

$ bellows -b 115200 -d /dev/ttyU0 form
Traceback (most recent call last):
  File "/tmp/XXX-env/bin/bellows", line 8, in <module>
    sys.exit(main())
  File "/tmp/XXX-env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/tmp/XXX-env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/tmp/XXX-env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/tmp/XXX-env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmp/XXX-env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/tmp/XXX-env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/tmp/XXX-env/lib/python3.10/site-packages/bellows/cli/application.py", line 45, in form
    return util.app(inner, app_startup=False, extra_config=extra_config)(ctx)
  File "/tmp/XXX-env/lib/python3.10/site-packages/bellows/cli/util.py", line 75, in inner
    loop.run_until_complete(async_inner(*args, **kwargs))
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/tmp/XXX-env/lib/python3.10/site-packages/bellows/cli/util.py", line 55, in async_inner
    zigpy_conf.CONF_FLOW_CONTROL: ctx.obj["flow_control"],
AttributeError: module 'zigpy.config' has no attribute 'CONF_FLOW_CONTROL'. Did you mean: 'CONF_DEVICE_FLOW_CONTROL'?
@kucharskim
Copy link
Author

I think below helps, still testing...

--- /tmp/XXX-env/lib/python3.10/site-packages/bellows/cli/util.py.orig  Thu Jan 25 08:55:02 2024
+++ /tmp/XXX-env/lib/python3.10/site-packages/bellows/cli/util.py       Thu Jan 25 09:25:02 2024
@@ -52,7 +52,7 @@
             zigpy_conf.CONF_DEVICE: {
                 zigpy_conf.CONF_DEVICE_PATH: ctx.obj["device"],
                 zigpy_conf.CONF_DEVICE_BAUDRATE: ctx.obj["baudrate"],
-                zigpy_conf.CONF_FLOW_CONTROL: ctx.obj["flow_control"],
+                zigpy_conf.CONF_DEVICE_FLOW_CONTROL: ctx.obj["flow_control"],
             },
             zigpy_conf.CONF_DATABASE: ctx.obj["database_file"],
         }

@puddly
Copy link
Contributor

puddly commented Jan 25, 2024

The bellows CLI isn't really maintained. The correct way to form a network is with zigpy-cli: https://github.com/zigpy/zigpy-cli#forming-a-network

@Hedda
Copy link
Contributor

Hedda commented Mar 4, 2024

@kucharskim For reference, the answer to this will probably be similar/same to answering replies here -> zigpy/zigpy#1342

@pepijndevos
Copy link

It seems it's really poorly documented how to use zigpy. Bellows CLI doesn't work, zigpy-cli doesn't have commands to actually do much beyond form a network and directs back to bellows to do packet capture, and there isn't much of any documentation how to use the zigpy library directly.

@Hedda
Copy link
Contributor

Hedda commented Mar 30, 2024

I think that it is today you need to look the ZHA integration component code inside the Home Assistent core, but it now seems like that might change in the future. Check out the links in this discussion in the main zigpy project repository:

zigpy/zigpy#1207

as well as the related requests in this open issue that is asking for application examples:

zigpy/zigpy#1087

@ghost
Copy link

ghost commented May 6, 2024

I made the suggested change above, and the 'form' seems to work :) even allowing me to set a channel (because I had warning about busy channel 25). Also the 'permit' and 'info' seem to work. But the 'devices' never exits. 2 endpoints are listed IAS_CONTROL, and then CONTROLLER. (this is a sonoff USB dongle plus stick, Model ZBDongle-E) . For the Controller it shows input clusters: Basic(0) and at that point never exits. I've been through the code best I can, and it seems like it might be scheduler locking, still looking... Anyone got further than that please? Oh and I tried the suggested zigpy cli but seems not to support any cli control of devices.

@puddly
Copy link
Contributor

puddly commented May 6, 2024

As mentioned above, the bellows CLI isn't maintained at this point because it includes a lot of duplicate functionality from zigpy-cli, which uses up-to-date interfaces and works with every radio. Other than packet capture (which can be abstracted into a generic method within zigpy), everything else is radio-agnostic and should be supported within zigpy-cli.

If you want to make a PR adding the functionality you want to zigpy-cli, that would be much appreciated. The basic application startup sequence is shown in the permit command: https://github.com/zigpy/zigpy-cli/blob/ab58a1b0c3d6e4670ab6af105e0fadc3310da2aa/zigpy_cli/radio.py#L167

@ghost
Copy link

ghost commented May 6, 2024

Probably it is already in zigpy-cli, I just cant seem to find it, or any examples. I am just looking for basic functionality to read and write device attributes via zcl, and something equivalent to the bellows 'devices' command.

@puddly puddly closed this as not planned Won't fix, can't repro, duplicate, stale Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants