Skip to content
Permalink
Browse files

Fixes and updates

* Simple devices: "switch" action fixed
* Simple devices: new motion sensor setting -- "reset only nobody's home"
* Simple devices: camera widget load optimizing
  • Loading branch information...
sergejey committed May 27, 2019
1 parent 1b05bb9 commit b65793f767ef7043eb7dbad491f40147685d0e10
@@ -1166,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',
@@ -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' => 'Основной сенсор помещения',
@@ -14,6 +14,8 @@
callMethodSafe($linked_room . '.onActivity', array('sensor' => $ot));
}
/*
include_once(DIR_MODULES . 'devices/devices.class.php');
$dv = new devices();
$dv->checkLinkedDevicesAction($ot, $this->getProperty('status'));
$dv->checkLinkedDevicesAction($ot, $this->getProperty('status'));
*/
@@ -30,7 +30,7 @@
if (defined('SETTINGS_BEHAVIOR_NOBODYHOME_TIMEOUT')) {
$nobodyhome_timeout = SETTINGS_BEHAVIOR_NOBODYHOME_TIMEOUT * 60;
}
if ($nobodyhome_timeout) {
if ($nobodyhome_timeout && !$this->getProperty('resetNobodysHome')) {
setTimeOut('nobodyHome', "callMethodSafe('NobodyHomeMode.activate');", $nobodyhome_timeout);
}
@@ -156,6 +156,7 @@
'CLASS'=>'SMotions',
'PROPERTIES'=>array(
'ignoreNobodysHome'=>array('DESCRIPTION'=>LANG_DEVICES_MOTION_IGNORE,'_CONFIG_TYPE'=>'yesno','_CONFIG_HELP'=>'SdIgnoreNobodysHome'),
'resetNobodysHome'=>array('DESCRIPTION'=>LANG_DEVICES_MOTION_RESET,'_CONFIG_TYPE'=>'yesno','_CONFIG_HELP'=>'SdResetNobodysHome'),
'timeout'=>array('DESCRIPTION'=>LANG_DEVICES_MOTION_TIMEOUT,'_CONFIG_TYPE'=>'num','_CONFIG_HELP'=>'SdMotionTimeout')
),
'METHODS'=>array(
@@ -35,6 +35,7 @@
if ($w && $h) {
$resolution = $w . 'x' . $h;
}
//-re -f v4l2 -video_size 1280x720 -i /dev/video0
$cmd = 'fswebcam -r ' . $resolution . ' ' . $img_tmp;
if ($_GET['debug']) {
echo $cmd . '<br/>';
@@ -67,7 +68,7 @@
$url = str_replace('://', '://' . $username . ':' . $password . '@', $url);
}
if (preg_match('/^rtsp:/is', $url)) {
if (preg_match('/^rtsp:/is', $url) || preg_match('/\/dev/',$url)) {
//-rtsp_transport tcp // -rtsp_transport tcp
$stream_options = '-timelimit 15 -y -i "' . $url . '"' . $resize . ' -r 5 -f image2 -vframes 1'; //-ss 00:00:01.500
if ($_GET['debug']) {
@@ -1,6 +1,7 @@
<div class="camera-widget">
<div>%.previewHTML%</div>
<div class="camera-widget" id="camera%.object_title%">
<div class="camera-preview-html">%.previewHTML%</div>
<script type="text/javascript">
function takeSnapshot%.object_title%() {
callMethod('%.object_title%'+'.takeSnapshot');
$('#%.object_title%_snap').html(' OK');
@@ -30,24 +30,61 @@
var imageOrig[#UNIQ#] = document.getElementById("imgelem[#UNIQ#]");
var imageOrig[#UNIQ#]URL = imageOrig[#UNIQ#].src;
var imgNew[#UNIQ#] = new Image();
imgNew[#UNIQ#].onload = function () {
imageOrig[#UNIQ#].src=imgNew[#UNIQ#].src;
var srcURL=imageOrig[#UNIQ#]URL+ "&" + new Date().getTime();
imgNew[#UNIQ#].src = srcURL;
function checkImageOnScreen[#UNIQ#]() {
var elem=$('#imgelem[#UNIQ#]');
var height = elem.outerHeight();
var width = elem.outerWidth();
if(!width || !height){
return false;
}
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = elem.offset();
bounds.right = bounds.left + width;
bounds.bottom = bounds.top + height;
var showing = {
top : viewport.bottom - bounds.top,
left: viewport.right - bounds.left,
bottom: bounds.bottom - viewport.top,
right: bounds.right - viewport.left
};
return showing.top > 0
&& showing.left > 0
&& showing.right > 0
&& showing.bottom > 0;
}
imgNew[#UNIQ#].src = imageOrig[#UNIQ#]URL;
/*
window.onload = function() {
var image[#UNIQ#] = document.getElementById("imgelem[#UNIQ#]");
function updateImage[#UNIQ#]() {
alert('updating');
console.log(image[#UNIQ#]);
image[#UNIQ#].src = image[#UNIQ#].src+"&" + new Date().getTime();
function reloadSlideShowImage[#UNIQ#]() {
if (checkImageOnScreen[#UNIQ#]()) {
//console.log('loading image');
imageOrig[#UNIQ#].src=imgNew[#UNIQ#].src;
var srcURL=imageOrig[#UNIQ#]URL+ "&" + new Date().getTime();
imgNew[#UNIQ#].src = srcURL;
} else {
//console.log('skipping load');
setTimeout('reloadSlideShowImage[#UNIQ#]();',1000);
}
setInterval(updateImage[#UNIQ#], 1000);
}
*/
imgNew[#UNIQ#].onload = function () {
reloadSlideShowImage[#UNIQ#]();
}
imgNew[#UNIQ#].src = imageOrig[#UNIQ#]URL;
</script>
[#endif#]

0 comments on commit b65793f

Please sign in to comment.
You can’t perform that action at this time.