Skip to content

Commit

Permalink
Merge pull request #556 from sergejey/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
sergejey committed May 27, 2019
2 parents 25f4fe7 + b65793f commit e9d137a
Show file tree
Hide file tree
Showing 66 changed files with 665 additions and 576 deletions.
4 changes: 4 additions & 0 deletions db_terminal.sql
Expand Up @@ -184,6 +184,7 @@ INSERT INTO `cached_values` (`KEYWORD`, `DATAVALUE`, `EXPIRE`) VALUES
('MJD:ThisComputer.isDark', '0', '2015-12-03 14:44:00'),
('MJD:ThisComputer.AlarmStatus', '', '2015-12-03 14:44:00'),
('MJD:ThisComputer.volumeLevel', '90', '2015-12-03 14:44:28'),
('MJD:ThisComputer.volumeMediaLevel', '90', '2015-12-03 14:44:28'),
('MJD:ThisComputer.TempOutside', '-0.9', '2015-12-03 14:44:28'),
('MJD:ThisComputer.textBoxTest', '0', '2015-12-03 14:46:01'),
('MJD:ThisComputer.AlarmTime', '09:30', '2015-12-03 14:46:01'),
Expand Down Expand Up @@ -932,6 +933,7 @@ CREATE TABLE IF NOT EXISTS `layouts` (
`DETAILS` text,
`REFRESH` int(10) NOT NULL DEFAULT '0',
`ICON` varchar(50) NOT NULL DEFAULT '',
`HIDDEN` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;

Expand Down Expand Up @@ -1623,6 +1625,7 @@ INSERT INTO `properties` (`ID`, `CLASS_ID`, `TITLE`, `DESCRIPTION`, `OBJECT_ID`,
(77, 0, 'stateTitle', NULL, 18, 0, ''),
(78, 0, 'stateTitle', NULL, 16, 0, ''),
(83, 0, 'volumeLevel', NULL, 7, 0, ''),
(152, 0, 'volumeMediaLevel', NULL, 7, 0, ''),
(119, 30, 'linkedRoom', '', 0, 0, ''),
(98, 0, 'somebodyHome', NULL, 7, 0, ''),
(118, 30, 'aliveTimeOut', '', 0, 0, ''),
Expand Down Expand Up @@ -2284,6 +2287,7 @@ CREATE TABLE IF NOT EXISTS `terminals` (
`PLAYER_USERNAME` varchar(255) NOT NULL DEFAULT '',
`PLAYER_PASSWORD` varchar(255) NOT NULL DEFAULT '',
`LATEST_ACTIVITY` date DEFAULT NULL,
`IS_ONLINE` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

Expand Down
3 changes: 2 additions & 1 deletion js/scripts.js
Expand Up @@ -316,7 +316,8 @@ var ajaxManager = (function() {

return {
addReq: function(opt) {
requests.push(opt);
if( !($.inArray(opt, requests) > -1) )
requests.push(opt);
},
removeReq: function(opt) {
if( $.inArray(opt, requests) > -1 )
Expand Down
5 changes: 4 additions & 1 deletion languages/default.php
Expand Up @@ -11,6 +11,7 @@
$dictionary = array(

/* general */
'SETTINGS_SITE_LANGUAGE_CODE'=>'en_GB',
'WIKI_URL' => 'http://majordomohome.com/',
'KB_URL' => 'https://kb.smartliving.ru/',
'DEFAULT_COMPUTER_NAME' => 'Alice',
Expand Down Expand Up @@ -1165,6 +1166,7 @@
'DEVICES_NOTIFY_BACKTONORMAL' => 'Value is back to normal',
'DEVICES_NOTIFY_NOT_CLOSED' => 'Notify when left open',
'DEVICES_MOTION_IGNORE' => 'Ignore device events when nobody\'s home',
'DEVICES_MOTION_RESET' => 'Reset "nobody home" status w/o setting timer',
'DEVICES_MOTION_TIMEOUT' => 'Activity timeout (sec)',
'DEVICES_ALIVE_TIMEOUT' => 'Possible inactivity timeout (hours)',
'DEVICES_MAIN_SENSOR' => 'Main sensor for the room',
Expand All @@ -1183,7 +1185,7 @@
'DEVICES_GROUP_ECO' => 'Turn it off in ECO mode',
'DEVICES_GROUP_ECO_ON' => 'Turn it on leaving ECO mode',
'DEVICES_GROUP_SUNRISE' => 'Turn it off with Sunrise',
'DEVICES_GROUP_SUNRISE' => 'Turn it on with Sunset',
'DEVICES_GROUP_SUNSET' => 'Turn it on with Sunset',
'DEVICES_IS_ACTIVITY' => 'Status change means activity in the room',
'DEVICES_NCNO' => 'Device/Sensor type',
'DEVICES_LOADTYPE' => 'Device type',
Expand Down Expand Up @@ -1300,6 +1302,7 @@

'AUTO_LINK' => 'Execute script automatically',
'FAVORITE_DEVICE' => 'Favorite device',
'SYSTEM_DEVICE' => 'System device',

'ROOMS' => 'Rooms',
'APPEARANCE' => 'Appearance',
Expand Down
2 changes: 2 additions & 0 deletions languages/ru.php
Expand Up @@ -1162,6 +1162,7 @@
'DEVICES_NOTIFY_BACKTONORMAL' => 'Значение датчика вернулось к норме',
'DEVICES_NOTIFY_NOT_CLOSED' => 'Напоминать об открытом состоянии',
'DEVICES_MOTION_IGNORE' => 'Игнорировать события от устройства, когда никого нет дома',
'DEVICES_MOTION_RESET' => 'Сброс статуса "никого нет дома" без таймера установки',
'DEVICES_MOTION_TIMEOUT' => 'Время активности (секунд)',
'DEVICES_ALIVE_TIMEOUT' => 'Допустимое время отсутствия данных (часов)',
'DEVICES_MAIN_SENSOR' => 'Основной сенсор помещения',
Expand Down Expand Up @@ -1295,6 +1296,7 @@

'AUTO_LINK' => 'Автоматический запуск сценария',
'FAVORITE_DEVICE' => 'В списке быстрого доступа',
'SYSTEM_DEVICE' => 'Системное устройство',

'ROOMS' => 'Комнаты',
'APPEARANCE' => 'Внешний вид',
Expand Down
12 changes: 10 additions & 2 deletions lib/terminals.class.php
Expand Up @@ -111,7 +111,15 @@ function getMajorDroidTerminals($limit = -1, $order = 'ID', $sort = 'ASC') {
}
return $terminals;
}

// Get terminals by CANTTS
function getTerminalsByCANTTS($order = 'ID', $sort = 'ASC') {
$sqlQuery = "SELECT * FROM `terminals` WHERE `CANTTS` = '".DBSafe('1')."' ORDER BY `".DBSafe($order)."` ".DBSafe($sort);
if(!$terminals = SQLSelect($sqlQuery)) {
$terminals = array(NULL);
}
return $terminals;
}
// Get local ip
function getLocalIp() {
global $local_ip_address_cached;
if (isset($local_ip_address_cached)) {
Expand All @@ -133,4 +141,4 @@ function getLocalIp() {
}
}
return $local_ip_address;
}
}
2 changes: 1 addition & 1 deletion modules/commands/commands.class.php
Expand Up @@ -589,7 +589,7 @@ function delete_commands($id) {
if ($tmp['ID']) {
return;
}

SQLExec("DELETE FROM security_rules WHERE OBJECT_TYPE='menu' AND OBJECT_ID=".(int)$rec['ID']);
SQLExec("DELETE FROM commands WHERE ID='".$rec['ID']."'");
}
/**
Expand Down
8 changes: 6 additions & 2 deletions modules/connect/connect.class.php
Expand Up @@ -477,7 +477,7 @@ function sendAllDevices()
// POST TO SERVER
$url = 'https://connect.smartliving.ru/sync_device_data.php';
$fields = array();
$devices = SQLSelect("SELECT ID, TITLE, ALT_TITLES, TYPE, SUBTYPE, LINKED_OBJECT FROM devices WHERE 1");
$devices = SQLSelect("SELECT devices.ID, devices.TITLE, devices.ALT_TITLES, devices.TYPE, devices.SUBTYPE, devices.LINKED_OBJECT, locations.TITLE as ROOM_TITLE FROM devices LEFT JOIN locations ON devices.LOCATION_ID=locations.ID WHERE devices.SYSTEM_DEVICE=0");
include_once(DIR_MODULES . 'classes/classes.class.php');
$cl = new classes();

Expand All @@ -496,6 +496,9 @@ function sendAllDevices()
$value = $object->getProperty($v['TITLE']);
if ($value === '') continue;
$device['properties'][$v['TITLE']] = $value;
if (strtolower($v['TITLE'])=='linkedroom') {
$device['ROOM_OBJECT']=$value;
}
}
}
}
Expand Down Expand Up @@ -532,7 +535,8 @@ function sendDeviceProperty($property, $value)
$url = 'https://connect.smartliving.ru/sync_device_data.php';
$fields = array();
list($object_name, $property_name) = explode('.', $property);
$device_rec = SQLSelectOne("SELECT ID, TITLE, TYPE, SUBTYPE FROM devices WHERE LINKED_OBJECT='" . DBSafe($object_name) . "'");
$device_rec = SQLSelectOne("SELECT ID, TITLE, TYPE, SUBTYPE FROM devices WHERE LINKED_OBJECT='" . DBSafe($object_name) . "' AND SYSTEM_DEVICE=0");
if (!$device_rec['ID']) return;
$fields['object'] = $object_name;
$fields['property'] = $property_name;
$fields['value'] = $value;
Expand Down
5 changes: 2 additions & 3 deletions modules/control_modules/control_modules.class.php
Expand Up @@ -215,14 +215,13 @@ function install($parent_name = "")
echo 'Installing '.$lst[$i]['FILENAME']." ($url)\n";
}
DebMes('Installing '.$lst[$i]['FILENAME']." ($url)",'reinstall');
$data = getURL($url);
/*
//$data = getURL($url); //
include_once(DIR_MODULES . $lst[$i]['FILENAME'] . "/" . $lst[$i]['FILENAME'] . ".class.php");
$obj = "\$object$i";
$code = "$obj=new " . $lst[$i]['FILENAME'] . ";\n";
//echo "Installing ".$lst[$i]['FILENAME']."\n";
@eval("$code");
*/

endMeasure('Installing '.$lst[$i]['FILENAME']);
}
}
Expand Down
25 changes: 12 additions & 13 deletions modules/devices/Rooms_onActivity.php
Expand Up @@ -2,25 +2,24 @@

if (defined('DISABLE_SIMPLE_DEVICES') && DISABLE_SIMPLE_DEVICES==1) return;

$ot=$this->object_title;
$ot = $this->object_title;

$latestActivity=$this->getProperty('LatestActivity');
$this->setProperty('LatestActivity',time());
$this->setProperty('LatestActivityTime',date('H:i'));
//$latestActivity = $this->getProperty('LatestActivity');
$this->setProperty('LatestActivity', time());
$this->setProperty('LatestActivityTime', date('H:i'));

if (!$this->getProperty('SomebodyHere')) {
$this->setProperty('SomebodyHere',1);
$this->callMethod("updateActivityStatus");
$this->setProperty('SomebodyHere', 1);
$this->callMethod('updateActivityStatus');
}

if ($this->getProperty("IdleDelay")) {
$activity_timeout=(int)$this->getProperty("IdleDelay");
if ($this->getProperty('IdleDelay')) {
$activity_timeout = (int)$this->getProperty('IdleDelay');
} else {
$activity_timeout=10*60;
$activity_timeout = 10*60;
}
clearTimeOut($ot."_activity_timeout");
setTimeOut($ot."_activity_timeout","callMethod('".$ot.".onIdle');",$activity_timeout);
setTimeOut($ot . '_activity_timeout', "callMethod('" . $ot . ".onIdle');", $activity_timeout);

if (getGlobal('NobodyHomeMode.active')) {
callMethod('NobodyHomeMode.deactivate',array('sensor'=>$params['sensor'],'room'=>$ot));
}
callMethod('NobodyHomeMode.deactivate', array('sensor' => $params['sensor'], 'room' => $ot));
}
2 changes: 1 addition & 1 deletion modules/devices/Rooms_onIdle.php
@@ -1,3 +1,3 @@
<?php

$this->callMethod("updateActivityStatus");
$this->callMethod('updateActivityStatus');
28 changes: 15 additions & 13 deletions modules/devices/SButtons_pressed.php
@@ -1,19 +1,21 @@
<?php

$ot=$this->object_title;
if (!isset($params['statusUpdated'])) {
setTimeout($ot.'_pressed_status', '', 3);
$ot = $this->object_title;
if (!isset($params['statusUpdated'])) {
setTimeout($ot . '_pressed_status', '', 3);
$this->setProperty('status', 1);
}
}

//$this->callMethod('statusUpdated');
//$this->callMethod('logicAction');
//$this->callMethod('statusUpdated');
//$this->callMethod('logicAction');

$linked_room=$this->getProperty('linkedRoom');
if ($linked_room) {
callMethodSafe($linked_room.'.onActivity', array('sensor'=>$ot));
}
$linked_room=$this->getProperty('linkedRoom');
if ($linked_room) {
callMethodSafe($linked_room . '.onActivity', array('sensor' => $ot));
}

include_once(DIR_MODULES.'devices/devices.class.php');
$dv=new devices();
$dv->checkLinkedDevicesAction($this->object_title, $this->getProperty('status'));
/*
include_once(DIR_MODULES . 'devices/devices.class.php');
$dv = new devices();
$dv->checkLinkedDevicesAction($ot, $this->getProperty('status'));
*/
3 changes: 1 addition & 2 deletions modules/devices/SControllers_switch.php
@@ -1,7 +1,6 @@
<?php

$currentStatus=$this->getProperty('status');
if ($currentStatus) {
if ($this->getProperty('status')) {
$this->callmethodSafe('turnOff');
} else {
$this->callmethodSafe('turnOn');
Expand Down
3 changes: 1 addition & 2 deletions modules/devices/SControllers_turnOn.php
@@ -1,4 +1,3 @@
<?php

$this->setProperty('status', 1);

$this->setProperty('status', 1);
14 changes: 7 additions & 7 deletions modules/devices/SCounters_valueWorkUpdated.php
@@ -1,22 +1,22 @@
<?php

$old_value=(float)$params['OLD_VALUE'];
$new_value=(float)$params['NEW_VALUE'];
$old_value = (float)$params['OLD_VALUE'];
$new_value = (float)$params['NEW_VALUE'];

$diff = $new_value-$old_value;
if ($diff<0) {
if ($diff < 0) {
$diff = $new_value;
}

$conversion = (float)$this->getProperty('conversion');
if ($conversion>0) {
if ($conversion > 0) {
$diff = $diff * $conversion;
}

$data_value = (float)$this->getProperty('value');
$new_data_value = round(($data_value + $diff),3);
$new_data_value = round(($data_value + $diff), 3);

if ($data_value!=$new_data_value) {
$this->setProperty('value',$new_data_value);
if ($data_value != $new_data_value) {
$this->setProperty('value', $new_data_value);
}

14 changes: 7 additions & 7 deletions modules/devices/SDevices_setUpdatedText.php
Expand Up @@ -3,21 +3,21 @@
$ot = $this->object_title;
$updatedTime = $this->getProperty('updated');
$passed = time() - $updatedTime;
$newTimeout=0;
$newTimeout = 0;

$passedText = getPassedText($updatedTime);
$this->setProperty('updatedText',$passedText);
$this->setProperty('updatedText', $passedText);

if ($passed<10) {
if ($passed < 10) {
$newTimeout = 10;
} elseif ($passed<60) {
} elseif ($passed < 60) {
$newTimeout = 10;
} elseif ($passed<60*60) {
} elseif ($passed < 60*60) {
$newTimeout = 60;
} elseif ($passed<20*60*60) {
} elseif ($passed < 20*60*60) {
$newTimeout = 60 * 60;
}

if ($newTimeout > 0) {
setTimeOut($ot.'_updateTime','callMethod("'.$ot.'.setUpdatedText");',$newTimeout);
setTimeOut($ot . '_updateTime', 'callMethod("' . $ot . '.setUpdatedText");', $newTimeout);
}
18 changes: 9 additions & 9 deletions modules/devices/SDevices_statusUpdated.php
Expand Up @@ -4,11 +4,12 @@
$linked_room = $this->getProperty('linkedRoom');

if ($this->class_title != 'SMotions' || $params['NEW_VALUE']) {
$tm = time();
$this->setProperty('updated', $tm);
$this->setProperty('updated', time());
$this->callMethod('setUpdatedText');
}
$this->setProperty('alive', 1);
if ($this->getProperty('alive') == 0) {
$this->setProperty('alive', 1);
}


$alive_timeout = (int)$this->getProperty('aliveTimeout') * 60 * 60;
Expand All @@ -18,7 +19,7 @@

setTimeout($ot . '_alive_timer', 'setGlobal("' . $ot . '.alive", 0);', $alive_timeout);

$need_call_logic_action = 1;
//$need_call_logic_action = 1;


if ($this->class_title == 'SMotions' && $params['NEW_VALUE'] && !timeOutExists($ot . '_motion_timer_status')) {
Expand All @@ -33,8 +34,7 @@
$nobodyhome_timeout=SETTINGS_BEHAVIOR_NOBODYHOME_TIMEOUT * 60;
}
if ($nobodyhome_timeout) {
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome", "callMethodSafe('NobodyHomeMode.activate');", $nobodyhome_timeout);
setTimeOut("nobodyHome", "callMethodSafe('NobodyHomeMode.activate');", $nobodyhome_timeout);
}
if ($linked_room) {
callMethodSafe($linked_room . '.onActivity', array('sensor' => $ot));
Expand All @@ -45,9 +45,9 @@
}
}

if ($need_call_logic_action) {
//if ($need_call_logic_action) {
$this->callMethod('logicAction');
include_once(DIR_MODULES . 'devices/devices.class.php');
$dv = new devices();
$dv->checkLinkedDevicesAction($this->object_title, $value);
}
$dv->checkLinkedDevicesAction($ot, $params['NEW_VALUE']);
//}

0 comments on commit e9d137a

Please sign in to comment.