PHP: Functions to control Domoticz

Post Reply
Amsterdam020
Posts: 61
Joined: Saturday 05 March 2016 22:42
Target OS: Raspberry Pi
Domoticz version: 3.5629
Contact:

PHP: Functions to control Domoticz

Post by Amsterdam020 » Friday 27 January 2017 22:12

I try to follow the instruction on https://www.domoticz.com/wiki/Extractin ... s_with_PHP
I created a php file in domoticz/scripts called extract.php.

When i try to execute in putty with ./extract.php i get the result "Permission denied".

My final goal is to export my data to a mysql database and (try to implement LUA Pass2php from Egregius), but the first step is that php is working.

Somebody a suggestion what i am doing wrong?
Rp3, youlesss, rfxcom, philips hue, dsb1820

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

Re: PHP: Functions to control Domoticz

Post by Egregius » Friday 27 January 2017 22:57

Did you disable authentication for 127.0.0.1 under settings, local networks?
Is the error from bash, php or domoticz?

Amsterdam020
Posts: 61
Joined: Saturday 05 March 2016 22:42
Target OS: Raspberry Pi
Domoticz version: 3.5629
Contact:

Re: PHP: Functions to control Domoticz

Post by Amsterdam020 » Sunday 29 January 2017 0:22

Thanks for your reply Egregius.

1) Under settings, local networks I added "127.0.*,192.168.1.*"
2) The error is in bash, btw.
3) i executed chmod 775 extract.php (in bash)
4) when i execute now:

pi@raspberrypi ~/domoticz/scripts $ ./extract.php

I get the result...
./extract.php: line 1: ?php: No such file or directory
./extract.php: line 2: syntax error near unexpected token `('
./extract.php: line 2: ` $json_string = file_get_contents("http://192.168.1.xx:8080/json.htm?type=devices&rid=73");'

5) Is it required to install special php software (which is not mentioned in https://www.domoticz.com/wiki/Extractin ... s_with_PHP )

file extract.php contains...
=================================
<?php
$json_string = file_get_contents("http://192.168.1.xx:8080/json.htm?type=devices$
$parsed_json = json_decode($json_string, true);
$test_link = "/home/pi/domoticz/scripts/test_1.txt";
$test_data = fopen ($test_link, "w+");
fwrite ($test_data, print_R($parsed_json, TRUE));
fclose ($test_data);
?>
=================================
Rp3, youlesss, rfxcom, philips hue, dsb1820

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

Re: PHP: Functions to control Domoticz

Post by Egregius » Sunday 29 January 2017 1:34

Do you have php7-cli installed?

Amsterdam020
Posts: 61
Joined: Saturday 05 March 2016 22:42
Target OS: Raspberry Pi
Domoticz version: 3.5629
Contact:

Re: PHP: Functions to control Domoticz

Post by Amsterdam020 » Sunday 05 February 2017 0:48

Hi Egregius. Took some time before i got into it.
Yes i have installed php7-cli. When i go to http://192.168.1.85/ the php info page is displayed. This is on port 80

Domoticz is running on port 8080. Do i have to enable php on 8080 as well in order to function (or shoudl i move domoticz to 80)?
Rp3, youlesss, rfxcom, philips hue, dsb1820

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

Re: PHP: Functions to control Domoticz

Post by Egregius » Sunday 05 February 2017 1:14

You can't use the same port. One port for domoticz and one for the php webserver.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest