Pass2PHP

Moderator: leecollings

User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

There's an example in the secure folder.
Placed mine outside the www root so I don't have to worry about personal stuff in it.
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Do you really need php7.3? i'm running 7.0
getting this error:
[Thu Apr 11 22:00:01.740901 2019] [:error] [pid 562] [client 127.0.0.1:56398] PHP Notice: Use of undefined constant TIME - assumed 'TIME' in /var/www/html/secure /functions.php on line 354

any idea?
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

the database is filling with my devices as they get used.

what does not work is the floorplanlog.log and with it the actions behind all the functions. the acpu is still needed right?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

I updated to example config to add the TIME constant.

Strange thing about floorplanlog.log:
I define $LogFile='/var/log/floorplanlog.log'; in the configfile but $LogFile is never used anywhere else.
I do have a file like that that's owned by www-data but it's timestamp is 05-2018 so it isn't used anymore.
The lg function writes to the domoticz logfile.

APCu isn't used in my scripts anymore, but if you'd like you can still use it for small things I guess.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Oh, and it should work with PHP 7.0. Just recently updated to 7.3 so don't think I already use stuff that's deprecated or new in 7.3.
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Almost there i think...

only problem i have now is that script is running, i do action in domoticz, this executes the right php file in /secure/pass2php/ , database is updated with the correct status (sw('device', 'on') but that is not communicated back to domoticz, so nothing happens... what am i missing?

seems like there is a missing link between database & domoticz.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Did you fill in the domoticzurl in the config file?
Do you have part of the code that should send something to domoticz?
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

The domoticz url is by default in the config file.

i do a sw('device','on')
is that not enough to do the trick?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

It has to be:

Code: Select all

sw('device', 'On');
Are the idx's filled in the devices table?
If not you must execute the _fetchdomoticz.php script to fill them.
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

ah, that is the i colom in the database, all is NULL

do i need to cron the _fetchdomoticz.php?
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

i've executed the script by browsing it:

[Fri Apr 12 10:56:09.261039 2019] [:error] [pid 10657] [client 192.168.0.254:55913] PHP Notice: Undefined variable: domoticzurl in /var/www/html/secure/_fetchdomoticz.php on line 12
[Fri Apr 12 10:56:09.261313 2019] [:error] [pid 10657] [client 192.168.0.254:55913] 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
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

You have to include it somewhere where the config is already included.
I execute it from floorplan.others.php with a button.

If the idx is null the device is used as a dummy switch outside Domoticz.
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

that page demands me a username and password (interface looks like acpu.php)
i tryed username1 - password1 but nothing.
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

i've added the required modules to the _fetchdomoticz.php page.
it adds now only 3 idx values.
2 virtual temperature items
1 achterdeur that i don't have (and the script adds idx of the last sensor in the json file to database for this item)
all items are virtual, i have 30 items in domoticz (all virtual for now) different types, wind,pressure,Thermostat,... but these do not show in the database (cleared db and ran script)
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Deleted some code from the _fetchdomoticz.php like Dimmer & Blinds percentage, now it is fine, all idx show up in table. now i need to test if it reacts in domoticz...
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

All is working, created a config.php in the var/www/ folder that was empty :( too tired last night i guess
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Only the floorplan.php gives me a login page where i dont know what account i need to fill in? Where do i set that?

i'l send you my notes on the install when upgrade is done ;-)
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

I wasn't intended to share my authentication script but I did now anyway. After all I do have fail2ban in place.
Already made some changes to have it more secure like httponly cookies.
Will search somehow for a more secure login system with token or something like that.
For now, usernames and passwords are stored in plain text in the config file. Another reason to put this file outside the www root folder ;)

There was indeed a typo with the 'achterdeur' in _fetchdomoticz, it was a single = instead of a double ==.
That part is in there because the switch at my backdoor responds inversed. It sends open when closed...
The other stuff should normally function ok. It's there to 'clean' the data that comes from Domoticz. Like changing 'Level: 10%' to just '10'.
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Tnx for the correction ;-)
i need to add a lot of those exceptions if i'm trying to calculate with values as wind speed, solarradiation,...

you need to add changelog, can not follow witch files you change every time ;-) you are to fast :roll:

you changed the index.php file also. was interested in the miromcal ;-)
with ould index.php file i get nothing, user is correct but get empty page
new index.php only has menu.php you forgot to add menu.php to git.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

menu.php is just a page with my bookmarks. There's way to much personal stuff in it to share it and you shouldn't need it.

All weather related stuff is in _cron120.php.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests