-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support for legacy Nexa Bridge (aka Bridge1) #15
Comments
Thanks for trying it out! You might actually be the first :)
This might be the case, because this integration works great on my bridge. I'm going to look into this today. Would you mind sharing some data from the |
|
Ah. This integration was made for the "Bridge 2" aka "Bridge X". I don't think the "Bridge 1" responds with the same data from the API, which seems to be the case by briefly looking at one of your screenshots. Might be possible to add support though, but then we need to dig some more in order to make things compatible (and I don't have one of these). |
Maybe you could share all the data from the nodes endpoint ? Also does it have |
Added the API end points, seems like most of the api endpoints listed on the nexa official site is available. What I could not find was an automations endpoint, not sure how implemented that is yet. Since all the information on that page is swedish notes. :) |
Thanks! I looked through and it seems that the node data is mostly compatible, however it does not contain the current value(s). Maybe it's possible to get that from If so then I think I can make reading sensor data work for the legacy bridge in this integration 🤞 |
This is the result for Node Id it /1
For id 1017
|
Sweet! That's basically all that's needed to make this work. I'm going to set up a dummy API to simulate a classic bridge and then update the integration. If you want to I can drop some development builds into this issue for you to test when I have something worked out. |
Sounds good. :) |
I think I have something ready for testing now. Added a "legacy bridge" checkbox in the configuration box that changes the behaviour of this integration slightly to work with your device. |
I wonder if your device also broadcasts updates via a websocket. Currently I have it disabled because I was unsure. Would you be able to run https://github.com/vi/websocata and connect to the socket at If this is the same as on Bridge2 I can simply just re-enable. |
Fett! This looks promising. Could you paste in the full text here ? I need to see the entire message(s). |
This was the complete message when i tutned off my light. |
Hm. This doesn't look like a message from the actual switch, but some kind of power metering. The bridge can spit out quite a few messages in a row (my assumption is that metering gets triggered when a switch state is modified and the "power" comes right after the value we want), and I don't know if your app is capable of capturing that 🤔 |
Might be correct. Will check on the computer soon. |
In hindsight, I think that the message you gave was enough to work with. So I've created a new release that's ready for testing: |
Would still love to see some though 😊 |
Looks like my changes should take care of the differences in your data :) |
|
Trying to add the comment as code, but it does remove linebreaks. Dont understand what I'm doing wrong x) |
That was a silly mistake on my end... Fixed here hopefully:
You need three of those tickmarks and a newline, then end with a newline and three ticks :) I think you can click on edit on your last comment (that I edited) to see. |
Really appreciate it :) I was doing some reverse-engineering by using the Web UI that's accessible on the Bridge to when you access the IP directly. Maybe that's possible on the Bridge1 as well ? It had basic features for controls.
This is actually intentional. I wonder if I should add a config option for it. I just found it handy to have a sensor in addition to a control.
That's def not intentional. I have a couple of dimmers at home, and they only appear as a light because they don't have the "binary" capability, only "level" (i.e.: 0-100%). Theoretically that should not have any issues, but I'm going to do some investigation on my end. |
Tested by forcing my dimmers to become switches as well, and I got both 🤔 Is it somewhere in the "Entities" tab disguised as something else perhaps ? |
I exported the postman collection. NexaBridge.postman_collection.zip I see how it was now, it added the "lights" under an other group. Which only was acceptable under the right page to show. Still new to this. |
Ah, I see. It took me a while to get to grips with this as well :) |
Also, I see now that I should disable the power meter stuff so that "Nexa Bridge" card doesn't just display garbage. I tried infer the stuff from the logs you shared, but obviously I missed something there :) |
Here's without that stuff. NB: Might have to remove the entities manually now that they have data on them (and might just show unavailable from now on). Looking forward to what you find out with the controls 😁 |
Actually, I maybe think what's needed here. The |
Meanwhile I've been trying to find some information about this on the web, but there's basically zero. Even for the X bridge (which is why I even started writing a document about all of this). I'm kind of bummed about that, but figure the solution for this gotta be simple considering how similar the APIs are.
Or maybe even One thing I noticed is that Really hope it's that simple. Or even that the endpoint is called
Is this available on your device btw ? If so you can open the browser dev tools to capture network calls to easily see how it's done. If you don't know how to work with this tool I can help out (on discord or something like that even), |
Sorry for the late reply. A session in Discord or similar would probably be great at some time. Opening up the web page locally and clicking the actions. It uses the call endpoint (which is also mentioned in the API doc from Nexa). /v1/nodes/[nodeId]/call With the payload of what capability to set value to. {"cap":"switchBinary","method":"turnOn"} for a switch Funny story tho, dimming units does not appear to work from the web interface. The button on WebUI does nothing at all. Power On and off does work and calls the above. dimming switch has the following body for setting dimming level. {"cap": "switchLevel","value": 0.6} |
Ah, so there's some kind of special case for buttons here in the old API. That's so weird.
Hm. Does this work from the Nexa app ? |
Yes. It works from the app. And it works if I use postman with the payload mentioned aboved with "cap" set to switchLevel and with a value between 0 and 1 (0-100%) :) |
Just a side note, it also works from Google Home (I have tried to use Google Home) as well, but due to the high delay I want to use something not cloud based, therefor HA |
So only not from the web UI. Now that's a fun one :D Hopefully this means that it works from HA. Well, then I think there's only one thing left to fix on my end and I can make a proper release. I'll fix that right after I finish work :) |
Perfect! Will hopefully be available to do a test in the evening if you get a RC ready. |
Here's a release with the methodCall stuff implemented: |
Retrying setup: 'NexaEnergy' object has no attribute 'populate_legac' Seems like something not working. Tried to just change it to populate_legacy and got a different error then.
|
Oh.... looks like I forgot to commit something on my home computer yesterday. I'm on the go 😅 This should fix that: |
Well. It is working, not 100% reliable. Some calls not going through, and with a high latency. Will try to dig into this further once I get home. Sitting at work and remoting to home computer. |
Might be worth looking into increasing the poll interval defined in the const file if it's a case of too many open connections on the bridge / congestion. I'm contemplating increasing it in general because theoretically the websocket should broadcast all of the required updates. |
I'm just wondering about one thing (relating to the methodCall differences)... do the Nexa and Zwave switches behave the same ? I see you have both. Do the switches on/off use the turnOn/turnOff in both cases in the Web UI ? |
Ignore this. It actually works on Bridge2 as well (backward compatible) :) |
Nexa dimmer and Z-wave dimmer works the same in HA. Works on first try, but trying to do successive changes makes the device go unavailable before coming back to life. Could perhaps give you some access, can be found on discord |
After inspecting Mr @biodland's instance I've come to the following conclusion:
And at the same time:
|
All of this has now been released: https://github.com/andersevenrud/ha-nexa-bridge-x/releases/tag/v1.1.0 Thank you so much for your time digging into this! Integration for the Bridge1 is pretty much complete with exception of this: #19 🎉 If you experience some issues following this release, feel free to open a new issue :) |
Trying to add this to my Nexa bridge, but seems to not be working.
Getting invalid authentication.
Have probed the device with Postman and in Chrome and the API's are exposed.
Been looking briefly into code and seems like the issue lies in the basicauth part, as per documentation of Nexa API it states the requirement of digest auth.
https://nexa.se/docs/
general
For the local connection, the auth is a simple HTTP Digest Auth. Username and password is nexa. Always use the prefix /v1 before any API-call. For example, http://192.168.1.12/v1/nodes.
And doing a simple test in postman shows that using basicauth will not work, and changing to digestauth works.
If this is a difference between Nexa Bridge X and the older Nexa Bridge I'm not aware. Could not find a simple way to use digestauth in the same modules. And due to lack of python experience this gets overwhelming fast. :)
The text was updated successfully, but these errors were encountered: