Pass2PHP
Moderator: leecollings
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
You're latest code block isn't the pass2php file posted in this topic.
Also the other scripts are very old versions.
Also the other scripts are very old versions.
-
- Posts: 37
- Joined: Friday 25 December 2015 0:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Pass2PHP
I did try according to this instruction:Egregius wrote:You're latest code block isn't the pass2php file posted in this topic.
Also the other scripts are very old versions.
https://egregius.be/2016/lua-pass2php-v2-0/
There is somewhere step by step instruction for noobs?
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Crap, my site is very outdated
This is more recent (but could also use an update) https://github.com/Egregius
This is more recent (but could also use an update) https://github.com/Egregius
-
- Posts: 37
- Joined: Friday 25 December 2015 0:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Pass2PHP
Ok but readme almost not exist.Egregius wrote:Crap, my site is very outdated
This is more recent (but could also use an update) https://github.com/Egregius
Code: Select all
Installation
Download the repository and unpack it
Place the lua script script_device_pass2php.lua in the lua folder of your Domoticz scripts folder
If you're planning on using pass2php with curl in a PHP enabled webserver place the complete secure folder in your html documents root (ex /var/www).
Update secure/pass2php with your settings.
And what next?
Code: Select all
root@raspberrypi:/home/pi/domoticz/scripts/lua# ls
ee5_base64.lua JSON.lua script_device_pass2php.lua
Code: Select all
2017-04-28 17:27:11.428 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_device_pass2php.lua did not return a commandArray
"os.execute('curl -s -d "c='..c..'" http://127.0.0.1/secure/pass2php.php &')"
in my case ?:
"os.execute( '/home/pi/domoticz/scripts/php/pass2php.php &')"
Can You explain "Update secure/pass2php with your settings" - i don't have idea what to do.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Using apcu and curl is way faster than just running thru cli.
I can't remember how I did it with CLI. You have to capture the changed device information.
I think in pass2php $_REQUEST['c'] should be replaced by $argv[0]
And in the lua script: os.execute('php /volume1/web/secure/pass2php.php "'..c..'" &')
But without apcu and a webserver you'll also need to use old versions of the whole system.
I can't remember how I did it with CLI. You have to capture the changed device information.
I think in pass2php $_REQUEST['c'] should be replaced by $argv[0]
And in the lua script: os.execute('php /volume1/web/secure/pass2php.php "'..c..'" &')
But without apcu and a webserver you'll also need to use old versions of the whole system.
-
- Posts: 52
- Joined: Friday 23 December 2016 9:41
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Pass2PHP
Hi Egregius,
As I understood you have changed your php2lua script completely and I wanted to change my script to your latest version.
However, the tutorial for this new version is nihil. Can you maybe create a tutorial on how to get your latest version working. Maybe it is a good idea to make a more general script version for people to use, because I see the main scripts are full of your custom functions with your custom IP's and devices.
Also make it clear on what the dependencies are. We need CURL & APCU installed?
For now I have checked your scripts and put everything in place, however, my domoticz log is full of the following error:
So I need some assistance...
It seems return {} is not valid. I changed it to:
Now I no longer have the log errors!
As I understood you have changed your php2lua script completely and I wanted to change my script to your latest version.
However, the tutorial for this new version is nihil. Can you maybe create a tutorial on how to get your latest version working. Maybe it is a good idea to make a more general script version for people to use, because I see the main scripts are full of your custom functions with your custom IP's and devices.
Also make it clear on what the dependencies are. We need CURL & APCU installed?
For now I have checked your scripts and put everything in place, however, my domoticz log is full of the following error:
Code: Select all
Error: EventSystem: Lua script /home/randall/domoticz/scripts/lua/script_device_pass2php.lua did not return a commandArray
It seems return {} is not valid. I changed it to:
Code: Select all
commandArray = {}
c = ''
for k,v in pairs(devicechanged) do c = c..k.."|"..v.."#" end
os.execute('curl -s -d "c='..c..'" http://###.###.###.###/secure/pass2php.php &')
return commandArray
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Hmmm, I wonder where that code came from. It was different on Github than in my own file.
I agree, documentation is far from complete. Most of the stuff is there for examples, there's no real plug and play description.
I agree, documentation is far from complete. Most of the stuff is there for examples, there's no real plug and play description.
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
Hi Egregius, is there a chance you can amend the wiki or create a sort of how to with curl and apcu? Would be great! Since this is a great feature!! Thnx a lot!!
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
there's not much to say about apcu. You install it with apt-get install php-apcu.
Once installed variables can be stored with apcu_store('keyname','value') and retrieved with apcu_fetch('keyname').
ACPU is extreme fast, multiple thousands times faster than the built-in uservariables of Domoticz. It takes less than a microsecond to store/retrieve data
There's a brief description at https://github.com/Egregius/LUA-Pass2PH ... stallation
Maybe it's better that an outsider makes documentation of the installation process to add to the wiki? I've done it already so many times that I don't think about it.
Once installed variables can be stored with apcu_store('keyname','value') and retrieved with apcu_fetch('keyname').
ACPU is extreme fast, multiple thousands times faster than the built-in uservariables of Domoticz. It takes less than a microsecond to store/retrieve data
There's a brief description at https://github.com/Egregius/LUA-Pass2PH ... stallation
Maybe it's better that an outsider makes documentation of the installation process to add to the wiki? I've done it already so many times that I don't think about it.
-
- Posts: 52
- Joined: Friday 23 December 2016 9:41
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Pass2PHP
Hi Egregius,
I was wondering about the status of an RGB Dimmer.
It seems that when changing the dimvalue the Dimmer Status is changed to 'Set Level' and not a numeric value. Can you confirm this behaviour?
For RGBW(C/W OR CCT) we would like to store multiple values I guess:
Dim Value (0-100)
RGB Color
Kelvin
Saturation
I was wondering about the status of an RGB Dimmer.
It seems that when changing the dimvalue the Dimmer Status is changed to 'Set Level' and not a numeric value. Can you confirm this behaviour?
For RGBW(C/W OR CCT) we would like to store multiple values I guess:
Dim Value (0-100)
RGB Color
Kelvin
Saturation
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
I don't have RGB stuff.
What exactly do you wan't to do with it? Auto set colors depending on statusses?
Best thing to do is view the commands being sent in the domotics web ui (in the developer console of a good browser).
With that json command you could create a new function.
What exactly do you wan't to do with it? Auto set colors depending on statusses?
Best thing to do is view the commands being sent in the domotics web ui (in the developer console of a good browser).
With that json command you could create a new function.
-
- Posts: 52
- Joined: Friday 23 December 2016 9:41
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Pass2PHP
What I want is to store multiple values in APCU ( On/Off, Dimmer Level, Color, Kelvin )Egregius wrote:I don't have RGB stuff.
What exactly do you wan't to do with it? Auto set colors depending on statusses?
Best thing to do is view the commands being sent in the domotics web ui (in the developer console of a good browser).
With that json command you could create a new function.
Currently when I dim a RGB ligth to 80% for instance, $status will be the value: "Set Level" It's not really usuable...
How do we provide PHP with more information?
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Is that data available in the devicechanged table in lua?
What does 'show current states' show under setup->more->events?
You could store it in multiple caches or combine them in a array and serialize that.
If it's not available in the devicechanged table, but it is when you call the json of that device that could also be an option.
What does 'show current states' show under setup->more->events?
You could store it in multiple caches or combine them in a array and serialize that.
If it's not available in the devicechanged table, but it is when you call the json of that device that could also be an option.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Updated github at https://github.com/Egregius/LUA-Pass2PHP-for-Domoticz
Biggest changes:
LUA script calls pass2php for each device in the devicechanged table
In pass2php the explodes aren't needed anymore because of that.
Splitted my cron jobs in different files based on frequency.
In cron180.php lots of weather information and garden irrigation based on passed and future rain predections.
In cron28800.php store battery levels in SQL based on ZWCFG.XML file instead of domoticz api.
A intermediate script to handle the IOS messages, no longer 4 seconds delay in script execution
And many more
Biggest changes:
LUA script calls pass2php for each device in the devicechanged table
In pass2php the explodes aren't needed anymore because of that.
Splitted my cron jobs in different files based on frequency.
In cron180.php lots of weather information and garden irrigation based on passed and future rain predections.
In cron28800.php store battery levels in SQL based on ZWCFG.XML file instead of domoticz api.
A intermediate script to handle the IOS messages, no longer 4 seconds delay in script execution
Code: Select all
shell_exec('/var/www/html/secure/ios.sh "Movement in Hall" > /dev/null 2>/dev/null &');
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
hi Egregius ,
in your pass2php.php you are using the telegram function:
i see you are using two id's, (one for you and one for your wife? )
i want the same, but my wife does not have to receive all messages like i do.
i'm just wondering, you also have 1 bot, but when i do this:
my wife is also receiving this message, but i'm ID1 and she is ID2, i have setup her ID in pass2php.php
Do you know what i'm doing wrong?
Thanks alot for your awesome php program
in your pass2php.php you are using the telegram function:
Code: Select all
function telegram($msg,$silent=true,$to=1){
$telegrambot='123456789:ABCD-xCRhO-RBfUqICiJs8q9A_3YIr9irxI';
$telegramchatid=123456789;
$telegramchatid2=234567890;
for($x=1;$x<=100;$x++){
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true){lg('telegram sent to 1: '.$msg);break;}
else lg('telegram sent failed');sleep($x*3);
global $actions;$actions=$actions+1;
}
if($to>=2)
for($x=1;$x<=100;$x++){
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid2.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true){lg('telegram sent to 2: '.$msg);break;}
else lg('telegram sent failed');sleep($x*3);
global $actions;$actions=$actions+1;
}
elseif($to==3){ios($msg);global $actions;$actions=$actions+1;}
}
i want the same, but my wife does not have to receive all messages like i do.
i'm just wondering, you also have 1 bot, but when i do this:
Code: Select all
$msg='Weg ingeschakeld na 6min geen beweging';
telegram($msg,false,1);
Do you know what i'm doing wrong?
Thanks alot for your awesome php program
- 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
I recognize your problem. Modified the telegram function to:
Code: Select all
function telegram($msg,$silent=true,$to='')
{
$telegrambot="*********:***********************************";
$telegramchatid_1r="******736";
$telegramchatid_2="******649";
$telegramchatid_group="-***********15";
if($to=='1')
for($x=1;$x<=100;$x++)
{
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid_sandor.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true)
{
lg('telegram sent to 1: '.$msg);
break;
}
else
{
lg('telegram sent failed');
}
sleep($x*3);
}
if($to=='2')
for($x=1;$x<=100;$x++)
{
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid_saskia.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true)
{
lg('telegram sent to 2: '.$msg);
break;
}
else
{
lg('telegram sent failed');
}
sleep($x*3);
}
if($to=='group')
for($x=1;$x<=100;$x++)
{
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid_bernini.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true)
{
lg('telegram sent to group: '.$msg);
break;
}
else
{
lg('telegram sent failed');
}
sleep($x*3);
}
}
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.
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.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
I use it like this:
Telegram('message',false) > only me
Telegram('message',false,2) > to me and girlfriend. She only wants the doorbel nd important stuff, I use it for lots of notifications.
With your function you need to add it twice.
Telegram('message',false) > only me
Telegram('message',false,2) > to me and girlfriend. She only wants the doorbel nd important stuff, I use it for lots of notifications.
With your function you need to add it twice.
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
Omg! feel so stupid
i had changed my code after to:
and it was not working like i wanted to be, but i forgot the double= sign if you want to make an if statement
doh :s
i had changed my code after to:
Code: Select all
if($to=1)
for($x=1;$x<=100;$x++){
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true){lg('telegram sent to 1: '.$msg);break;}
else lg('telegram sent failed');sleep($x*3);
global $actions;$actions=$actions+1;
}
if($to=2)
for($x=1;$x<=100;$x++){
$result=json_decode(file_get_contents('https://api.telegram.org/bot'.$telegrambot.'/sendMessage?chat_id='.$telegramchatid2.'&text='.urlencode($msg).'&disable_notification='.$silent));
if(isset($result->ok))
if($result->ok===true){lg('telegram sent to 2: '.$msg);break;}
else lg('telegram sent failed');sleep($x*3);
global $actions;$actions=$actions+1;
}
doh :s
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Yeah, you can search long after small errors like that.
- 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
Totally agree
Sent from my SM-G925F using Tapatalk
Sent from my SM-G925F using Tapatalk
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.
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.
Who is online
Users browsing this forum: No registered users and 0 guests