Page 40 of 76
Re: Pass2PHP
Posted: Thursday 02 May 2019 11:55
by poudenes
I get this error:
root@raspberrypi:/var/www/html/secure# php _fetchdomoticz.php
PHP Notice: Undefined variable: domoticzurl in /var/www/html/secure/_fetchdomoticz.php on line 14
PHP Warning: file_get_contents(/json.htm?type=devices&used=true): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 14
php is running correct with apache in my case
PHP Version 7.0.33-0+deb9u3
This is what I did not:
Code: Select all
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache
sudo apt-get install mysql-server
sudo apt-get install phpmyadmin
sudo mysql_secure_installation
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'domotica'@'localhost' IDENTIFIED BY 'domotica';
CREATE DATABASE domotica;
Download the GitHub package zip file. In this zip file you have ‘Create-Update SQL Database.txt'
Code: Select all
mysql -u domotica -p domotica < 'Create-Update SQL Database.txt'
mysql -u root -p
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| domotica |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
sudo ln -s /usr/share/phpmyadmin /var/www/html
Copy follow files from the ZIP file:
Code: Select all
pass2php.php
functions.php
_fetchdomoticz.php
config.php
To
But then im lost. I have script_device_pass2php (OLD FILE) do I need copy this to :
Also have a file called base64.lua .. do I need this one also and put info:
This is maybe last part thats missing in a good explanation how to install pass2php?
Re: Pass2PHP
Posted: Thursday 02 May 2019 12:07
by Trigun
sincze wrote: ↑Thursday 02 May 2019 10:44
Don't forget the lua file in the Domoticz directory later.
Can you echo the string (line12l that is failing so we can see what the problem is?
There seems to be a typo.
ok, i think I was to enthusiatic with putting in my personal info(eg. domoticz ipadresses in the different files/
I changed it all back to the usual files and now I get the following error based on line 12.
line 12 is:
Code: Select all
$domoticz=json_decode(file_get_contents($domoticzurl.'/json.htm?type=devices&used=true'), true);
error is:
Code: Select all
PHP Notice: Undefined variable: domoticzurl in /var/www/html/secure/_fetchdomoticz.php on line 12
PHP Warning: file_get_contents(/json.htm?type=devices&used=true): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 12
so I thought the "."was wrong after the $domoticzurl part.
after removing that I got the following error.
Code: Select all
PHP Parse error: syntax error, unexpected ''/json.htm?type=devices&used=t' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')' in /var/www/html/secure/_fetchdomoticz.php on line 12
Re: Pass2PHP
Posted: Thursday 02 May 2019 12:13
by poudenes
Trigun wrote: ↑Thursday 02 May 2019 12:07
sincze wrote: ↑Thursday 02 May 2019 10:44
Don't forget the lua file in the Domoticz directory later.
Can you echo the string (line12l that is failing so we can see what the problem is?
There seems to be a typo.
line 12 looks like this:
Code: Select all
$domoticz=json_decode(file_get_contents($http://127.0.0.1:8080.'/json.htm?type=devices&used=true'), true);
indeed. I also put the "script_device_pass2php.lua" file in the following directory: /home/pi/domoticz/schrips/lua
I hope this helps.
thnx!
Code: Select all
$domoticz=json_decode(
file_get_contents(
$domoticzurl.'/json.htm?type=devices&used=true'
),
true
);
must be ok. because $domoticzurl is configured in config.php
But I don't see a include or need to use config.php
EDIT:
Code: Select all
$domoticz=json_decode(file_get_contents($http://127.0.0.1:8081.'/json.htm?type=devices&used=true'), true);
gives me
Code: Select all
PHP Parse error: syntax error, unexpected ':', expecting ',' or ')' in /var/www/html/secure/_fetchdomoticz.php on line 12
Re: Pass2PHP
Posted: Thursday 02 May 2019 12:20
by poudenes
Tried this as well: Add
to
Code: Select all
then I get error:
PHP Fatal error: Uncaught Error: Call to undefined function store() in /var/www/html/secure/_fetchdomoticz.php:58
Stack trace:
#0 {main}
thrown in /var/www/html/secure/_fetchdomoticz.php on line 58
Fatal error: Uncaught Error: Call to undefined function store() in /var/www/html/secure/_fetchdomoticz.php:58
Stack trace:
#0 {main}
thrown in /var/www/html/secure/_fetchdomoticz.php on line 58
Re: Pass2PHP
Posted: Thursday 02 May 2019 12:21
by Trigun
poudenes wrote: ↑Thursday 02 May 2019 12:13
Trigun wrote: ↑Thursday 02 May 2019 12:07
sincze wrote: ↑Thursday 02 May 2019 10:44
Don't forget the lua file in the Domoticz directory later.
Can you echo the string (line12l that is failing so we can see what the problem is?
There seems to be a typo.
line 12 looks like this:
Code: Select all
$domoticz=json_decode(file_get_contents($http://127.0.0.1:8080.'/json.htm?type=devices&used=true'), true);
indeed. I also put the "script_device_pass2php.lua" file in the following directory: /home/pi/domoticz/schrips/lua
I hope this helps.
thnx!
Code: Select all
$domoticz=json_decode(
file_get_contents(
$domoticzurl.'/json.htm?type=devices&used=true'
),
true
);
must be ok. because $domoticzurl is configured in config.php
But I don't see a include or need to use config.php
EDIT:
Code: Select all
$domoticz=json_decode(file_get_contents($http://127.0.0.1:8081.'/json.htm?type=devices&used=true'), true);
gives me
Code: Select all
PHP Parse error: syntax error, unexpected ':', expecting ',' or ')' in /var/www/html/secure/_fetchdomoticz.php on line 12
quick question:
do all files need to be put in /var/www/html/secure or /var/www/secure?
this might be a crucial part

Re: Pass2PHP
Posted: Thursday 02 May 2019 13:03
by sincze
In my case nginx base directory is
/var/www/html
So everything behind that / deeper is accessible via http calls.
So I would suggest /var/www/html/secure
At the moment no access to @egregius latest files to check what the current files look like.
If I look at your error message it seems he is unable to find the specific functions like 'store' those are defined in functions.php if I am correct
Re: Pass2PHP
Posted: Thursday 02 May 2019 13:50
by Trigun
sincze wrote: ↑Thursday 02 May 2019 13:03
In my case nginx base directory is
/var/www/html
So everything behind that / deeper is accessible via http calls.
So I would suggest /var/www/html/secure
At the moment no access to @egregius latest files to check what the current files look like.
If I look at your error message it seems he is unable to find the specific functions like 'store' those are defined in functions.php if I am correct
thats where I stored all the files, so thats ok.
In all the files though, the reference is made to a different path.
I'll change that first.
thanks for you help!
Re: Pass2PHP
Posted: Thursday 02 May 2019 14:04
by sincze
There is a difference if files should be available via a web call.../ web Request.
Vs
Or the file should just be available for reading.. like it should not be served by the webserver... However it should be available for PHP to read it

Be careful with modifying. If they are in the path as requested it should go okay.
You are using the exact setup of @egregius so a working solution.
Re: Pass2PHP
Posted: Thursday 02 May 2019 14:09
by poudenes
Beside this all. We had config a mysql database, where in the files do you add the user/pass/db name information
Re: Pass2PHP
Posted: Thursday 02 May 2019 14:09
by Trigun
sincze wrote: ↑Thursday 02 May 2019 14:04
There is a difference if files should be available via a web call.../ web Request.
Vs
Or the file should just be available for reading.. like it should not be served by the webserver... However it should be available for PHP to read it

Be careful with modifying. If they are in the path as requested it should go okay.
You are using the exact setup of @egregius so a working solution.
I replaced all the files with the standard @egregius files again.
If I understand correctly I only need to change the domoticzurl of the config.php file which is stored in the /var/www folder?
Re: Pass2PHP
Posted: Thursday 02 May 2019 14:27
by poudenes
Did a full clear try:
unzip the ZIP total in /var/www/html/
changed the Domoticz info
still I have the error:
Code: Select all
PHP Notice: Undefined variable: domoticzurl in /var/www/html/secure/_fetchdomoticz.php on line 14
PHP Warning: file_get_contents(/json.htm?type=devices&used=true): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 14
So didn't change anything just Domoticz path
Re: Pass2PHP
Posted: Thursday 02 May 2019 14:43
by Trigun
poudenes wrote: ↑Thursday 02 May 2019 14:27
Did a full clear try:
unzip the ZIP total in /var/www/html/
changed the Domoticz info
still I have the error:
Code: Select all
PHP Notice: Undefined variable: domoticzurl in /var/www/html/secure/_fetchdomoticz.php on line 14
PHP Warning: file_get_contents(/json.htm?type=devices&used=true): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 14
So didn't change anything just Domoticz path
I Guess we're stuck at the same point

Re: Pass2PHP
Posted: Thursday 02 May 2019 15:05
by sincze
Your issues seems similar indeed.
Variable is not found... And the file_get_content executes the wrong url .
Debug is needed here.
a. Declare temporarily the missing variable in the _fetch.php file to find the next clue.
As I don't have access to my pc / GitHub I have to work with your feedback to get it up and running. Only have my mobile phone screen.

Re: Pass2PHP
Posted: Thursday 02 May 2019 15:11
by sincze
I just remember @egregius saying... He is calling the _fetch from a button on his floorplan... That would imply that the file already knows all variables and functions.
If you call the _fetch file by hand... You are missing key peaces of the pass2php puzzle...
Like the fetch file by itself would need :
require '/var/www/config.php';
require 'functions.php';
Re: Pass2PHP
Posted: Thursday 02 May 2019 15:22
by poudenes
sincze wrote: ↑Thursday 02 May 2019 15:11
I just remember @egregius saying... He is calling the _fetch from a button on his floorplan... That would imply that the file already knows all variables and functions.
If you call the _fetch file by hand... You are missing key peaces of the pass2php puzzle...
Like the fetch file by itself would need :
require '/var/www/config.php';
require 'functions.php';
Add this in _fetch and still I get the error

Re: Pass2PHP
Posted: Thursday 02 May 2019 16:35
by Egregius
The current version of _fetchdomoticz is functioning, just tested and didn't get any errors.
There's a example config.php file in the secure folder.
Mine is placed outside my webroot at
Either place it there, or change the files referring to it.
In the config file you must have a line like:
Code: Select all
$domoticzurl='http://127.0.0.1:8080';
Re: Pass2PHP
Posted: Thursday 02 May 2019 16:52
by sincze
Remember Domoticz needs to accept these changes via 127.0.0.1 as well without username or password. (Local network)
@egregius if you call the _fetchdomicz.php via a browser. Does that also work for you? I guess the guys are trying that. In that case I guess _fetch is unaware of the config file and functions location as the file by itself if I remember correctly has no link to these config and functions files and will fail with the same error message as currently being experienced.
A wrongly placed config file as you describe will cause the same error message indeed.
Re: Pass2PHP
Posted: Thursday 02 May 2019 16:53
by Trigun
poudenes wrote: ↑Thursday 02 May 2019 15:22
sincze wrote: ↑Thursday 02 May 2019 15:11
I just remember @egregius saying... He is calling the _fetch from a button on his floorplan... That would imply that the file already knows all variables and functions.
If you call the _fetch file by hand... You are missing key peaces of the pass2php puzzle...
Like the fetch file by itself would need :
require '/var/www/config.php';
require 'functions.php';
Add this in _fetch and still I get the error
GOT IT!!
my database is filled! whoehoo!
I put the config file in the www folder and added require '/var/www/config.php'; and require 'functions.php'; in the _fetch file.
i see the following output for all my devices.
Code: Select all
Notice: Undefined index: Temperature Garage in /var/www/html/secure/functions.php on line 368
PHP Notice: Undefined index: Tuinsproeier(1hour) in /var/www/html/secure/functions.php on line 368
when I check the database i can see all the devices are added but am sure if the output is correct because of the undefined index?
Re: Pass2PHP
Posted: Thursday 02 May 2019 16:54
by poudenes
Trigun wrote: ↑Thursday 02 May 2019 16:53
poudenes wrote: ↑Thursday 02 May 2019 15:22
sincze wrote: ↑Thursday 02 May 2019 15:11
I just remember @egregius saying... He is calling the _fetch from a button on his floorplan... That would imply that the file already knows all variables and functions.
If you call the _fetch file by hand... You are missing key peaces of the pass2php puzzle...
Like the fetch file by itself would need :
require '/var/www/config.php';
require 'functions.php';
Add this in _fetch and still I get the error
GOT IT!!
my database is filled! whoehoo!
I put the config file in the www folder and added require '/var/www/config.php'; and require 'functions.php'; in the _fetch file.
i see the following output for all my devices.
Code: Select all
Notice: Undefined index: Temperature Garage in /var/www/html/secure/functions.php on line 368
PHP Notice: Undefined index: Tuinsproeier(1hour) in /var/www/html/secure/functions.php on line 368
when I check the database i can see all the devices are added but am sure if the output is correct because of the undefined index?
Where did you add the mysql credentials? so php knows how to connect?
Re: Pass2PHP
Posted: Thursday 02 May 2019 17:06
by sincze
@trigun: excellent job.
Now have a look if all devices (domoticz) idx are there as well.