Skip to content

Commit 7548514

Browse files
committed
Update SDimmers_levelUpdated.php
Dimmer level fix
1 parent 2e582d0 commit 7548514

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

modules/devices/SDimmers_levelUpdated.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
<?php
22

3-
/*
4-
$tm=time();
5-
$this->setProperty('updated', $tm);
6-
$this->setProperty('updatedText', date('H:i', $tm));
7-
*/
8-
93
$level = $this->getProperty('level');
104
$minWork = $this->getProperty('minWork');
115
$maxWork = $this->getProperty('maxWork');
126
$levelWork = $this->getProperty('levelWork');
137

14-
//DebMes("Level updated to " . $level, 'dimming');
15-
168
$statusUpdated = 0;
179

1810
if ($level > 0) {
@@ -21,24 +13,21 @@
2113
$statusUpdated = 1;
2214
$this->setProperty('status', 1, false);
2315
}
24-
if ($minWork != $maxWork) {
25-
//DebMes("Level updated to " . $level ." ".$_SERVER['REQUEST_URI'], 'dimming');
26-
$levelWork = round($minWork + round(($maxWork - $minWork) * $level / 100));
27-
if ($this->getProperty('levelWork') != $levelWork) {
28-
//DebMes("Setting new levelWork to " . (int)$levelWork, 'dimming');
29-
$this->setProperty('levelWork', (int)$levelWork);
30-
}
31-
}
3216
} else {
3317
if ($this->getProperty('status')) {
3418
$statusUpdated = 1;
3519
$this->setProperty('status', 0);
3620
}
37-
if ($levelWork>0) {
38-
$this->setProperty('levelWork', 0);
21+
}
22+
23+
if ($minWork != $maxWork) {
24+
$levelWork = round($minWork + round(($maxWork - $minWork) * $level / 100));
25+
if ($this->getProperty('levelWork') != $levelWork) {
26+
$this->setProperty('levelWork', (int)$levelWork);
3927
}
4028
}
4129

30+
4231
if (!$statusUpdated) {
4332
$this->callMethod('logicAction');
4433
include_once(dirname(__FILE__) . '/devices.class.php');

0 commit comments

Comments
 (0)