Skip to content

Commit

Permalink
Update SDimmers_levelUpdated.php
Browse files Browse the repository at this point in the history
Dimmer level fix
  • Loading branch information
sergejey committed Feb 7, 2023
1 parent 2e582d0 commit 7548514
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions modules/devices/SDimmers_levelUpdated.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
<?php

/*
$tm=time();
$this->setProperty('updated', $tm);
$this->setProperty('updatedText', date('H:i', $tm));
*/

$level = $this->getProperty('level');
$minWork = $this->getProperty('minWork');
$maxWork = $this->getProperty('maxWork');
$levelWork = $this->getProperty('levelWork');

//DebMes("Level updated to " . $level, 'dimming');

$statusUpdated = 0;

if ($level > 0) {
Expand All @@ -21,24 +13,21 @@
$statusUpdated = 1;
$this->setProperty('status', 1, false);
}
if ($minWork != $maxWork) {
//DebMes("Level updated to " . $level ." ".$_SERVER['REQUEST_URI'], 'dimming');
$levelWork = round($minWork + round(($maxWork - $minWork) * $level / 100));
if ($this->getProperty('levelWork') != $levelWork) {
//DebMes("Setting new levelWork to " . (int)$levelWork, 'dimming');
$this->setProperty('levelWork', (int)$levelWork);
}
}
} else {
if ($this->getProperty('status')) {
$statusUpdated = 1;
$this->setProperty('status', 0);
}
if ($levelWork>0) {
$this->setProperty('levelWork', 0);
}

if ($minWork != $maxWork) {
$levelWork = round($minWork + round(($maxWork - $minWork) * $level / 100));
if ($this->getProperty('levelWork') != $levelWork) {
$this->setProperty('levelWork', (int)$levelWork);
}
}


if (!$statusUpdated) {
$this->callMethod('logicAction');
include_once(dirname(__FILE__) . '/devices.class.php');
Expand Down

0 comments on commit 7548514

Please sign in to comment.