HTTPDevice: Expected answer from device on URL??

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
MTK
Posts: 1
Joined: 01 Aug 2015 00:36

HTTPDevice: Expected answer from device on URL??

Post by MTK »

Hi
I just want to switch an HTTP Device via a URL. What is the expected answer from the device?

Background: The device is switching but the status of the element in the webinterface does not really change,
it gets greyed ... :-(

When I call the URL
to switch it on or off. My webssh.php skript answers with a simple "on" or "off", which comes from a bash script called ...

Code: Select all

<?php
/* get parameters stored in URL command*/

$cmd=$_GET["cmd"];
$host=$_GET["host"];
$parm1=$_GET["par1"];
$parm2=$_GET["par2"];
$parm3=$_GET["par3"];
$parm4=$_GET["par4"];
if ($host != "") {
    /*$resp = shell_exec("ssh $host $cmd $parm1 $parm2 $parm3 2>&1");*/
	$resp = shell_exec("/Heimautomation/webssh $host $cmd $parm1 $parm2 $parm3 $parm4 2>&1");
	$say = $resp; 	
} else {
    $resp = shell_exec("/Heimautomation/$cmd $parm1 $parm2 $parm3 $parm4 2>&1");
    $say = $resp;  
}
?>
<html>
<head>
<title>MTK WebSSH Interface</title>
</head>
<body>
<?php print($say); ?>
<form>
</form>
</body>
</html>
This should be expected behaviour of the the device as per HTTPDevice sources:

Code: Select all

 
if (typeof(response.data) === "string") {
                        var _data = response.data.trim();
                        if (deviceType === "switchBinary" || deviceType === "sensorBinary") {
                            if (_data === "1" || _data === "on" || _data === "true") {
                                data = "on";
                            } else if (_data === "0" || _data === "off" || _data === "false") {
                                data = "off";
                            }
                        }
I also implemented a read function to be populated in the result URL field:
Any hint what might be wrong?

kind regards
MTK
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: HTTPDevice: Expected answer from device on URL??

Post by PoltoS »

You need to read periodically (set poll period field to 1 or any number of seconds >0). We have separated actions from status. Doing actions does not change the status itself. Either wait for polling period or check box "updateOnAction" (it currently seems to have a small bug we will fix soon.
Post Reply