deconz icon indicating copy to clipboard operation
deconz copied to clipboard

Getting started with pydeconz

Open markicos opened this issue 4 years ago • 12 comments

hello there,

i am trying to implement a python code in order to connect a usb Conbee II, to some sensors, but i don´t see any getting started doc or similar.

Looking at the code i can see that all I want to implement in my code is possible, except to search new devices, where can I find more information about it?

Thanks a lot for you work

markicos avatar Feb 15 '21 10:02 markicos

Rest API documentation: https://dresden-elektronik.github.io/deconz-rest-doc/endpoints/configuration/

Make a new method similar to initialize which calls request with

await self.request("put", "/config/", json={"permitjoin": 60})

Note this is untested and might not work

https://github.com/Kane610/deconz/blob/c89a33b0f72216567209a8cab1e0ebd65111d1d6/pydeconz/gateway.py#L66

Kane610 avatar Feb 15 '21 16:02 Kane610

Thanks it was a very useful help,

Now i am facing a problem, I am trying to use the basic authentification, but it is reporting always user and password is not recognized. I saw in your main.py that you comment the user and pass in kw, have you had problems with it?

https://github.com/Kane610/deconz/blob/c89a33b0f72216567209a8cab1e0ebd65111d1d6/pydeconz/main.py#L39

Later I tested to get into Conbee II thought Web App I am getting always an error: image

I am using the same pass than in Phoscon APP where I have no problem. I am doing something wrong...

markicos avatar Feb 16 '21 18:02 markicos

I should probably improve the main a bit :), what you should do is generate an api key https://github.com/Kane610/deconz/blob/c89a33b0f72216567209a8cab1e0ebd65111d1d6/pydeconz/utils.py#L13

In Phoscon you should open up for pairing of third party applications and then use the async_get_api_key function

Kane610 avatar Feb 17 '21 06:02 Kane610

I was expecting not to use the pairing :(, but in any case thanks a lot...

markicos avatar Feb 17 '21 07:02 markicos

If you get your credentials right it's just a matter of altering this line with the basic auth parts from async_get_api_key, unfortunately I stopped using the credentials a couple of years ago but it should still work

https://github.com/Kane610/deconz/blob/c89a33b0f72216567209a8cab1e0ebd65111d1d6/pydeconz/gateway.py#L99

Kane610 avatar Feb 17 '21 07:02 Kane610

Thanks, I think the problem is the user not the password, but don't know how to get the proper one, I will keep you updated in any case.

markicos avatar Feb 17 '21 09:02 markicos

You will laugh, the default user and password was the ones in your main code, both are delight , I though it was something you set previously, i am getting the apikey without problems.

Thanks a lot

markicos avatar Feb 17 '21 16:02 markicos

You will laugh, the default user and password was the ones in your main code, both are delight , I though it was something you set previously, i am getting the apikey without problems.

Thanks a lot

Great! It was so obvious I didn't think I'd need to ask the question 😂

Kane610 avatar Feb 17 '21 16:02 Kane610

Hello,

I have one more question, is it mandatory to run up the deconz software to use the discovery function?, as if i have not this software running i am having allways "[ ]" as response.

markicos avatar Feb 24 '21 09:02 markicos

No the discovery function is a helper function in cases where you don't have full knowledge of the system or want to provide a better user experience

Kane610 avatar Feb 25 '21 18:02 Kane610

Hi, Where I can find some sample code to get me started. It would be great to put it in README doc for other to use this package. I could create something like that if you are OK with it. I now have API key and can connect to my gateway check sensors etc, but wondering how I could use your code. Please advise. Thanks

voytecPL avatar Feb 27 '21 20:02 voytecPL

Hi, Where I can find some sample code to get me started. It would be great to put it in README doc for other to use this package. I could create something like that if you are OK with it. I now have API key and can connect to my gateway check sensors etc, but wondering how I could use your code. Please advise. Thanks

Feel free to contribute 👍🏻

I think improving the main file is a good way to show case how to set up the basics of the integration. I can probably do that within the next few days.

If you want to delve deep into it everything is done to work with Home Assistant so you can look at the deconz integration to get inspiration. https://github.com/home-assistant/core/tree/dev/homeassistant/components/deconz

Kane610 avatar Feb 27 '21 20:02 Kane610