Problem:
Not able to provide an URL with JSON payload to achieve a custom content on the Lametric TIME via the Lametric App My Data (DIY)
It is stated that this has to be done " 1. Expose your data to some URL available in the same local network with the device in predefined JSON format (more about that below)." But i couldn’t find any source where and how it was achieved with OpenHAB3 and maybe the HTTP binding in specific the configuration of the HTTP Thing.
Circumstances:
OpenHABian 3 installation on RPi3
Lametric TIME in the same local network
HTTP binding installed
Ideas:
Creating a thing and maybe channel in the HTTP binding. But i already don’t know what to put for the “Basis-URL”. The IP of the Lametric or OpenHAB or something totally different?
And i would maybe use “sendHttpPostRequest” in a rule to POST a JSON payload to an URL.
rule "Update My Data DIY"
when
Item PostHTTP received command ON
then
val String URL = "http://192.168.178.91/jsonmydata"
var String contenttype = "application/json"
var String jsondata = '{"frames" : [ {"icon": "794","text": "Hello!"}]}'
sendHttpPostRequest(URL, contenttype, jsondata)
end
But here i get the following error
2023-03-23 16:37:32.407 [INFO ] [core.model.script.Update My Data DIY] - {
"errors":[
{
"message":"Authorization is required"
}
]
}
The http binding will not help you. It is used to do POST/GET requests to a http server.
The Lametric would like to access an URL to download the JSON response from that server.
Sorry, forgot to tell you to setup Lametric DIY App, you have to enter url: http://your_openhab_ip:8080/static/lametric.json
No HTTP binding needed, Lametric App will read json file exposed by rules
My path naming seems to be different “\192.168.178.232\openhab\etc” from yours “…/etc/openhab/”. Is this still the right path?
I couldn’t add a JSON file there but only under “\192.168.178.232\openHAB-userdata\etc” i created a folder “html” manually because it wasn’t there and added “lametric.json” file. The folder structure appeared shortly under the other path. The JSON file has the content:
Is there some possibilty to check if the file is at least accessible like by putting the URL in the browser or similar? Because if i try that i get this:
Looks like you access the folder via the samba share from a windows host ?
As long as you see directories items, things, rules and others next to html then you are in the right directory. Change into the html directory. In case you can’t write here you are not connected with correct user permissions.
This is the wrong directory. It is a different one ( /var/lib/openhab/etc vs. /etc/openhab/ ).
I think there is no html directory.
Are you able to login using ssh / putty as user openhabian ?
Then you should be able to move the file from folder /var/lib/openhab/etc to /etc/openhab/html.
Yes i use the access over the mounted network drive over windows.
As long as you see directories items, things, rules and others next to html then you are in the right
That was a good hint because the path then for me is: \192.168.178.232\openHAB-conf\html
I just copied the “lametric.json” file with the content which i mentioned above to this folder and…