I’m trying to subscribe to REST API bt can’t get it working fro sitemap.
It works fine for items and groups, but absolutely nothing happen whit sitemap.
I try different URL, which works fine in a web browser, but nothing happen when items are updated.
I use client side javscript. Here after are my simple test files :
OH is version 1.8 build 1106 (which works fine for about 2,5 years and differents upgrades ).
I certainly missing something…
Any help really appreciated.
Gilles
widgets.sitemap
sitemap Dashboard label=“Test” {
Frame label=“Frame 1” {
Text item=EnergyUsagePercent label=“Electricity [%d%%]”
}
}
subscribe.js
function subscribeWebsocket_DEBUG(URL) {
var wsSocket = new WebSocket(URL);
wsSocket.onopen = function()
console.log("OPEN: wsSocket.onopen: "+URL);
wsSocket.onmessage = function(evt)
console.log("MESSAGE: wsSocket.onmessage: \n"+evt.data + "\n\n");
wsSocket.onclose = function(evt)
console.log("CLOSED: wsSocket.onclose: "+URL);
wsSocket.onerror = function(error)
console.log("ERROR: wsSocket.onerror: "+URL);
}
function subscribeItems() {
// Works fine
subscribeWebsocket_DEBUG(“ws://192.168.1.1:8080/rest/items/EnergyUsagePercent” + “?Accept=application/json”);
// Doesn't work
subscribeWebsocket_DEBUG("ws://192.168.1.1:8080/rest/sitemaps/Dashboard" + "?Accept=application/json");
// Message in openhab.log:
//[WARN ] [.w.protocol.SimpleHttpProtocol:152 ] - Status code higher or equal than 400. Unable to deliver the websocket messages to installed component. Status 404 Message Not Found
subscribeWebsocket_DEBUG("ws://192.168.1.1:8080/rest/sitemaps/widgets/Dashboard" + "?Accept=application/json");
//[WARN ] [o.u.i.items.ItemUIRegistryImpl:471 ] - Cannot find page for id 'Dashboard'.
}
log message, when it works
MESSAGE: wsSocket.onmessage:
{“type”:“StringItem”,“name”:“EnergyUsagePercent”,“state”:“15”,“link”:“http://192.168.1.1:8080/rest/items/EnergyUsagePercent”}