Page 24 of 76
Re: Pass2PHP
Posted: Friday 08 September 2017 18:23
by Egregius
Make a php page that stores a post or get request in cache

Shall I post some code later?
Re: Pass2PHP
Posted: Friday 08 September 2017 19:01
by Egregius
It's on my github already
https://github.com/Egregius/LUA-Pass2PH ... /cache.php
Usage:
cache.php?fetch=devicename returns the value of that cache
cache.php?store=devicename&value=Off = store that value in cache
I only need it internally so my file is in my secure folder.
If you make this available from internat you could ad forexample &token=anystring and use that as a security measurement.
Re: Pass2PHP
Posted: Friday 08 September 2017 19:17
by sincze
Egregius wrote: ↑Friday 08 September 2017 19:01
It's on my github already
https://github.com/Egregius/LUA-Pass2PH ... /cache.php
Usage:
cache.php?fetch=devicename returns the value of that cache
cache.php?store=devicename&value=Off = store that value in cache
I only need it internally so my file is in my secure folder.
If you make this available from internat you could ad forexample &token=anystring and use that as a security measurement.
Damn... You completely redesigned pass2php since december 2016....
It seems I have a working... however outdated version running

Re: Pass2PHP
Posted: Friday 08 September 2017 19:28
by Egregius
Indeed, I just rewrote all the cache functions yesterday
It's still a work in progress,still some fine tuning but a lot less than a year ago. Once it does everything you need there's not much left to do.
Re: Pass2PHP
Posted: Friday 08 September 2017 21:15
by sincze
Hmm have been looking at your latest Github. It looks very nice and I can imagine for the 'starter' this now becomes a little bit more complicated than in December 2016. Even I got lost.
In my mind normally all functions would be in (and known within) pass2php.php that is called by the lua.
Pass2php.php would call (include) the pass2php/devicename.php
As all functions are within the 'root' document they can be used in the childs e.g. devicename.php.
I even got lost now as I can see the separate functions.php, cleaning up pass2php.php.
However I did not find a file that would include the functions.php to actually be able to use it. (I found it witin settings.php).
In addition I can imagine you added security for the floorplan access as well as some nice custom arrows and colours.
Where it used to be floorplans as project 1 and pass2php as project 2 you managed to integrate them both.
Pieuw brainteaser.
I'm still on...
- Spoiler: show
Code: Select all
<?php
error_reporting(E_ALL);
ini_set("display_errors","on");
date_default_timezone_set('Europe/Amsterdam');
//$actions=0;
// --------------------------------------------------------------------------------
// CONFIG
// --------------------------------------------------------------------------------
define('time',$_SERVER['REQUEST_TIME']);
define('domoticz','http://127.0.0.1:8080/');
define('webserver','http://127.0.0.1/');
define('port','8080');
// --------------------------------------------------------------------------------
// DEBUG OPTIONS
// --------------------------------------------------------------------------------
define('debug','false'); // Only Print Known functions
define('logging','true'); // Only Print Known functions (Pass2PHP functions)
define('influxdb','true'); // If this is set to true data will be exported. false will prevent this
define('thermostatdebug','true'); // If this is set to true thermostat data will be shown in the log
// --------------------------------------------------------------------------------
// Pass2PHP Stuff from here
// --------------------------------------------------------------------------------
// $a = status of triggered device devicechanged
// $s = array of all statusses otherdevices
// $i = array of all IDXs otherdevices_idx
// $t = array of all last update times otherdevices_lastupdate
// $c = array (equals devicechanged in lua)
$c=json_decode(base64_decode($_REQUEST['c']),true);
$s=json_decode(base64_decode($_REQUEST['s']),true);
$i=json_decode(base64_decode($_REQUEST['i']),true);
$t=json_decode(base64_decode($_REQUEST['t']),true);
foreach($c as $device=>$status)
{
if(@include '/var/www/php/pass2php/'.$device.'.php')
{
if(debug=="true") lg('Executing device: '.$device);
$dev=$device;
}
}
if(!isset($dev))die();
if(debug=="true") lg('Calling __CRON.php');
include '/var/www/php/pass2php/__CRON.php';
Re: Pass2PHP
Posted: Friday 08 September 2017 22:41
by Egregius
It's indeed difficult to separate the two things as they work perfectly together
Your json decode is very long time ago...
I wanted to create the settingsfile to have all user specific stuff in there, still some work to do. Once ready it should be a lot easier to update the other files.
Re: Pass2PHP
Posted: Saturday 09 September 2017 10:21
by dilepa
Hi Egregius,
I barely started to understand your old pass2php,

you have already updated.
Any particular reason you have removed apcu?
on a different note, would you run your programs from devicename.php or would you schedule it in cron jobs? Just some guidance..
Thanks

Re: Pass2PHP
Posted: Saturday 09 September 2017 11:59
by dilepa
Hi Egregius,
_cron604800.php is still reflecting apcu functions.
setidx is not used and none of the switch works, because the idx values are zero.

Re: Pass2PHP
Posted: Saturday 09 September 2017 16:25
by Egregius
apcu wasn't stable here on Jessie. Did some very strange things.
My floorplan is based completely on the cache from pass2php. First evening after the update to Jessie it showed 9 of 10 times the good status but 1 of 10 times like a status of half hour before. Of course resulting in some serious flipping of the automated lights.
I instantly started to work on file based cache, have used that before.
Another advantage of this is that you can sync the cache to SD when domoticz stops. So even after a reboot you still have the cache from before.
Also updated cron604800 on github

Re: Pass2PHP
Posted: Sunday 10 September 2017 11:36
by sincze
Egregius wrote: ↑Saturday 09 September 2017 16:25
apcu wasn't stable here on Jessie. Did some very strange things.
My floorplan is based completely on the cache from pass2php. First evening after the update to Jessie it showed 9 of 10 times the good status but 1 of 10 times like a status of half hour before. Of course resulting in some serious flipping of the automated lights.
I instantly started to work on file based cache, have used that before.
Another advantage of this is that you can sync the cache to SD when domoticz stops. So even after a reboot you still have the cache from before.
Also updated cron604800 on github
haha Mr innovator.

luckily I was not able to use acpu... back in the days.
I did install it on Jessie yesterday so I will not continue with that and use memcached.
Although I already started by digging up some of your old code:
- Spoiler: show
Code: Select all
function cset($key,$value){
if(cache=='apcu'){
apcu_store($key,$value);
}elseif(cache=='apc'){
apc_store($key,$value);
}elseif(cache=='memcached'){
if(!$m=xsMemcached::Connect('127.0.0.1',11211)){return;}$m->Set($key,$value);
}
}
function cget($key){
if(cache=='apcu'){
return apcu_fetch($key);
}elseif(cache=='apc'){
return apc_fetch($key);
}elseif(cache=='memcached'){
if(!$m=xsMemcached::Connect('127.0.0.1',11211)){return 0;}return $m->Get($key);
}
}
BTW I know you are a home automation speed / response junky.
What do your metrics say with file based cache.. Fast .. Faster .. Fastest ??
or reliable, more reliable ...
Re: Pass2PHP
Posted: Sunday 10 September 2017 12:39
by Egregius
File based is a little bit slower than apcu but almost not measurable in pass2php.
For my floorplan I read about 80 caches, there the time needed is 3msec for apcu, 6msec for file based. So maybe 3msec divided by 80 is the speed difference between apcu en file.
And I made a huge error, it's not on Jessie that apcu wasn't stable but on Stretch (Debian 9).
Re: Pass2PHP
Posted: Sunday 05 November 2017 13:35
by ropske
Hi Egregius,
i updated my Domoticz to the latest version => V3.8699
and what i see in the Domoticz log file now is that all commands executed by your php script are executed 2 or 3times after eachother.
Please see attached screenshot.
You can help me by pointing me in what direction in need to look for?
Thanks mate!
Re: Pass2PHP
Posted: Sunday 05 November 2017 14:55
by mosjonathan
fixed in beta 8701
Re: Pass2PHP
Posted: Sunday 05 November 2017 15:04
by Egregius
I've seen topics about double actions so I assume it is/was a domoticz issue.
I don't know because I don't update anymore

Re: Pass2PHP
Posted: Sunday 05 November 2017 17:10
by ropske
i better staid with my older version, seems domoticz is crashing a lot now

Re: Pass2PHP
Posted: Sunday 05 November 2017 23:13
by Egregius
Restore a backup...
Re: Pass2PHP
Posted: Thursday 21 December 2017 12:36
by sincze
Happy Birthday Pass2PHP.
Ik has been over a year I started to use this and I must say it has been worthwile. The system is running faster than ever.. Tnx @egregius.
Re: Pass2PHP
Posted: Friday 22 December 2017 8:48
by Egregius
Nice, and you're welcome

I do wonder how far you go with it?
Speeking of fast: I recently moved from a RPi2 to a oversized Intel NUC and virtualized Debian with Domoticz in Proxmox...
In the beginning of this topic I was so happy to get response times lower than 80msec. Now they're down to 6 msec

Re: Pass2PHP
Posted: Friday 22 December 2017 8:51
by DarkAllMan
sincze wrote: ↑Thursday 21 December 2017 12:36
Happy Birthday Pass2PHP.
Ik has been over a year I started to use this and I must say it has been worthwile. The system is running faster than ever.. Tnx @egregius.
Hear hear!
Egregius wrote: ↑Friday 22 December 2017 8:48
Nice, and you're welcome

I do wonder how far you go with it?
Speeking of fast: I recently moved from a RPi2 to a oversized Intel NUC and virtualized Debian with Domoticz in Proxmox...
In the beginning of this topic I was so happy to get response times lower than 80msec. Now they're down to 6 msec
I was already running Domoticz on a Ubuntu VM on an ESXi NUC

Re: Pass2PHP
Posted: Friday 22 December 2017 10:32
by sincze
Guys guys. Tell me what to buy.

exactly. Need for speed.
Currently running it on CubieTruck with ssd. Seems fast

enough haha. It must be low power consuming.
I try to teach people how to use pass2php but if they look at github they are overwhelmed with confusion. And may be it lacks a bit of explanatory documentation. As I have read ALL forum posts I at least understand the power.

your latest security additions are still a mystery to me
Sent from my SM-G925F using Tapatalk