Forums : OpenHAB to OpenRemote HTTP REST Issues
This page last changed on Nov 02, 2015 by nwootton.
I'm currently using OR as the controller for my AV kit, with OpenHAB being used to control the other aspects of my home. Now that both systems are stable and working as I expect, I'm trying to integrate some of the OpenHAB controls into the OR interface to improve the experience for the rest of the household.
I can create individual buttons in OR to send OpenHAB On & Off commands for devices via the HTTP REST API - a simple POST for each. However, what I need to do is get the current state returned from OpenHAB so I can populate a sensor and then use either use a single switch (toggle) or at least give some kind of indication (text label) that the device has been switched.
OpenRemote is currently running in a Docker container @ 192.168.1.152:8093.
In OR I can turn the device on or off with a POST to OpenHAB at http://192.168.1.153:8080/rest/items/Light_GF_Lounge_TrolleyLamp/. Setting the body/data/payload to content type of 'text/plain' and the actual content to be either ON or OFF. This works fine - my test lamp goes on and off.
Trying to get the status is proving to be an issue. Using the REST API in OpenHAB I can successfully make a call from either the browser or from a tool like Postman to GET the specific state of the item:
http://192.168.1.153:8080/rest/items/Light_GF_Lounge_TrolleyLamp/state —> this will return a plain text of either ON or OFF
But nothing is being shown in OR. I have tried both normal switches and custom ones (with either ON/OFF specified or left empty). As the sensor isn't being populated, I can turn stuff ON with a switch, but the state never changes, so it doesn't allow me to turn it OFF again.
I have tried using the XML information for the entire object and then using Xpath to query the state attribute. I have tried using the same information in JSON format and then using JSONPath to retrieve the state. With the Content-Type has been altered accordingly. I have tried changing the polling time. I have tried just using a text label on screen to see if anything comes back - all I get is either 'N/A' or 'label text' being displayed.
OpenHAB event logs tell me that the calls are being made and that they are succeeding - HTTP Code 200, but nothing happens in the OR interface. I even tried it across an iPad, iPhone and an Android tablet just in case it was an issue with the OR software for the specific device.
What am I missing? Anyone have any suggestions of other things I can try?
Screen Shot 2015-10-28 at 13.43.10.jpg (image/jpeg)
|Document generated by Confluence on Jun 05, 2016 09:33|