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 » Wednesday 06 June 2018 22:46

Ok! but sorry, no success anyway :(

still error but in line 8. thanks for taking time anyway!
Attachments
Screenshot (8).png
Screenshot (8).png (188.86 KiB) Viewed 1545 times

User avatar
Egregius
Posts: 2714
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 06 June 2018 23:30

What if you past thag url in a browser and just change the ip address?

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 07 June 2018 9:21

What? :shock:

User avatar
Egregius
Posts: 2714
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 » Thursday 07 June 2018 12:28

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"
}

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 » Sunday 10 June 2018 20:02

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>

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 » Sunday 10 June 2018 20:07

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..

User avatar
Egregius
Posts: 2714
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 » Sunday 10 June 2018 20:16

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?

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 » Sunday 10 June 2018 20:42

sorry, ofcourse i used to have domoticz on same computer..

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

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 » Sunday 10 June 2018 20:50

you mean like this?
Attachments
Screenshot (9).png
Screenshot (9).png (170.13 KiB) Viewed 1473 times

User avatar
Egregius
Posts: 2714
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 » Sunday 10 June 2018 22:42

No. This command:
curl -s "url..."

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 11 June 2018 17:20

i get this...
Attachments
Screenshot (10).png
Screenshot (10).png (133.17 KiB) Viewed 1460 times

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 11 June 2018 17:27

tried curl -I to...
Attachments
Screenshot (12).png
Screenshot (12).png (151.79 KiB) Viewed 1460 times

User avatar
Egregius
Posts: 2714
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 11 June 2018 17:35

You need to place the url between quotes...
Also, please try google... He knows a lot ;)

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 11 June 2018 17:49

ahh crap :) sorry again...

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

other words.. it works like that!!

User avatar
Egregius
Posts: 2714
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 11 June 2018 22:49

Then it should also work from php.

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 » Tuesday 12 June 2018 9:00

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.

User avatar
Egregius
Posts: 2714
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 » Sunday 17 June 2018 7:27

Did you manage to get this working yet?
What did you do in the mean time?

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 » Sunday 17 June 2018 22:32

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

User avatar
Egregius
Posts: 2714
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 9:42

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');
?>

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:21

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...
Attachments
Screenshot (13).png
Screenshot (13).png (158.15 KiB) Viewed 2157 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest