Giter VIP home page Giter VIP logo

Comments (20)

manup avatar manup commented on July 20, 2024 1

Hello Steve,
to enable the debug output you can use the commandline switch --dbg-<type>=<level>

Where type can be error, info, aps, zdp, zcl, zcldb, http. The level parameter defaults to 0 (no debug output) and can be set up to 2.

The debug output can be quite noisy :)

from deconz-rest-plugin.

manup avatar manup commented on July 20, 2024

Hi sjlb197, did you already got the thermostat to join the RaspBee network?

Since you already use the REST API I would recommend to clone the repository and extend the API with the needed thermostat functionality. For example by implementing a /thermostats endpoint in the same way the /lights endpoint was done. Be aware that the REST API plugin is written with help of the deCONZ C++ API.

I'm not sure how complex the thermostat interface is (clusters/commands/attributes) but if only reading out data like temperature is needed it should be fairly easy todo.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi manup,

Yes, I have got the thermostat to join the RaspBee network, although it cannot control it at the moment. I am waiting for a firmware update on the thermostat, and this may be the cause of not being able to control it. I have also seen some more detailed instructions on one of the other issues here on GitHub about how to setup a network for HA profile devices - I will try going through that also.

The thermostat supports the thermostat cluster (0x0201) and the temperature measurement cluster (0x0402), as well as on/off (0x0006). I will need to send target temperature values to the thermostat, as well as on/off, and will also need to set attribute reporting for the measured temperature attribute. I agree that this should be reasonably easy to achieve.

Many thanks for your advice.

Steve

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

I actually have some follow-on questions please. I am able to compile the REST API, either using the provided makefiles and command (qmake-qt4 && make), or by opening the project in Qt Creator and building from there.

My questions are:

  • Does this process build libde_rest_plugin.so?
  • If so, where does it go?
  • Will deCONZ automatically pick up this new shared object?
  • Can I build a standalone application using the C++ API that will talk to the RaspBee without deCONZ running?

Many thanks in advance!

Steve

from deconz-rest-plugin.

manup avatar manup commented on July 20, 2024

Hi Steve, the following answers should shed more light on the plugin build process.
The build documentation of the plugin will be updated soon to add the missing instructions.

  • Does this process build libde_rest_plugin.so?
  • If so, where does it go?
  • Will deCONZ automatically pick up this new shared object?

After building the plugin with the commands qmake-qt4 && make the the original libde_rest_plugin.so file has to be replaced.

# create a backup of the original plugin
$ cp /usr/share/deCONZ/plugins/libde_rest_plugin.so libde_rest_plugin.so.bak

# replace original plugin 
$ sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins/libde_rest_plugin.so

After restarting deCONZ the new plugin will be loaded automatically.

Can I build a standalone application using the C++ API that will talk to the RaspBee without deCONZ running?

Right now it's not possible to build a standalone application without the deCONZ GUI running. However a headless lightweight version of deCONZ shall address this. There is no fixed release schedule for the headless version set but it should be available later this year.


The thermostat supports the thermostat cluster (0x0201) and the temperature measurement cluster (0x0402), as well as on/off (0x0006). I will need to send target temperature values to the thermostat, as well as on/off, and will also need to set attribute reporting for the measured temperature attribute.

Related to the thermostat and ZCL attribute reporting you may refer to the secion 7.2.3 configure attribute reporting of the deCONZ user manual since you can setup reporting without writing code.

  • create a ZigBee binding from a thermostat temperature cluster (source) to deCONZ HA endpoint (destination) via deCONZ binding dropbox
  • setup attribute reporting in the ZCL attribute editor of the cluster info panel (double click on a attribute)

The UI will update automatically the attribute table after reception of a ZCL attribute report.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi Manuel,

Again, many thanks for your reply.

I have copied the new shared object as you described; I seem to now have two menu entries for the REST api in deCONZ. One item opens the old app, and the other opens the new app (I made a trivial change to add a label to the widget, so that I can see which version it is, old or new).

I also tried making a change that would be visible over http. I changed the port number to 8082, and changed the RaspBee-GW name. When I try to connect using my web browser, I cannot connect on 8082, only 8081 which is what I provide with the --http-port option to deCONZ. Also I only see the old name RapBee-GW.

I would guess that this is because deCONZ is somehow picking up the original shared object from somewhere, and cannot connect to two different objects, so I just see the original behaviour.

Do you know what might be causing these problems?

Apologies if my explanation isn't very clear. Please let me know if I need to clarify anything.

Many thanks, and regards,

Steve

from deconz-rest-plugin.

willem4ever avatar willem4ever commented on July 20, 2024

Hi Steve, Did you remove the old library from /usr/share/deCONZ/plugins/ I initially did a rename of of the old library but it was still loaded. A move to another directory resolved the problem for me.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi Willem,

Ah, OK. No, I have only renamed. I'll move to another directory.

Many thanks.

from deconz-rest-plugin.

manup avatar manup commented on July 20, 2024

Thats true the original library has to be either removed or replaced because deCONZ will just load everything from the plugins directory on startup.

Also note that the --http-port commandline parameter controls the port of the http server which is running directly in the deCONZ application. The REST plugin contains only a handler for HTTP requests not the server itself. The idea is to support multiple plugins/handlers which can share the same HTTP server.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

I can confirm that indeed moving the old .so rather than just renaming fixes the issue. Thank you.
I had realised that the things I'd tried changing (http-port and RaspBee-GW) name don't seem to have an effect on the api behaviour. I have now managed to change the behaviour of the /lights part of the api, so I know that my version is being correctly picked up.

It's just going to take me a little while to work out how to add similar /thermostats functionality (I just get a 404 error at the moment). I'll keep working on that.

Many thanks for your advice and input.

Steve

from deconz-rest-plugin.

manup avatar manup commented on July 20, 2024

The --http-port=<port> parameter should work, but note that the port has to be > 1024. That is a Linux restriction for userspace programs.

The reason why the RaspBee-GW name does not change is because the name and other configuration parameters are stored in a sqlite3 database file. The name can be changed either via REST API or in the WebApp.

Youre welcome if you have anymore questions always feel free to ask :)
The documentation for the plugin is quite limited at the moment but there will be more content added over time.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi Manuel,

Yes, the --http-port command line option does work. I was trying to override in the plugin source code, only to be able to show that the correct shared object had been picked up. But I've shown that now so that's fine.

I do have another question please: I noticed that debug prints are present in the code, and I think these would be useful. By running strings on the deCONZ executable I noted that there are --dbg* options (don't remember the details off the top of my head now). I tried adding some including --dbg-info (having built the debug version of the plugin), but I don't see any messages. Should I expect this to work or does it also require a debug build of deCONZ?

Many thanks,

Steve

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi Manuel,

Ah of course, thank you. I'm quite used to looking at noisy debug output so that should be fine. I'll start off by making it noisier anyway :-)

Work is keeping me quite busy at the moment, but hopefully I'll get a little time to look at this as well.

Many thanks.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi Manuel,

Just taking a quick look at this now, now that I have the debug logging turned on (http and info to 2) it looks like my HTTP GET isn't getting as far as the plugin.

For a GET request to /api//lights I see an "HTTP API GET" debug message.
For a GET request to /api//thermostats I see an "HTTP client GET" debug message, and no API debug message.

The 404 response my REST client receives is the "This is not the page you are looking for" response.

Do you think I'm correct in my analysis (that the response I get for /thermostats is generated by deCONZ, not the plugin)?

For now I'll try adding to the /lights endpoint instead.

Many thanks,

Steve

from deconz-rest-plugin.

manup avatar manup commented on July 20, 2024

Hi Steve,

have a look into the file de_web_plugin.cpp, I guess the HTTP request is filtered. Did you already add it to the DeRestPlugin::isHttpTarget(...) method?

After a request passes the filter it shall be handled in the broker method DeRestPlugin::handleHttpRequest(...) by forwarding it to a handleMyApi(req, rsp) method.

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

Hi Manuel,

No, indeed you are correct I didn't add it to the isHttpTarget method. Many thanks for the pointer.

Steve

from deconz-rest-plugin.

ktching avatar ktching commented on July 20, 2024

Hi Steve & Manuel,

I'm reading your convo with much interest as I just got my Raspbee. Works with deCONZ REST API plugin nicely.

However, I am also looking to extend the API beyond just lights to switches, motion sensors and door sensors.

I have to admit it felt hopeless until I chanced upon this thread. Looks like it's possible!

Was wondering if there is some documentation available somewhere with step-by-step guide? Many thanks in advance!

Regards,
Keith

from deconz-rest-plugin.

danieljkemp avatar danieljkemp commented on July 20, 2024

Hi Steve,

Your last update made it look like you were just one step away from a functional addition. any chance you could submit a pull request? Even if it wasn't accepted the changes would be listed and it would be a great help to people looking to add functionality!

from deconz-rest-plugin.

sjlb197 avatar sjlb197 commented on July 20, 2024

from deconz-rest-plugin.

manup avatar manup commented on July 20, 2024

Closing the oldest issues for know to tidy up the tracker and duplicates in newer issues.

from deconz-rest-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.