Page 2 of 3

Re: Water tank level (from other webserver)

Posted: Wednesday 06 June 2018 22:46
by Tarzan737
Ok! but sorry, no success anyway :(

still error but in line 8. thanks for taking time anyway!

Re: Water tank level (from other webserver)

Posted: Wednesday 06 June 2018 23:30
by Egregius
What if you past thag url in a browser and just change the ip address?

Re: Water tank level (from other webserver)

Posted: Thursday 07 June 2018 9:21
by Tarzan737
What? :shock:

Re: Water tank level (from other webserver)

Posted: Thursday 07 June 2018 12:28
by Egregius
What? What don't you understand? You don't know what a url is? Or you don't know what a browser is?

Well, a url is a link, in this case:

Code: Select all

http://192.168.0.14:8080/json.htm?type=command&param=udevice&idx=33&nvalue=0&svalue=100
And a browser? That's what you use the browse the web, like Chrome, Firefox, Safari,...

So, copy the above url and past it in the address bar of your browser.
You should see this:

Code: Select all

{
   "status" : "OK",
   "title" : "Update Device"
}

Re: Water tank level (from other webserver)

Posted: Sunday 10 June 2018 20:02
by Tarzan737
Sorry for late answer (been away) but i do get this

Code: Select all

 "status" : "OK",
   "title" : "Update Device"
if i use 192.168.0.14

but if i use 127.0.0.1:8080 i get domoticz offline with this code

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>

Re: Water tank level (from other webserver)

Posted: Sunday 10 June 2018 20:07
by Tarzan737
And i noticed that the value actually changed to 100 % in domoticz when i copy/pasted that line into browser, so it is updating

if i change value from 100 to 70 it is doing that as well into domoticz..

Re: Water tank level (from other webserver)

Posted: Sunday 10 June 2018 20:16
by Egregius
You can't use 127.0.0.1 on your computer of course.
Do you have authentication enabled?
What is you curl the url in a shell?

Re: Water tank level (from other webserver)

Posted: Sunday 10 June 2018 20:42
by Tarzan737
sorry, ofcourse i used to have domoticz on same computer..

but if you mean if i have any website protection? no i don“t

Re: Water tank level (from other webserver)

Posted: Sunday 10 June 2018 20:50
by Tarzan737
you mean like this?

Re: Water tank level (from other webserver)

Posted: Sunday 10 June 2018 22:42
by Egregius
No. This command:
curl -s "url..."

Re: Water tank level (from other webserver)

Posted: Monday 11 June 2018 17:20
by Tarzan737
i get this...

Re: Water tank level (from other webserver)

Posted: Monday 11 June 2018 17:27
by Tarzan737
tried curl -I to...

Re: Water tank level (from other webserver)

Posted: Monday 11 June 2018 17:35
by Egregius
You need to place the url between quotes...
Also, please try google... He knows a lot ;)

Re: Water tank level (from other webserver)

Posted: Monday 11 June 2018 17:49
by Tarzan737
ahh crap :) sorry again...

anyway.. then i get status ok and title update device....

other words.. it works like that!!

Re: Water tank level (from other webserver)

Posted: Monday 11 June 2018 22:49
by Egregius
Then it should also work from php.

Re: Water tank level (from other webserver)

Posted: Tuesday 12 June 2018 9:00
by Tarzan737
Propanly but it dont! Not with that code.
Everything seems to work, and when i use php
It reads correct value from tanklevel but it refuse to send it to domoticz.

Re: Water tank level (from other webserver)

Posted: Sunday 17 June 2018 7:27
by Egregius
Did you manage to get this working yet?
What did you do in the mean time?

Re: Water tank level (from other webserver)

Posted: Sunday 17 June 2018 22:32
by Tarzan737
Nope, not with the PHP code.
I beg that you or someone else have the solution. It would be nice to have it in domoticz.
I don't know what I do wrong. Could it be something in settings in domoticz? But as I wrote before, it responds but not with PHP script

Re: Water tank level (from other webserver)

Posted: Monday 18 June 2018 9:42
by Egregius
But you didn't do anything since my last post?
You didn't try stuff?

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));
}
?>
Check the url that is printed in the terminal window.
Use another small php script with this to verify:

Code: Select all

<?php
file_get_contents('http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx=33&nvalue=0&svalue=100);
?>
or

Code: Select all

<?php
file_get_contents('http://192.168.0.14:8080/json.htm?type=command&param=udevice&idx=33&nvalue=0&svalue=100);
?>
and

Code: Select all

<?php
file_get_contents('the url that was printed with the first code');
?>

Re: Water tank level (from other webserver)

Posted: Monday 18 June 2018 19:21
by Tarzan737
i have actually tried this before

Code: Select all

<?php
file_get_contents('http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx=33&nvalue=0&svalue=100);
?>
and then i get error on line 2 instead...