zigpy / zigpy-cli

Command line interface for zigpy
GNU General Public License v3.0
44 stars 12 forks source link

zigpy-cli - socket interface #7

Closed mdeweerd closed 1 year ago

mdeweerd commented 2 years ago

Just a suggestion - add a daemon mode with a socket interface.

The socket interface would accept the same commands as the CLI but without addint the call to zigpy or the radio setting.

So the daemon could be started like this:

zigpy radio znp /dev/ttyUSB0 daemon --host 127.0.0.4 --port 3400

And then connections can be made to port 3400 to send commands, using telnet, netcat or whatever.

Example:

telnet 127.0.0.4 3400

Then inside the telnet session:

network info

The parsing of the commands would remain the same as on the cli, but then the tool would have a broader range of uses and the zigpy session can keep on running without requiring reinitialisation, potentially reporting incoming messages as well.

puddly commented 2 years ago

You may be interested in @dmulcahey's https://github.com/zigpy/zha-websocket-server/ (and ZHA WS itself https://github.com/dmulcahey/home-assistant/tree/dm/zha-ws) as a basis for such a tool. Its command line client currently is just thin frontend for sending JSON but building an alternative CLI with asyncio-native python-prompt-toolkit seems very doable in the future.

Once the low-level network information PRs are done, adding backup/restore to ZHA WS (and things from https://github.com/mdeweerd/zha-toolkit/!) will be very easy.

dmulcahey commented 2 years ago

@mdeweerd any interest in working on this with us? It may eventually replace ZHA entirely.

mdeweerd commented 2 years ago

I am really busy on quite a few projects. I can easily put in some brain power, but not too much coding. I have put some effort into the project to help it go forward, and because I can use some of it.

Hedda commented 1 year ago

You may be interested in @dmulcahey's https://github.com/zigpy/zha-websocket-server/ (and ZHA WS itself https://github.com/dmulcahey/home-assistant/tree/dm/zha-ws) as a basis for such a tool. Its command line client currently is just thin frontend for sending JSON but building an alternative CLI with asyncio-native python-prompt-toolkit seems very doable in the future.

Once the low-level network information PRs are done, adding backup/restore to ZHA WS (and things from https://github.com/mdeweerd/zha-toolkit/!) will be very easy.

Noticed PR https://github.com/home-assistant/core/pull/88564 with work on HA's ZHA network settings API and that reminded me of question about the websocket server project, so wondering what the current planned roadmap/status is for zha-websocket-server and ZHA WS itself?

Hedda commented 1 year ago

You may be interested in @dmulcahey's https://github.com/zigpy/zha-websocket-server/ (and ZHA WS itself https://github.com/dmulcahey/home-assistant/tree/dm/zha-ws) as a basis for such a tool. Its command line client currently is just thin frontend for sending JSON but building an alternative CLI with asyncio-native python-prompt-toolkit seems very doable in the future. Once the low-level network information PRs are done, adding backup/restore to ZHA WS (and things from https://github.com/mdeweerd/zha-toolkit/!) will be very easy.

Noticed PR home-assistant/core#88564 with work on HA's ZHA network settings API and that reminded me of question about the websocket server project, so wondering what the current planned roadmap/status is for zha-websocket-server and ZHA WS itself?

Bump this question now that https://github.com/home-assistant/core/pull/88564 (ZHA network settings API) has been merged into Home Assistant core.

mdeweerd commented 1 year ago

@Hedda Thanks for keeping this Issue up-to-date.

This is for sure a nice addition to ZHA, however my suggestion was really related to Zigpy itself when it is launched independently from ZHA.

mdeweerd commented 1 year ago

Closing this - not very recent, not the main usage of the cli I think.