forked from FredBardin/phpMyHue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec682ae
commit c93ed29
Showing
11 changed files
with
477 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
v1.0 - 24/04/2015 : Creation | ||
v1.1 - 04/05/2015 : Html tag attributes and javascript optimization | ||
v1.2 - 07/06/2015 : Add Multi Lang support | ||
v1.2.1 - 15/07/2015 : Correction of a select group display bug when a special case occured. | ||
v1.2.2 - 16/07/2015 : Update logo in code and screenshots | ||
v1.3 - 07/11/2015 : Add Automatic Configuration | ||
v1.4 - 13/12/2015 : Add Effects scripts | ||
v1.4.1 - 28/12/2015 : Correction to manage white only lights (='dimmable light' type) | ||
v1.5 - 11/09/2016 : | ||
- Add Sensors Rules management | ||
- Update color conversion with new formulas from meethue | ||
- Add 'on' status in setcolor/getcolor effect execution (not only color status) | ||
- Update sample effects with save/restore original status | ||
- Correct some minor display bugs | ||
v1.4.2 - 05/05/2016 : add new effect sample | ||
v1.5 - 05/03/2016 : | ||
- Add Sensors Rules management | ||
- Update color conversion with new formulas from meethue | ||
- Now, manage also 'on' status in setcolor/getcolor effect execution (not only color status) | ||
- Update some sample effects with save/restore original status | ||
v1.4.1 - 28/12/2015 : Correction to manage white only lights (='dimmable light' type) | ||
v1.4 - 13/12/2015 : Add Effects scripts | ||
v1.3 - 07/11/2015 : Add Automatic Configuration | ||
v1.2.2 - 16/07/2015 : Update logo in code and screenshots | ||
v1.2.1 - 15/07/2015 : Correction of a select group display bug when a special case occured. | ||
v1.2 - 07/06/2015 : Add Multi Lang support | ||
v1.1 - 04/05/2015 : Html tag attributes and javascript optimization | ||
v1.0 - 24/04/2015 : Creation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,26 @@ | |
$('#detail').hide("slide"); | ||
</SCRIPT> | ||
<DIV ID=about>phpMyHue 1.5<BR> | ||
© <A HREF="mailto:[email protected]" CLASS=about>F. Bardin</A> 03-2016<BR> | ||
© <A HREF="mailto:[email protected]" CLASS=about>F. Bardin</A> 09-2016<BR> | ||
<small> | ||
Bridge IP : <?php echo $bridgeip?><BR> | ||
Current language : <?php echo $lang?> | ||
<BR><DIV ID=histo> | ||
<H3><?php echo $trs['Histo']?></H3> | ||
<DIV> | ||
<?php | ||
$histo = @file("HISTO.txt"); | ||
foreach ($histo as $num => $line){ | ||
$line = preg_replace("/^(v.*) - /","<B>$1</B> - ",$line); | ||
echo "$line<BR>\n"; | ||
} | ||
?> | ||
</DIV></DIV> | ||
</small></DIV> | ||
<SCRIPT> | ||
$('#histo').accordion({ | ||
collapsible: true, | ||
heightStyle: "content", | ||
active: false | ||
}); | ||
</SCRIPT> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
<?php | ||
// ===================================================== | ||
// Rules details for simplified ZGPSwitch management | ||
// Included from rules_details.php | ||
// Include js functions getConditionsJson and getActionsJson which are used during an update. | ||
// These functions are specific to each rules display (simple or advanced) | ||
// ----------------------------------------------------- | ||
// F. Bardin 2016/08/26 | ||
// ===================================================== | ||
// Anti-hack | ||
if (! defined('ANTI_HACK')){exit;} | ||
|
||
// Get rule conditions | ||
// For Hue Tap : | ||
// - 1 condition to detect last pressed button (operator 'eq') | ||
// - 1 condition to detect that previous conditon has changed (operator 'dx') | ||
// Look for value of pressed button | ||
$butval = ""; | ||
foreach ($srules[$selruleid]['conditions'] as $cond => $cval){ | ||
if ($cval['operator'] == "eq"){ | ||
$butval = $cval['value']; | ||
break; | ||
} | ||
} | ||
|
||
// Get rule actions | ||
// For Hue Tap : managed action is scene display or switch off lights (only 1 action allowed to stay simple, several actions wouldn't be very logical) | ||
$selsceneid=""; | ||
$selgroupid=""; | ||
$htmode = "sc"; | ||
foreach ($srules[$selruleid]['actions'] as $act => $aval){ | ||
if (isset($aval['body']['scene'])){ | ||
$htmode = "sc"; | ||
$selsceneid = $aval['body']['scene']; | ||
} elseif (isset($aval['body']['on'])){ | ||
$selgroupid = preg_replace("/\/groups\/(.*)\/action/","$1", $aval['address']); | ||
if ($aval['body']['on']==""){$htmode = "off";} | ||
else {$htmode = "on";} | ||
} | ||
} | ||
|
||
echo "<FIELDSET CLASS=\"ui-widget-content ui-corner-all\">"; | ||
echo "<TABLE><TR>"; | ||
echo "<TD>"; | ||
|
||
// Hue Tap button selection : Event value to button value is 34=1, 16=2, 17=3, 18=4 | ||
echo "<SELECT ID=selbutton>"; | ||
echo "<OPTION>".$trs["Select"]." ".$trs["Button"]."</OPTION>"; | ||
echo "<OPTION VALUE=34"; | ||
if ($butval == "34"){echo " SELECTED";} | ||
echo ">".$trs["Button"]." 1</OPTION>"; | ||
echo "<OPTION VALUE=16"; | ||
if ($butval == "16"){echo " SELECTED";} | ||
echo ">".$trs["Button"]." 2</OPTION>"; | ||
echo "<OPTION VALUE=17"; | ||
if ($butval == "17"){echo " SELECTED";} | ||
echo ">".$trs["Button"]." 3</OPTION>"; | ||
echo "<OPTION VALUE=18"; | ||
if ($butval == "18"){echo " SELECTED";} | ||
echo ">".$trs["Button"]." 4</OPTION>"; | ||
echo "</SELECT>"; | ||
|
||
// Action : Scene or lights group on/off | ||
echo "<TD>"; | ||
echo "<DIV ID=htradio>"; | ||
echo "<INPUT TYPE=radio NAME=htradio ID=scenemode VALUE=sc"; | ||
if ($htmode == "sc"){echo " CHECKED=checked";} | ||
echo "><LABEL FOR=scenemode>".$trs["Scenes"]."</LABEL>"; | ||
echo "<INPUT TYPE=radio NAME=htradio ID=onmode VALUE=on"; | ||
if ($htmode == "on"){echo " CHECKED=checked";} | ||
echo "><LABEL FOR=onmode>".$trs["Lights"]." ".$trs["On"]."</LABEL>"; | ||
echo "<INPUT TYPE=radio NAME=htradio ID=offmode VALUE=off"; | ||
if ($htmode == "off"){echo " CHECKED=checked";} | ||
echo "><LABEL FOR=offmode>".$trs["Lights"]." ".$trs["Off"]."</LABEL>"; | ||
echo "</DIV>"; // htradio | ||
|
||
echo "<TR>"; | ||
echo "<TD>"; | ||
echo "<TD>"; | ||
// Scenes list | ||
$HueAPI->loadInfo("scenes"); | ||
// Create id->name array | ||
$a_sname=""; | ||
foreach ($HueAPI->info['scenes'] as $sceneid => $sval){ | ||
$a_sname[$sceneid] = $sval['name']; | ||
} | ||
asort($a_sname); | ||
// Display scenes list | ||
echo "<SELECT ID=selhtsc>"; | ||
echo "<OPTION>".$trs["Select"]." ".$trs["Scene"]."</OPTION>"; | ||
foreach ($a_sname as $sceneid => $sname){ | ||
echo "<OPTION VALUE=$sceneid"; | ||
if ($sceneid == $selsceneid){echo " SELECTED";} | ||
echo ">$sname (".count($HueAPI->info['scenes'][$sceneid]['lights'])." ".$trs["Lights"].")"; | ||
echo "</OPTION>"; | ||
} | ||
echo "</SELECT>"; | ||
|
||
// On/Off list (all+groups) | ||
$HueAPI->loadInfo("groups"); | ||
createGroupList($selgroupid, "selhton", " ".$trs["On"]); | ||
createGroupList($selgroupid, "selhtoff", " ".$trs["Off"]); | ||
|
||
echo "</TABLE>"; | ||
echo "</FIELDSET>"; | ||
|
||
//------------------------------------------------------ | ||
// Create a group list for a defined action | ||
//------------------------------------------------------ | ||
function createGroupList($gid, $selid, $label_suffix){ | ||
global $trs,$HueAPI; | ||
|
||
echo "<SELECT ID=$selid>"; | ||
echo "<OPTION VALUE=0>".$trs["All"]."$label_suffix</OPTION>"; | ||
foreach ($HueAPI->info['groups'] as $gnum => $gval){ | ||
echo "<OPTION VALUE=$gnum"; | ||
if ($gid == $gnum){echo " SELECTED";} | ||
echo ">".$gval['name']."$label_suffix</OPTION>"; | ||
} | ||
echo "</SELECT>"; | ||
} // createGroupList | ||
|
||
?> | ||
<SCRIPT> | ||
$("#selbutton").selectmenu({width : 'auto'}); | ||
$("#htradio").buttonset({width : 'auto'}); | ||
$("#selhtsc").selectmenu({width : 'auto'}).selectmenu("menuWidget").addClass("overflow"); | ||
$("#selhton").selectmenu({width : 'auto'}); | ||
$("#selhtoff").selectmenu({width : 'auto'}); | ||
|
||
// Hide scene or on/off selectmenu at init | ||
switch ($("#htradio [name=htradio]:checked").val()){ | ||
case "sc" : | ||
$("#selhton").selectmenu("widget").hide(); | ||
$("#selhtoff").selectmenu("widget").hide(); | ||
break; | ||
case "on" : | ||
$("#selhtsc").selectmenu("widget").hide(); | ||
$("#selhtoff").selectmenu("widget").hide(); | ||
break; | ||
case "off" : | ||
$("#selhtsc").selectmenu("widget").hide(); | ||
$("#selhton").selectmenu("widget").hide(); | ||
break; | ||
} | ||
|
||
// Trigger change for action and hide/show selectmenu | ||
$("#htradio [name=htradio]").change(function(){ | ||
switch ($("#htradio [name=htradio]:checked").val()){ | ||
case "sc" : | ||
$("#selhton").selectmenu("widget").hide(); | ||
$("#selhtoff").selectmenu("widget").hide(); | ||
$("#selhtsc").selectmenu("widget").show(); | ||
break; | ||
case "on" : | ||
$("#selhtsc").selectmenu("widget").hide(); | ||
$("#selhtoff").selectmenu("widget").hide(); | ||
$("#selhton").selectmenu("widget").show(); | ||
break; | ||
case "off" : | ||
$("#selhtsc").selectmenu("widget").hide(); | ||
$("#selhton").selectmenu("widget").hide(); | ||
$("#selhtoff").selectmenu("widget").show(); | ||
break; | ||
} | ||
}); | ||
|
||
//----------------------------------------------------- | ||
// Get conditions json from displayed screen | ||
// (Specific to each display advanced or simplified) | ||
// Parameter : sensorid (required) | ||
// Return : json string for rule conditions | ||
//----------------------------------------------------- | ||
function getConditionsJson(sensorid){ | ||
var cond,value; | ||
|
||
value = $("#selbutton").val(); | ||
cond = '{"address":"/sensors/'+sensorid+'/state/buttonevent","operator":"eq","value":"'+value+'"},'; | ||
cond += '{"address":"/sensors/'+sensorid+'/state/lastupdated","operator":"dx"}'; | ||
|
||
return cond; | ||
} // getConditionsJson | ||
|
||
//----------------------------------------------------- | ||
// Get actions json from displayed screen | ||
// (Specific to each display advanced or simplified) | ||
// Return : json string for rule actions | ||
//----------------------------------------------------- | ||
function getActionsJson(){ | ||
var act,body,gid; | ||
|
||
switch ($("#htradio [name=htradio]:checked").val()){ | ||
case "sc" : | ||
gid = 0; | ||
var sceneid = $("#selhtsc").val(); | ||
body = '"scene":"'+sceneid+'"'; | ||
break; | ||
case "on" : | ||
gid = $("#selhton").val(); | ||
body = '"on":true'; | ||
break; | ||
case "off" : | ||
gid = $("#selhtoff").val(); | ||
body = '"on":false'; | ||
break; | ||
} | ||
|
||
act = '{"address":"/groups/'+gid+'/action","method":"PUT","body":{'+body+'}}'; | ||
return act; | ||
} // getActionsJson | ||
</SCRIPT> |
Oops, something went wrong.