Pass2PHP

Moderator: leecollings

simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Pass2PHP

Post by simon_rb »

Egregius wrote: Saturday 12 August 2017 17:35 Hi Simon,

The code at github should be pretty recent, will update it in a few minutes with my latest code and scripts.
The installation in the wiki should be a good starting point, not very detailed...
https://github.com/Egregius/LUA-Pass2PH ... stallation
Hey, Thanks.

I tried to run

Code: Select all

sudo apt-get install php7.0 php7.0-cgi php7.0-common php7.0-fpm php7.0-json php7.0-mysql php7.0-phpdbg php7.0-sqlite3 php-apcu php-common php7.0-bcmath php7.0-cli php7.0-curl php7.0-gmp php7.0-mbstring php7.0-opcache php7.0-readline php7.0-xml php-cgi
I got

Code: Select all

pi@raspberrypi:~$ sudo apt-get install php7.0 php7.0-cgi php7.0-common php7.0-fpm php7.0-json php7.0-mysql php7.0-phpdbg php7.0-sqlite3 php-apcu php-common php7.0-bcmath php7.0-cli php7.0-curl php7.0-gmp php7.0-mbstring php7.0-opcache php7.0-readline php7.0-xml php-cgi
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package php7.0
E: Couldn't find any package by regex 'php7.0'
E: Unable to locate package php7.0-cgi
E: Couldn't find any package by regex 'php7.0-cgi'
E: Unable to locate package php7.0-common
E: Couldn't find any package by regex 'php7.0-common'
E: Unable to locate package php7.0-fpm
E: Couldn't find any package by regex 'php7.0-fpm'
E: Unable to locate package php7.0-json
E: Couldn't find any package by regex 'php7.0-json'
E: Unable to locate package php7.0-mysql
E: Couldn't find any package by regex 'php7.0-mysql'
E: Unable to locate package php7.0-phpdbg
E: Couldn't find any package by regex 'php7.0-phpdbg'
E: Unable to locate package php7.0-sqlite3
E: Couldn't find any package by regex 'php7.0-sqlite3'
E: Unable to locate package php-apcu
E: Unable to locate package php-common
E: Unable to locate package php7.0-bcmath
E: Couldn't find any package by regex 'php7.0-bcmath'
E: Unable to locate package php7.0-cli
E: Couldn't find any package by regex 'php7.0-cli'
E: Unable to locate package php7.0-curl
E: Couldn't find any package by regex 'php7.0-curl'
E: Unable to locate package php7.0-gmp
E: Couldn't find any package by regex 'php7.0-gmp'
E: Unable to locate package php7.0-mbstring
E: Couldn't find any package by regex 'php7.0-mbstring'
E: Unable to locate package php7.0-opcache
E: Couldn't find any package by regex 'php7.0-opcache'
E: Unable to locate package php7.0-readline
E: Couldn't find any package by regex 'php7.0-readline'
E: Unable to locate package php7.0-xml
E: Couldn't find any package by regex 'php7.0-xml'
E: Unable to locate package php-cgi
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 »

What system are you using?
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Pass2PHP

Post by simon_rb »

Egregius wrote: Sunday 13 August 2017 7:29 What system are you using?
Raspberry Pi 3, Jessie.

Cheers
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 »

Could be that you need the backports sources.list to enable php7:

Code: Select all

deb http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Pass2PHP

Post by simon_rb »

Egregius wrote: Sunday 13 August 2017 9:46 Could be that you need the backports sources.list to enable php7:

Code: Select all

deb http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free
Good call, I thought I had added them.. I added them to the /usr/share/doc/apt/examples/sources.list - I was very tired last night and no idea what I was thinking. Installing as we speak so fingers crossed its just adding the script you kindly made for me to a cron job.. :D

Top man! Thanks

I am really confused as to where to put the secure folder etc.. I have created a script called denon_cron60.php with your example script on the other topic under pi/home/domoticz/scripts/lua/secure is this the correct place?
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 »

Mine are stored at the www folder of my lighttpd webserver at /var/www/html/secure
Don't forget to secure that folder with .htaccess or something similar. PHP code is easily to grab, so you don't want any passwords or api keys available to everybody who knows how to grab the code.
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Pass2PHP

Post by simon_rb »

Egregius wrote: Sunday 13 August 2017 11:09 Mine are stored at the www folder of my lighttpd webserver at /var/www/html/secure
Don't forget to secure that folder with .htaccess or something similar. PHP code is easily to grab, so you don't want any passwords or api keys available to everybody who knows how to grab the code.
Thanks, I am still just as confused. Most of what you said is in a foreign language to me.. This is all well above my head of what I am capable of understanding. I'll go back to the old script and have the switch update every minute regardless of state.

You have been nothing but helpful and patient however I just can't get my head around this. I've read through this thread and had a brain melt down lol.
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's indeed not so simple to get it running, but when it runs it's rock stable and lightning fast :D
Give me a few minutes to put some code together, I'll post that in your other topic.
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Pass2PHP

Post by simon_rb »

Egregius wrote: Sunday 13 August 2017 13:23 It's indeed not so simple to get it running, but when it runs it's rock stable and lightning fast :D
Give me a few minutes to put some code together, I'll post that in your other topic.
Thank you! Much appreciated!
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Pass2PHP

Post by sincze »

Hey Egregius.

As the whole Pass2php is running basically by itself :D and I still have a spare Google Home I wanted to integrate this piece of hardware with custom commands as well via IFTTT. Ha-Bridge basically emulates a switch and that is already working, however I want nice custom commands.

I've found some instructions on how to do it using the uservariables in domoticz.
http://www.domoticz.com/forum/viewtopic ... me#p148881

As I don't want to use NodeRed.. I want to use Pass2PHP, any chance if I update a uservariable I would be able to retrieve the new value using Pass2php and do the regex of the result :D ? Is that array also stored somewhere within $c for example?

tnx

Sándor
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
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 »

Why not post the data directly to php?
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Pass2PHP

Post by sincze »

Egregius wrote: Monday 04 September 2017 22:46 Why not post the data directly to php?
:lol: :lol: :lol: You got me,
My PHP setup is not open to the outside world.

Maybe I can expose 1 device.... to the outside world.. Update that one and have Pass2PHP do the rest :D
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
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 are plenty of ways to secure that. I trust my php more than I trust domoticz :P
dilepa
Posts: 8
Joined: Thursday 16 June 2016 6:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by dilepa »

Egregius wrote: Tuesday 05 September 2017 22:01 There are plenty of ways to secure that. I trust my php more than I trust domoticz :P
Hi Egregius,

Total newbie here, do you have a detailed setup instructions on how to use this? This will help many like me.

Looked up Github and your site.. its still difficult.

My setup is pi3 running jessie with apache2 running on port 8090.

using the minimal pass2php.php

Thanks
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'm afraid there's still no 'just follow' guide to get this running...
But since you already have apache running can't be that hard.

I do wonder if you get it running good with apcu on jessie.
I recently updated my Pi to jessie and found that apcu did very strange things. I even wrote a file based cache system and removed apcu.

Anyway, if you're stuck anywhere on the installation of pass2php don't hesitate to ask, I enjoy giving people help with php.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Pass2PHP

Post by sincze »

Egregius wrote: Wednesday 06 September 2017 17:38 I do wonder if you get it running good with apcu on jessie.
A yes running Jessie here, I skipped the acpu part.. still on memcache (cget,cset) and one of your original versions retrieving all the $c,$s,$i,$t.
As said it runs very well. Really happy with the performance. Unfortunately I was unable to retrieve variable updates :lol:
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
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 »

Updates of domoticz variables you mean?
I don't use those,only php variables.

With all statusses in php it's even faster.
dilepa
Posts: 8
Joined: Thursday 16 June 2016 6:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by dilepa »

Egregius wrote: Wednesday 06 September 2017 17:38 I'm afraid there's still no 'just follow' guide to get this running...
But since you already have apache running can't be that hard.

I do wonder if you get it running good with apcu on jessie.
I recently updated my Pi to jessie and found that apcu did very strange things. I even wrote a file based cache system and removed apcu.

Anyway, if you're stuck anywhere on the installation of pass2php don't hesitate to ask, I enjoy giving people help with php.
Finally got it running i think.. with apcu php7.
Will have to experiment with various small programs.

Now i have understood a small part :cry: of how pass2php works. Nicely done. :idea:

Can you please explain about the various cron... why is the _cron604800 set for a long time for the domoticz values?
Also in github, the _cron604800 does not have the extension .php. Is it supposed to be like that?

Will let you know how it goes with my programs.
Thanks :D :D
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 »

Let me now if you got apcu stable. Mine give somethimes old values on Jessie.
Rewrote some functions to use file cache on tmpfs instead. So I shall update github again.

pass2php is triggered by every device update, but to be sure it's triggered very frequently I also trigger it with curl from a bash script and cron.
Inside pass2php the various cron files are called whenever their timeout is passed.
The cron604800 is that long because it's only needed after a restart (to fetch the statusses of domoticz). Once the cache is filled it receives it's updates instantly so no need to fetch them regularly from domoticz.

The extension of that file is fixed, thanks for pointing that out.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Pass2PHP

Post by sincze »

Egregius wrote: Wednesday 06 September 2017 19:05 Updates of domoticz variables you mean?
I don't use those,only php variables.

With all statusses in php it's even faster.
Yes indeed :D
Normally I would use php ones indeed, but unfortunately I can't update those via a http json call.
I need variables or custom hw device to store the google home ;-) results as I did not manage to create a php/webserver that solves incoming messages for me. :shock:
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests