Skip to content
Permalink
Browse files

Update magichome.class.php

Add acttion methods.
Fix level warming.
  • Loading branch information...
directman66 committed Oct 6, 2018
1 parent 891d193 commit b9c3bdd3a5254ac819b26dd303f4952f08ddff76
Showing with 30 additions and 5 deletions.
  1. +30 −5 modules/magichome/magichome.class.php
@@ -287,13 +287,13 @@ function propertySetHandle($object, $property, $value) {
if ($command=='color') {
$colorhex=str_replace('#','',$value);
$ar =(str_split($colorhex, 2));
sg('test.newcolor',$colorhex);
//sg('test.newcolor',$colorhex);
$magichomeObject->set_colorhex($deviceid, $ar[0],$ar[1],$ar[2]);
$magichomeObject->getinfo2($deviceid, $debug);
}
} //model
} //цикл девайсов
} //цикл девайсов
}//if total
@@ -786,7 +786,15 @@ function getinfo2($id=0) {
if (substr($buf,4,2)=='23') {$newvalue=1;} else {$newvalue=0;}
}
elseif ($properties[$i]['TITLE']=='color') {$newvalue='#'.str_replace('#','',substr($buf,12,6));}
elseif ($properties[$i]['TITLE']=='level') $newvalue=substr($buf,10,3);
elseif ($properties[$i]['TITLE']=='level')
{
$tempclolor=str_replace('#','',substr($buf,12,6));
$ar =(str_split($tempclolor, 2));
//$newvalue=((hexdec($ar[0]/255))+(hexdec($ar[1]/255))+(hexdec($ar[2]/255)))/3;
//$newvalue=round(hexdec((int)max($ar[0],$ar[1],$ar[2]))/255,2)*100;
$newvalue=round(max(hexdec($ar[0]),hexdec($ar[1]),hexdec($ar[2]))/255,2)*100;
}
else $newvalue=$buf;
@@ -805,6 +813,23 @@ function getinfo2($id=0) {
if ($myrec['LINKED_OBJECT'] && $myrec['LINKED_METHOD']) { // && $old_value!=$prop['CURRENT_VALUE_STRING']
$params=array();
$params=$_REQUEST;
$params['TITLE']=$properties[$i]['TITLE'];
$params['VALUE']=$newvalue;
$methodRes=callMethod($myrec['LINKED_OBJECT'].'.'.$myrec['LINKED_METHOD'], $params);
if (is_string($methodRes)) {
$ecmd=$methodRes;
}
}
}}
@@ -969,8 +994,8 @@ function csum($str)
//info 81:8a:8b:96
//РІРєР» 71:23:0f:a3
//выкл 71:24:0f:a4
//РІРєР» 71:23:0f:a3
//выкл 71:24:0f:a4
//color 1 1 1 31:01:01:01:00:f0:0f:33
//3100:00:00:00:f0:0f:30
//3100ff0000f00f2f

0 comments on commit b9c3bdd

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