I have a solution for you (if I am not too late and you bought already a Shelly

):
- Create a getvalue.html file and copy the code into this file.
- Save this getvalue.html file in domoticz/www/views
- Change the line with $.domoticzurl="http://<IP-of-server>:<port>"; to the correct IP adress and port of your domoticz server
- Use the following link http://<IP>:<port>/views/getvalue.html?idx=xxx&type=yyy to get the requested value as plain text (as requested by OpenWB)
idx is the idx number of the device
type (case sensitive!) is the type of the requested value from the json of your idx device (http://<IP-of-server>:<port>/json.htm?type=devices&rid=idx) like from below example :
type=Data will give 3.14 (the data is cleaned by the html file)
type=BatteryLevel will give 255
If the page cannot read a value due to for example type error it will give the value ??
So for below example device 113 to get the value Data you should enter the following link http://<IP-of-server>:<port>/views/getvalue.html?idx=113&type=Data
example json of idx 113:
Code: Select all
{
"ActTime" : 1614199414,
"AstrTwilightEnd" : "20:01",
"AstrTwilightStart" : "05:43",
"CivTwilightEnd" : "18:44",
"CivTwilightStart" : "07:00",
"DayLength" : "10:37",
"NautTwilightEnd" : "19:23",
"NautTwilightStart" : "06:21",
"ServerTime" : "2021-02-24 21:43:34",
"SunAtSouth" : "12:52",
"Sunrise" : "07:34",
"Sunset" : "18:10",
"app_version" : "2020.2 (build 12901)",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "3.14 Watt",
"Description" : "",
"Favorite" : 0,
"HardwareDisabled" : false,
"HardwareID" : 8,
"HardwareName" : "ZiGate",
"HardwareType" : "Zigate plugin",
"HardwareTypeVal" : 94,
"HaveTimeout" : false,
"ID" : "00158d00032d3827",
"LastUpdate" : "2021-02-24 21:42:55",
"Name" : "ZiGate - Power-00158d00032d3827-02",
"Notifications" : "false",
"PlanID" : "1",
"PlanIDs" :
[
1
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : 9,
"SubType" : "Electric",
"Timers" : "false",
"Type" : "Usage",
"TypeImg" : "current",
"Unit" : 23,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "113"
}
],
"status" : "OK",
"title" : "Devices"
}
getvalue.html (to be saved in folder domoticz/www/views):
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use the following link http://<IP>:<port>/views/getvalue.html?idx=xxx&type=yyy to get the requested value as plain text -->
<!-- idx is the idx number of the device -->
<!-- type (case sensitive!) is the type of the requested value from the json of your idx device -->
<!-- change line $.domoticzurl="http://<IP-of-server>:<port>" to match your domoticz IP and port -->
<meta charset="utf-8">
<title>GetValue</title>
<script src="http://code.jquery.com/jquery-3.5.1.min.js"></script>
<style>
div#cnt
</style>
</head>
<div id="iusage">--</div>
<script type="text/javascript" charset="utf-8">
function RefreshData()
{
clearInterval($.refreshTimer);
var jurl=$.domoticzurl+"/json.htm?type=devices&rid="+$.getIDX;
$.getJSON(jurl,
{
format: "json"
},
function(data) {
if (typeof data.result != 'undefined') {
if (typeof data.WindSign != 'undefined') {
$('.windsign').html(data.WindSign);
}
if (typeof data.TempSign != 'undefined') {
$('.degsign').html(data.TempSign);
}
$.each(data.result, function(i,item) {
if( $.getIDX === item.idx ) {
var vdata=item[$.vtype];
if (typeof vdata == 'undefined') {
vdata="??";
}
else {
vdata=new String(vdata).split(" ",1)[0];
}
$('#iusage').html(vdata);
}
});
}
});
$.refreshTimer = setInterval(RefreshData, 10000);
}
function getAllUrlParams(url) {
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
var obj = {};
if (queryString) {
queryString = queryString.split('#')[0];
var arr = queryString.split('&');
for (var i = 0; i < arr.length; i++) {
var a = arr[i].split('=');
var paramName = a[0];
var paramValue = typeof (a[1]) === 'undefined' ? true : a[1];
//paramName = paramName.toLowerCase();
//if (typeof paramValue === 'string') paramValue = paramValue.toLowerCase();
if (paramName.match(/\[(\d+)?\]$/)) {
var key = paramName.replace(/\[(\d+)?\]/, '');
if (!obj[key]) obj[key] = [];
if (paramName.match(/\[\d+\]$/)) {
var index = /\[(\d+)\]/.exec(paramName)[1];
obj[key][index] = paramValue;
} else {
obj[key].push(paramValue);
}
} else {
if (!obj[paramName]) {
obj[paramName] = paramValue;
} else if (obj[paramName] && typeof obj[paramName] === 'string'){
obj[paramName] = [obj[paramName]];
obj[paramName].push(paramValue);
} else {
obj[paramName].push(paramValue);
}
}
}
}
return obj;
}
$(document).ready(function() {
// change next line to match your domoticz IP and port
$.domoticzurl="http://<IP-of-server>:<port>";
$.getIDX = getAllUrlParams().idx;
$.vtype = getAllUrlParams().type;
RefreshData();
});
</script>
</body>
</html>