POST Z-Way device status to another server (webpage)
Posted: 05 Jun 2017 01:10
Hello everyone, I have a problem and I was wondering if maybe some of you could help me, as I am more or less new in the programming and Z-Wave world.
I am trying to create a webpage, hosted in an Apache server (with PHP and mySQL) on the Raspberry, where I can see the values of my Fibaro Flood Sensor, more or less like an interface. Following an old post on this forum and Mr. Hekkers blog, I am currently executing a .js file in my z-way-server with the following code:
On my server I have a php file which supposedly recieves the POST with the sensor value, but I can't make it work and I do not see anything o my page. Is there any way I can check if this script is making the GET and POST request correctly? How can I recieve the POST request with the sensor info on my webpage?
Any info would be really appreciated, as I am really blocked right now.
Thank you very much and sorry if this is not the correct place to ask.
EDITED to add code tags
I am trying to create a webpage, hosted in an Apache server (with PHP and mySQL) on the Raspberry, where I can see the values of my Fibaro Flood Sensor, more or less like an interface. Following an old post on this forum and Mr. Hekkers blog, I am currently executing a .js file in my z-way-server with the following code:
Code: Select all
var callback = function(type,arg) {
try {
var options = {};
// timestamp
var ts = (new Date()).getTime();
ts = Math.floor(ts/1000).toString();
// query local ZWave API
options.url = "http://192.168.1.50:8083/ZWaveAPI/Run/devices[2].instances[0].commandClasses[156].data[5].sensorState.value"+ts; //sensor value
options.method = "GET";
var res = http.request(options);
// send response to webpage
options.url = "http://192.168.1.50:80"; // my Apache server on the Raspberry
options.method = "POST";
options.data = JSON.stringify(res);
res = http.request(options);
} catch(err) {
debugPrint("Failed to upload device state changes to webpage: " + err);
}
};
for (var dv in zway.devices) {
var dv = zway.devices[dv];
dv.data.bind(callback, null, true);
}
Any info would be really appreciated, as I am really blocked right now.
Thank you very much and sorry if this is not the correct place to ask.
EDITED to add code tags