Page 3 of 3

Re: Water tank level (from other webserver)

Posted: Monday 18 June 2018 19:31
by Tarzan737
i noticed now when i tried this code

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&param=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));
}
?>
that the value has changed to 0 in domoticz.. it was like 50% this morning since when i used a browser to update the value...

but the tanklevel unit was off by mistake... and then it sent the value 0 to domoticz and i can see it in domoticz log to.. incoming connection 127.0.0.1... but when i started tanklevel sensor i got error again... but it reads values (in this case 81% tanklevl1) but it don´t send it to domoticz

Re: Water tank level (from other webserver)

Posted: Monday 18 June 2018 23:38
by Egregius
Qdd a echo $data; line to see what's in there.
Or better, add such line after each data= line

Re: Water tank level (from other webserver)

Posted: Wednesday 20 June 2018 22:09
by Tarzan737
Hi..

i added those lines.. i don´t know if i did right..

but really.. when i shut off the arduino with tanklevel it updates to domoticz.. so the code works in that case... (but the value is zero ofcourse)

and when i turn on arduino and use the php code it reads the correct values as i can see in putty but then it is not able to send it to domoticz..

Re: Water tank level (from other webserver)

Posted: Wednesday 20 June 2018 22:58
by Egregius
I think you need to learn how the code works and debug it yourself. With just a screen shot and no code it hard to find out the issue.

Re: Water tank level (from other webserver)

Posted: Thursday 21 June 2018 5:38
by Tarzan737
I understand that, i don’t expect that you should solve everything for me, im not a developer and don’t really have time to learn coding right now.

Im going away some weeks anyway now so cant try things.

Thank u anyway for help and your patience