Page 37 of 76
Re: Pass2PHP
Posted: Thursday 11 April 2019 21:18
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.
Re: Pass2PHP
Posted: Thursday 11 April 2019 22:02
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?
Re: Pass2PHP
Posted: Thursday 11 April 2019 23:12
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?
Re: Pass2PHP
Posted: Friday 12 April 2019 6:47
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.
Re: Pass2PHP
Posted: Friday 12 April 2019 6:56
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.
Re: Pass2PHP
Posted: Friday 12 April 2019 9:05
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.
Re: Pass2PHP
Posted: Friday 12 April 2019 9:22
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?
Re: Pass2PHP
Posted: Friday 12 April 2019 10:32
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?
Re: Pass2PHP
Posted: Friday 12 April 2019 10:51
by Egregius
It has to be:
Are the idx's filled in the devices table?
If not you must execute the _fetchdomoticz.php script to fill them.
Re: Pass2PHP
Posted: Friday 12 April 2019 10:55
by gimic
ah, that is the i colom in the database, all is NULL
do i need to cron the _fetchdomoticz.php?
Re: Pass2PHP
Posted: Friday 12 April 2019 11:00
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
Re: Pass2PHP
Posted: Friday 12 April 2019 11:02
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.
Re: Pass2PHP
Posted: Friday 12 April 2019 11:17
by gimic
that page demands me a username and password (interface looks like acpu.php)
i tryed username1 - password1 but nothing.
Re: Pass2PHP
Posted: Friday 12 April 2019 19:45
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)
Re: Pass2PHP
Posted: Friday 12 April 2019 20:38
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...
Re: Pass2PHP
Posted: Friday 12 April 2019 20:49
by gimic
All is working, created a config.php in the var/www/ folder that was empty
too tired last night i guess
Re: Pass2PHP
Posted: Friday 12 April 2019 21:02
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
Re: Pass2PHP
Posted: Saturday 13 April 2019 7:06
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'.
Re: Pass2PHP
Posted: Saturday 13 April 2019 9:52
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
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.
Re: Pass2PHP
Posted: Saturday 13 April 2019 10:34
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.