Re: Water tank level (from other webserver)
Posted: Wednesday 06 June 2018 22:46
Ok! but sorry, no success anyway 
still error but in line 8. thanks for taking time anyway!
still error but in line 8. thanks for taking time anyway!
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
http://192.168.0.14:8080/json.htm?type=command¶m=udevice&idx=33&nvalue=0&svalue=100Code: Select all
{
"status" : "OK",
"title" : "Update Device"
}Code: Select all
"status" : "OK",
"title" : "Update Device"Code: Select all
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Domoticz Offline</title>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<style>
html, body
{
height: 100%;
}
body
{
font: 12px 'Lucida Sans Unicode', 'Trebuchet MS', Arial, Helvetica;
margin: 0;
background: #202020 url(../css/images/img01.jpg) repeat;
}
#offline
{
background-color: #fff;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#eee));
background-image: -webkit-linear-gradient(top, #fff, #eee);
background-image: -moz-linear-gradient(top, #fff, #eee);
background-image: -ms-linear-gradient(top, #fff, #eee);
background-image: -o-linear-gradient(top, #fff, #eee);
background-image: linear-gradient(top, #fff, #eee);
height: 50px;
width: 300px;
margin: -150px 0 0 -180px;
padding: 30px;
position: absolute;
top: 50%;
left: 50%;
z-index: 0;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
#offline:before
{
content: '';
position: absolute;
z-index: -1;
border: 1px dashed #ccc;
top: 5px;
bottom: 5px;
left: 5px;
right: 5px;
-moz-box-shadow: 0 0 0 1px #fff;
-webkit-box-shadow: 0 0 0 1px #fff;
box-shadow: 0 0 0 1px #fff;
}
h3
{
text-transform: uppercase;
text-align: center;
color: #666;
margin: 0 0 30px 0;
letter-spacing: 4px;
font: normal 26px/1 Verdana, Helvetica;
position: relative;
}
h3:after, h3:before
{
background-color: #777;
content: "";
height: 1px;
position: absolute;
top: 15px;
width: 60px;
}
h3:after
{
background-image: -webkit-gradient(linear, left top, right top, from(#777), to(#fff));
background-image: -webkit-linear-gradient(left, #777, #fff);
background-image: -moz-linear-gradient(left, #777, #fff);
background-image: -ms-linear-gradient(left, #777, #fff);
background-image: -o-linear-gradient(left, #777, #fff);
background-image: linear-gradient(left, #777, #fff);
right: 0;
}
h3:before
{
background-image: -webkit-gradient(linear, right top, left top, from(#777), to(#fff));
background-image: -webkit-linear-gradient(right, #777, #fff);
background-image: -moz-linear-gradient(right, #777, #fff);
background-image: -ms-linear-gradient(right, #777, #fff);
background-image: -o-linear-gradient(right, #777, #fff);
background-image: linear-gradient(right, #777, #fff);
left: 0;
}
</style>
</head>
<body>
<div id="offline">
<h3 data-i18n="Domoticz Offline">Domoticz Offline</h3>
</div>
</body>
</html>
Code: Select all
<?php
$data=file_get_contents('http://192.168.0.12/tanklevl1');
$data=strafter($data,'</span><br>');
$data=strbefore($data,'%');
$idx=33;
$nvalue=0;
$svalue=$data;
$url='http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue='.$nvalue.'&svalue='.$svalue;
echo $url.PHP_EOL;
file_get_contents($url);
function strafter($string,$substring){
$pos=strpos($string,$substring);
if($pos===false)return $string;
else return(substr($string,$pos+strlen($substring)));
}
function strbefore($string,$substring){
$pos=strpos($string,$substring);
if($pos===false)return $string;
else return(substr($string,0,$pos));
}
?>Code: Select all
<?php
file_get_contents('http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=33&nvalue=0&svalue=100);
?>
Code: Select all
<?php
file_get_contents('http://192.168.0.14:8080/json.htm?type=command¶m=udevice&idx=33&nvalue=0&svalue=100);
?>
Code: Select all
<?php
file_get_contents('the url that was printed with the first code');
?>
Code: Select all
<?php
file_get_contents('http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=33&nvalue=0&svalue=100);
?>