Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr-logrus committed May 8, 2019
1 parent 4388ea1 commit 1f8a2f2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
2 changes: 1 addition & 1 deletion modules/devices/SDevices_statusUpdated.php
Expand Up @@ -9,7 +9,7 @@
$this->callMethod('setUpdatedText');
}
if ($this->getProperty('alive') == 0) {
$this->setProperty('alive', 1);
$this->setProperty('alive', 1);
}


Expand Down
89 changes: 44 additions & 45 deletions modules/devices/SSensors_valueUpdated.php
@@ -1,59 +1,58 @@
<?php

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

$ot=$this->object_title;
$description = $this->description;
if (!$description) {
$ot = $this->object_title;
$description = $this->description;
if (!$description) {
$description = $ot;
}
$linked_room=$this->getProperty('linkedRoom');

$value=(float)$this->getProperty('value');
$minValue=(float)$this->getProperty('minValue');
$maxValue=(float)$this->getProperty('maxValue');
$is_normal=(int)$this->getProperty('normalValue');
$directionTimeout=(int)$this->getProperty('directionTimeout');
if (!$directionTimeout) {
$directionTimeout=1*60*60;
}

if ($maxValue==0 && $minValue==0 && !$is_normal) {
}

$directionTimeout = (int)$this->getProperty('directionTimeout');
if (!$directionTimeout) {
$directionTimeout = 1*60*60;
}

$value = (float)$params['NEW_VALUE'];
$minValue = (float)$this->getProperty('minValue');
$maxValue = (float)$this->getProperty('maxValue');
$is_normal = (int)$this->getProperty('normalValue');
if ($maxValue == 0 && $minValue == 0 && !$is_normal) {
$this->setProperty('normalValue', 1);
} elseif (($value>$maxValue || $value<$minValue) && $is_normal) {
} elseif (($value > $maxValue || $value < $minValue) && $is_normal) {
$this->setProperty('normalValue', 0);
if ($this->getProperty('notify')) {
//out of range notify
say(LANG_DEVICES_NOTIFY_OUTOFRANGE. ' ('.$description.' '.$value.')', 2);
//out of range notify
say(LANG_DEVICES_NOTIFY_OUTOFRANGE . ' (' . $description . ' ' . $value . ')', 2);
}
} elseif (($value<=$maxValue && $value>=$minValue) && !$is_normal) {
} elseif (($value <= $maxValue && $value >= $minValue) && !$is_normal) {
$this->setProperty('normalValue', 1);
if ($this->getProperty('notify')) {
//back to normal notify
say(LANG_DEVICES_NOTIFY_BACKTONORMAL. ' ('.$description.' '.$value.')', 2);
//back to normal notify
say(LANG_DEVICES_NOTIFY_BACKTONORMAL . ' (' . $description . ' ' . $value . ')', 2);
}
}


$data1 = getHistoryValue($this->object_title.".value", time()-$directionTimeout);
$direction = 0;
if ($data1>$value) {
$direction=-1;
} elseif ($data1<$value) {
$direction=1;
}
$currentDirection = $this->getProperty('direction');
if ($currentDirection != $direction) {
$this->setProperty('direction',$direction);
}

if ($linked_room && $this->getProperty('mainSensor')) {
if ($this->class_title=='STempSensors') {
sg($linked_room.'.temperature',$value);
} elseif ($this->class_title=='SHumSensors') {
sg($linked_room.'.humidity',$value);
}

$data1 = getHistoryValue($this->object_title . '.value', time() - $directionTimeout);
$direction = 0;
if ($data1 > $value) {
$direction = -1;
} elseif ($data1 < $value) {
$direction = 1;
}
$currentDirection = $this->getProperty('direction');
if ($currentDirection != $direction) {
$this->setProperty('direction', $direction);
}

$linked_room = $this->getProperty('linkedRoom');
if ($linked_room && $this->getProperty('mainSensor')) {
if ($this->class_title == 'STempSensors') {
setGlobal($linked_room . '.temperature', $value);
} elseif ($this->class_title == 'SHumSensors') {
setGlobal($linked_room . '.humidity', $value);
} elseif ($this->class_title == 'SLightSensors') {
setGlobal($linked_room . '.light', $value);
}
}
}

$this->callMethod('statusUpdated');
/*
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/devices_structure.inc.php
Expand Up @@ -21,7 +21,7 @@
'DESCRIPTION'=>'General Devices Class',
'PROPERTIES'=>array(
'status'=>array('DESCRIPTION'=>LANG_DEVICES_STATUS, 'KEEP_HISTORY'=>365, 'ONCHANGE'=>'statusUpdated', 'DATA_KEY'=>1),
'alive'=>array('DESCRIPTION'=>'Alive','KEEP_HISTORY'=>365),
'alive'=>array('DESCRIPTION'=>'Alive'),
'aliveTimeout'=>array('DESCRIPTION'=>LANG_DEVICES_ALIVE_TIMEOUT,'_CONFIG_TYPE'=>'num','_CONFIG_HELP'=>'SdAliveTimeout'),
'linkedRoom'=>array('DESCRIPTION'=>'LinkedRoom'),
'updated'=>array('DESCRIPTION'=>'Updated Timestamp'),
Expand Down

0 comments on commit 1f8a2f2

Please sign in to comment.