Read out data from a z wave sensor from domoticz and pass to OpenWB with http Topic is solved

For Z-Wave related questions in Domoticz

Moderator: leecollings

Post Reply
lumjajo
Posts: 67
Joined: Wednesday 26 April 2017 20:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Germany
Contact:

Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by lumjajo »

Hi,
I need to read out the data (Energy) of a Z Wave Plug from Domoticz.
This should be done with the API as OpenWB requires a http url.
If I read the Domoticz API Wiki page, it only tells me how tomodify the calues of a sensor, not to read the data of a z wave device. Can someony please just poin tme into the right direction?
Thanks
User avatar
waltervl
Posts: 5712
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waltervl »

You can use HTTPlink for that: setup > more options > data push > HTTP
see also https://www.domoticz.com/wiki/HttpLink On that wike page there is an example how to send data to an influx database but the same can be done to somthing as OpenWB.


Alternative you can create a DzVents script that sends the data with domoticz.OpenURL see https://www.domoticz.com/wiki/DzVents:_ ... terface.29
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waaren »

lumjajo wrote: Wednesday 17 February 2021 23:47 I need to read out the data (Energy) of a Z Wave Plug from Domoticz.
Is the information needed not already in the result of the standard device API?

Code: Select all

http://<domoticz IP:domoticz Port>/json.htm?type=devices&rid=<device idx>
Spoiler: show

Code: Select all

{
	"ActTime" : 1613644456,
	"AstrTwilightEnd" : "19:54",
	"AstrTwilightStart" : "05:57",
	"CivTwilightEnd" : "18:36",
	"CivTwilightStart" : "07:15",
	"DayLength" : "10:12",
	"NautTwilightEnd" : "19:15",
	"NautTwilightStart" : "06:36",
	"ServerTime" : "2021-02-18 11:34:16",
	"SunAtSouth" : "12:56",
	"Sunrise" : "07:50",
	"Sunset" : "18:02",
	"app_version" : "2020.2 (build 12947)",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CounterToday" : "-0.000 kWh",
			"CustomImage" : 0,
			"Data" : "112.521 kWh",
			"Description" : "",
			"EnergyMeterMode" : "",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 4,
			"HardwareName" : "Aeotec  Zwave stick",
			"HardwareType" : "OpenZWave USB",
			"HardwareTypeVal" : 21,
			"HaveTimeout" : false,
			"ID" : "00000301",
			"LastUpdate" : "2021-02-18 08:55:31",
			"Name" : "Wasmachine Kw",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "kWh",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "General",
			"TypeImg" : "current",
			"Unit" : 1,
			"Usage" : "0.1 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "915"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waltervl
Posts: 5712
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waltervl »

BTW: If you want to communicate with OpenWB you better can use MQTT: https://openwb.de/forum/viewtopic.php?f=6&t=577
But I think there is no way to send the Energy values of your Zwave device to OpenWB??? You can only set charge modes....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
lumjajo
Posts: 67
Joined: Wednesday 26 April 2017 20:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Germany
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by lumjajo »

The problem is the smarthome 2.0 connection to the sensor. Its either Shelly or Tasmota or http no Mqtt. I would really like to do it with MQTT. I just thought having domoticz available I use one of the sensores there. I need a power sensor, which feeds back the information to OpenWB. Unfortunately openWB does not suppurt ESP Easy...would also be an option ....

Ok I understand that I cannot read out the Current, Power from a Z wave Device with simple http url. Therefore I assume i need to create something different....

@warren, yes it does but openWB does not know what to do with all the information.

Code: Select all

ActTime	1613668859
AstrTwilightEnd	"19:24"
AstrTwilightStart	"05:30"
CivTwilightEnd	"18:12"
CivTwilightStart	"06:42"
DayLength	"10:26"
NautTwilightEnd	"18:48"
NautTwilightStart	"06:06"
ServerTime	"2021-02-18 18:20:59"
SunAtSouth	"12:27"
Sunrise	"07:14"
Sunset	"17:40"
app_version	"4.10717"
result	
0	
AddjMulti	1
AddjMulti2	1
AddjValue	0
AddjValue2	0
BatteryLevel	255
CounterToday	"0.020 kWh"
CustomImage	0
Data	"0.020 kWh"
Description	""
EnergyMeterMode	"0"
Favorite	0
HardwareID	4
HardwareName	"ZWave USB"
HardwareType	"OpenZWave USB"
HardwareTypeVal	21
HaveTimeout	false
ID	"00002201"
LastUpdate	"2021-02-18 18:20:24"
Name	"Neo Coolcam Plug 2 Energie"
Notifications	"false"
PlanID	"12"
PlanIDs	
0	12
Protected	false
ShowNotifications	true
SignalLevel	"-"
SubType	"kWh"
SwitchTypeVal	0
Timers	"false"
Type	"General"
TypeImg	"current"
Unit	1
Usage	"0 Watt"
Used	1
XOffset	"548"
YOffset	"167"
idx	"428"
status	"OK"
title	"Devices"
and I am not smart enough to tell openWb with a http url which value it should pick....gues thats not working at all.

Thanks anyway for your help...:-)
User avatar
waltervl
Posts: 5712
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waltervl »

I cannot understand what you want to do. Can you give a link to the documentation or manual were is described that openWB can read energy data from an external device with an http link?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
lumjajo
Posts: 67
Joined: Wednesday 26 April 2017 20:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Germany
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by lumjajo »

Here its strange but its one of the options .

Image

I understand now that its not possible, so I will by a shelly...this will be supported by OpenWB.
In the Drop Down Menue it says:
Shelly,Tasmota,Acthor,Elwa,IDM ,Stiebel,Http,AVM,MyStrom
User avatar
waltervl
Posts: 5712
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waltervl »

What is a possibility is to create a php script that will show the value when called eg http://IP-domoticz:port/extract.php?idx=xxx

See for example
https://www.domoticz.com/wiki/Extractin ... s_with_PHP
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
lumjajo
Posts: 67
Joined: Wednesday 26 April 2017 20:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Germany
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by lumjajo »

Interesting, I did not know it and will have a look.
Basically the easiest way is to buy a shelly...this can be used natively...and even can be connected with domoticz
User avatar
waltervl
Posts: 5712
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waltervl »

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>
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Pvhpsb
Posts: 15
Joined: Tuesday 20 January 2015 13:38
Target OS: NAS (Synology & others)
Domoticz version:
Location: Prinsenbeek
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by Pvhpsb »

Hello Walter, thanks for this info I can now read the correct data in a web browser with getvalue link.
But unfortunately it doesn't work in openWB, you know someone who have this working with openWB.
With kind regards,
Patrick
User avatar
waltervl
Posts: 5712
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by waltervl »

I am sorry, perhaps someone on openWB forum can help...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
lumjajo
Posts: 67
Joined: Wednesday 26 April 2017 20:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Germany
Contact:

Re: Read out data from a z wave sensor from domoticz and pass to OpenWB with http

Post by lumjajo »

I tried it as well, but did not work for me either..yes I bought a Shelly but did not use it so far...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest