easyRF
|
$device_id=$params['did'];
$destination_id=$params['dest'];
$packet_id=$params['pid'];
$command_id=$params['c'];
$data=$params['d'];
if ($device_id==0) {
if ($command_id==10) {
//temp
setGlobal('ws.tempInside',round($data/100));
} elseif ($command_id==12) {
//motion
callMethod('intSensor.statusChanged',array('status'=>1));
clearTimeOut($id.'_move');
setTimeOut($id.'_move',"callMethod('intSensor.statusChanged',array('status'=>0));",20);
}
}
|
Greeting
|
runScript("reportStatus", array());
|
playFavoriteMusic
|
// вытягиваем историю из переменной
$alreadyPlayed=gg("AlreadyPlayedMusic");
if (!$alreadyPlayed) {
$alreadyPlayed='0';
}
// выбираем случайную папку
$rec=SQLSelectOne("SELECT * FROM media_favorites WHERE ID NOT IN (".$alreadyPlayed.") ORDER BY RAND()");
if (!$rec['ID']) {
// папок больше не осталось, поэтому выбираем случайную и сбрасываем истоирю
$rec=SQLSelectOne("SELECT * FROM media_favorites ORDER BY RAND()");
$alreadyPlayed='0';
}
if ($rec['ID']) {
// добавляем выбранную папку в историю
$alreadyPlayed.=','.$rec['ID'];
sg("AlreadyPlayedMusic",$alreadyPlayed);
// запускаем на проигрывание
$collection=SQLSelectOne("SELECT * FROM collections WHERE ID=".(int)$rec['COLLECTION_ID']);
$path=$collection['PATH'].$rec['PATH'];
playMedia($path);
//setTimeOut('VLCPlayer_update',"callMethod('VLCPlayer.update');",10);
}
|
playPause
|
getURL('http://localhost/rc/?command=vlc_pause',0);
|
RCSwitch
|
$id=$params['rcswitch'];
if ($id=='12345') {
//sensor 1
}
|
readWeatherToday
|
$weather.="Сегодня ожидается ".str_replace('°',' ',getGlobal('weatherToday'));
$weather.=". Завтра ".str_replace('°',' ',getGlobal('weatherTomorrow'));
$weather.=". Сейчас на улице ".getGlobal('TempOutside').'.';
$weather=str_replace('°','',$weather);
say($weather,2);
|
amper
|
$res = file_get_contents("http://10.24.1.51/sec/?uart_tx=0103000D0001&mode=rs485");
usleep(100000);
$res = file_get_contents("http://10.24.1.51/sec/?uart_rx=1&mode=rs485");
if ( $res != 'CRC Error' )
{
$data = explode("|", $res);
$voltage = number_format(hexdec($data[3].$data[4]) / 10, 1);
echo "$voltage";
}
else
echo "Ошибка CRC";
|
electricity
|
$res = file_get_contents("http://10.24.1.51/sec/?uart_tx=0103000A0002&mode=rs485");
usleep(100000);
$res = file_get_contents("http://10.24.1.51/sec/?uart_rx=1&mode=rs485");
if ( $res != 'CRC Error' )
{
$data = explode("|", $res);
$voltage = number_format(hexdec($data[3].$data[4].$data[5].$data[6])/100, 2);
$voltagetotal = str_replace(",", "", $voltage);
echo "$voltagetotal";
}
else
echo "Ошибка CRC";
|
power
|
$res = file_get_contents("http://10.24.1.51/sec/?uart_tx=0103000E0001&mode=rs485");
usleep(100000);
$res = file_get_contents("http://10.24.1.51/sec/?uart_rx=1&mode=rs485");
if ( $res != 'CRC Error' )
{
$data = explode("|", $res);
$voltage = number_format(hexdec($data[3].$data[4]) / 10, 1);
echo "$voltage";
}
else
echo "Ошибка CRC";
|
Voltage
|
$res = file_get_contents("http://10.24.1.51/sec/?uart_tx=0103000C0001&mode=rs485");
usleep(100000);
$res = file_get_contents("http://10.24.1.51/sec/?uart_rx=1&mode=rs485");
if ( $res != 'CRC Error' )
{
$data = explode("|", $res);
$voltage = number_format(hexdec($data[3].$data[4]) / 10, 1);
echo "$voltage";
}
else
echo "Ошибка CRC";
|