Skip to content
Permalink
Browse files

Merge pull request #545 from Alexandr-logrus/alpha

smallfix
  • Loading branch information...
sergejey committed May 8, 2019
2 parents 03c6c99 + 1f8a2f2 commit 975f59b639986307b1c82c6561802d919376013a
@@ -9,7 +9,7 @@
$this->callMethod('setUpdatedText');
}
if ($this->getProperty('alive') == 0) {
$this->setProperty('alive', 1);
$this->setProperty('alive', 1);
}
@@ -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');
/*
@@ -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'),

0 comments on commit 975f59b

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