Re: Pass2PHP
Posted: Friday 28 April 2017 14:12
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.
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.
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.
Code: Select all
root@raspberrypi:/home/pi/domoticz/scripts/lua# ls
ee5_base64.lua JSON.lua script_device_pass2php.luaCode: 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 Code: Select all
Error: EventSystem: Lua script /home/randall/domoticz/scripts/lua/script_device_pass2php.lua did not return a commandArrayCode: 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 commandArrayWhat 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.
Code: Select all
shell_exec('/var/www/html/secure/ios.sh "Movement in Hall" > /dev/null 2>/dev/null &');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;}
}Code: Select all
$msg='Weg ingeschakeld na 6min geen beweging';
telegram($msg,false,1);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);
}
}
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;
}