Skip to content
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

Extending to full HA profile #5

Closed
sjlb197 opened this issue Feb 25, 2014 · 20 comments
Closed

Extending to full HA profile #5

sjlb197 opened this issue Feb 25, 2014 · 20 comments

Comments

@sjlb197
Copy link

sjlb197 commented Feb 25, 2014

This isn't an issue, so my apologies if this isn't the correct place to raise this question.

I would like to use my RaspBee module to control HA profile thermostatic radiator valves (thermostat and temperature measurement clusters). I'm using OpenRemote at the moment to communicate over the REST API to deCONZ, and so I have a question about how best to communicate with my radiator valves.

Am I going to be able to extend the REST API to support my devices, or might I be better off using the C++ API to deCONZ?

Many thanks in advance for any assistance.

@manup
Copy link
Member

manup commented Feb 28, 2014

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.

@manup manup added the question label Feb 28, 2014
@sjlb197
Copy link
Author

sjlb197 commented Mar 1, 2014

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

@sjlb197
Copy link
Author

sjlb197 commented Mar 5, 2014

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

@manup
Copy link
Member

manup commented Mar 6, 2014

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.

@sjlb197
Copy link
Author

sjlb197 commented Mar 9, 2014

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

@willem4ever
Copy link

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.

@sjlb197
Copy link
Author

sjlb197 commented Mar 9, 2014

Hi Willem,

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

Many thanks.

@manup
Copy link
Member

manup commented Mar 11, 2014

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.

@sjlb197
Copy link
Author

sjlb197 commented Mar 11, 2014

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

@manup
Copy link
Member

manup commented Mar 11, 2014

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.

@sjlb197
Copy link
Author

sjlb197 commented Mar 17, 2014

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

@manup
Copy link
Member

manup commented Mar 20, 2014

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 :)

@sjlb197
Copy link
Author

sjlb197 commented Mar 23, 2014

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.

@sjlb197
Copy link
Author

sjlb197 commented Mar 23, 2014

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

@manup
Copy link
Member

manup commented Mar 26, 2014

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.

@sjlb197
Copy link
Author

sjlb197 commented Mar 29, 2014

Hi Manuel,

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

Steve

@ktching
Copy link

ktching commented May 28, 2015

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

@danieljkemp
Copy link

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!

@sjlb197
Copy link
Author

sjlb197 commented Dec 19, 2015 via email

@manup
Copy link
Member

manup commented Sep 17, 2018

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

@manup manup closed this as completed Sep 17, 2018
manup pushed a commit that referenced this issue Jan 12, 2020
Merge pull request from dresden-elektronik/master
manup pushed a commit that referenced this issue Oct 15, 2020
manup pushed a commit that referenced this issue Nov 15, 2020
Update code with last official version
manup pushed a commit that referenced this issue Jan 12, 2021
mdolnik added a commit to mdolnik/deconz-rest-plugin that referenced this issue Mar 1, 2021
…an event for Button 1 for any button pressed.

This switch has a situation where it sends the same endpoint/cluster/command ID for every button pressed and only makes the distinction between buttons via payload value.

The current logic in `DeRestPluginPrivate::checkSensorButtonEvent()` currently does not support this type of distinction, and the button map (field dresden-elektronik#5) only seems to support the first digit of the payload value and not the full payload value.

Therefore all of the information that distinguishes between the buttons ends up being ignored and the button events are being sent as the first mapped entry (button 1).

This commit changes the logic within `DeRestPluginPrivate::checkSensorButtonEvent()` to allow the value of the button pressed to be modified once a valid mapped entry has been found, and adds specific logic for the Eria Adurosmart Wireless Dimming Switch to change the button value based off of the payload value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants