Water tank level (from other webserver)

Tarzan737
Posts: 25
Joined: Friday 01 June 2018 20:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Water tank level (from other webserver)

Post by Tarzan737 » Monday 18 June 2018 19:31

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

User avatar
Egregius
Posts: 2713
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Water tank level (from other webserver)

Post by Egregius » Monday 18 June 2018 23:38

Qdd a echo $data; line to see what's in there.
Or better, add such line after each data= line

Tarzan737
Posts: 25
Joined: Friday 01 June 2018 20:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Water tank level (from other webserver)

Post by Tarzan737 » Wednesday 20 June 2018 22:09

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..
Attachments
Screenshot (14).png
Screenshot (14).png (243.91 KiB) Viewed 2282 times

User avatar
Egregius
Posts: 2713
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Water tank level (from other webserver)

Post by Egregius » Wednesday 20 June 2018 22:58

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.

Tarzan737
Posts: 25
Joined: Friday 01 June 2018 20:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Water tank level (from other webserver)

Post by Tarzan737 » Thursday 21 June 2018 5:38

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest