madchicken / comelit-client

Simple CLI to interact with Comelit HUB, Vedo and Comelit Serial Bus
Apache License 2.0
23 stars 6 forks source link

compatibility with serial bridge 20090334 #23

Closed megamarco833 closed 2 years ago

megamarco833 commented 2 years ago

hi, do you know if the CLI is also compatibile with serial bridge version 20090334 ?

https://pro.comelitgroup.com/product/20090334 (version without SD card)

thanks

madchicken commented 2 years ago

Yes, it is. Just use the comelit-sb-client command

megamarco833 commented 2 years ago

comelit-sb-client

Yes, it is. Just use the comelit-sb-client command

thanks for reply, i'm asking because looking and the readme.md it linked: comelit-sb - a CLI to interact with comelit Serial Bridge (https://pro.comelitgroup.com/product/20003101) but this serial bridge has the SD card, i fund an old 20090334 that is without the SD card support: https://pro.comelitgroup.com/product/20090334 so i'm wondering if buy this one or not :) thanks for support

p.s. i don't see the command comelit-sb-client documented inside the readme is specific for this model of serial bridge?

madchicken commented 2 years ago

Ok, then I don't know. If this serial bridge has a web interface like the other one, then it should be compatible, but it's still uncertain. Regarding the documentation: you are right, I forgot about it, since I have the HUB and I focused on the newer model. They are very similar tho, and you can launch the command and read the help

megamarco833 commented 2 years ago

Ok, then I don't know. If this serial bridge has a web interface like the other one, then it should be compatible, but it's still uncertain. Regarding the documentation: you are right, I forgot about it, since I have the HUB and I focused on the newer model. They are very similar tho, and you can launch the command and read the help

Looking at on line comelit documentation it seams that graphics of this two serial bridge looks like different. But i think that also the serial bridge with sd card and comelit hub has different web graphics, right? There is something that i can check inside comelit documentation before buy the version without the SD card to check the compatibility with your scipt?

madchicken commented 2 years ago

Looking at on line comelit documentation it seams that graphics of this two serial bridge looks like different. But i think that also the serial bridge with sd card and comelit hub has different web graphics, right? There is something that i can check inside comelit documentation before buy the version without the SD card to check the compatibility with your scipt?

Unfortunately not much...you should check if the API is compatible (i.e. the same)

megamarco833 commented 2 years ago

Looking at on line comelit documentation it seams that graphics of this two serial bridge looks like different. But i think that also the serial bridge with sd card and comelit hub has different web graphics, right? There is something that i can check inside comelit documentation before buy the version without the SD card to check the compatibility with your scipt?

Unfortunately not much...you should check if the API is compatible (i.e. the same)

sorry for asking, but where you find the API for serial bridge? ps. right now i don't have any serial bridge, but i find an old one (version without SD card) so i'm wondering if buy this or not to upgrade my actual simplebus comelit domotica :)

megamarco833 commented 2 years ago

short update: i wrote to comelit support, and they reply that both serial bridge doesn't support any API (the one with SD card and the other one without SD card) so, sorry for asking, but are you sure that the serial bridge can work with the API and your code? do you physically tested? many thanks for your kindness and for your support!!!!!!

madchicken commented 2 years ago

Yes, I physically tested it: there is a web UI and they expose some JSON endpoint. It's not a real API, is just the way it works. I used it to write my client

megamarco833 commented 2 years ago

understand, thanks for feedback. so in the end i should check if the bridge without the SD (that i see on the documentation that has a web ui)

report some json when i use the web ui to activate some devices, correct? how you discovered the JSON that the web ui expose? immagine

https://staticpro.comelitgroup.com/storage/2018/01/496/2G40000468.pdf

thanks again

megamarco833 commented 2 years ago

Yes, it is. Just use the comelit-sb-client command

hi sorry for disturbing, finally i bought the serial bridge, but if i use this command i receive an error:

pi@raspberrypi:~ $ comelit-sb-client -h 192.168.0.252 -p 80 lights --list
-bash: comelit-sb-client: command not found

if i try:

pi@raspberrypi:~ $ comelit-sb -h 192.168.0.252 -p 80 lights --list
Executing command lights - {"_":["lights"],"h":"192.168.0.252","host":"192.168.0.252","p":80,"port":80,"list":true,"$0":"comelit-sb"}
(node:30644) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
    at createError (/usr/lib/node_modules/comelit-client/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/lib/node_modules/comelit-client/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/usr/lib/node_modules/comelit-client/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:30644) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:30644) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
pi@raspberrypi:~ $ comelit-sb -h 192.168.0.252 -p 80
comelit-sb <command>

Commands:
  comelit-sb rooms     Get the list of all rooms in the house
  comelit-sb lights    Get the list of all lights in the house
  comelit-sb outlets   Get the list of all outlets in the house
  comelit-sb shutters  Get the list of all shutters in the house
  comelit-sb clima     Get the list of all thermostats/clima in the house

Options:
  --version   Show version number                                      [boolean]
  --host, -h                                                 [string] [required]
  --port, -p                                              [number] [default: 80]
  --help      Show help                                                [boolean]

Not enough non-option arguments: got 0, need at least 1

it seams that it's working the version command:

pi@raspberrypi:~ $ comelit-sb -h 192.168.0.252 --version
2.3.5

but not comelit-sb-client command

madchicken commented 2 years ago

Sorry, the correct command is comelit-sb, indeed. Regarding the output, seems the endpoint the client is trying to contact does not exist (404 error means "not found"). Are you able to use some sort of web UI to control your devices?

megamarco833 commented 2 years ago

Sorry, the correct command is comelit-sb, indeed. Regarding the output, seems the endpoint the client is trying to contact does not exist (404 error means "not found"). Are you able to use some sort of web UI to control your devices?

yes, correct it seams that the bridge not respond, but it is working in web UI maybe could be an issue related to password? if i use firefox when i enter inside web UI it ask me about userID and passsword. immagine

anyhow this is a webpage related to light, and if i click at one icon it trigger the light and it change physically its status, so it seams that the bridge is working. immagine

what i should do? thanks

p.s. how you discover what are the Json command status?

madchicken commented 2 years ago

Ok, it seems your version uses Basic Authentication. I will provide you a new version where you can specify the user and password to access the UI

megamarco833 commented 2 years ago

thanks so much for that! i really appreciate it.

just to understand what's the commands that you send to trigger the light? i try to discover them using firefox debug mode, and i see: http://192.168.0.252/user/luci.cgi?luce=16 where 192.168.0.252 is the IP of serial bridge and 16 is the number of the light on web UI but i not understand what is the command to trigger it on / off

i also see a webpage xml where it's reported the status of the light: immagine

for example here you can see that the 16th position is 0 => so it means that light number 16 is OFF

madchicken commented 2 years ago

I see this version uses XML to communicate, while the other is using JSON. This is an issue since the client I wrote does not support XML. It should not be difficult to add the support to XML but is definitely more complicated than adding Basic Authentication support...

megamarco833 commented 2 years ago

hi, yes, it seams a different way to communicate. mine "old" bridge is publishing on xml web page the status. For example lights status are published on luci.xml, blinds status are published on automzioni.xml, temperature are on termo.xml the commands to toggle a light number 18 is: http://userID:PASSW@IP_ADDR/user/luci.cgi?luce=18 command for blind number 3 up is: http://userID:PASSW@IP_ADDR/user/automazioni.cgi?command=0&tapp=3 command for blind number 3 down is: http://userID:PASSW@IP_ADDR/user/automazioni.cgi?command=1&tapp=3

are these different from your serial bridge version with SD card?