
john56 a écrit:Il est au taquet, c'est son petit bébé
P@t a écrit:john56 a écrit:Il est au taquet, c'est son petit bébé
J'aime surtout les choses bien faites, et surtout, j'aimerai passer à autre chose
Mon prochain plugin, normalement, devrait permettre de récupérer l'historique d'un compteur Linky via l'API du site d'Enedis (malheureusement, les données ne sont pas disponibles en temps réel, mais à J-1)
<?
$ip = 'xxx.xxx.xxx.xxx';
$milight = new sdk_Milight($ip);
$milight->sdk_rgbwAllOn();
$milight->sdk_rgbwAllSetToWhite();
$milight->sdk_rgbwAllBrightnessMax();
sleep(2);
$milight->sdk_setRgbwActiveGroup(1);
$milight->sdk_rgbwBrightnessPercent(50);
sleep(2);
$milight->sdk_setRgbwActiveGroup(2);
$milight->sdk_rgbwSetColorHexString('FF1254'); // or #FF1254
$milight->sdk_rgbwBrightnessPercent(90);
sleep(2);
$milight->sdk_whiteAllOn();
$milight->sdk_whiteAllBrightnessMax();
sleep(2);
$milight->sdk_whiteGroup1NightMode();
sleep(2);
$milight->sdk_setWhiteActiveGroup(2);
$milight->sdk_whiteWarmIncrease();
$milight->sdk_whiteWarmIncrease();
$milight->sdk_whiteWarmIncrease();
class sdk_Milight
{
private $host;
private $port;
private $delay = 10000; //microseconds
private $command_repeats = 10;
private $rgbwActiveGroup = 0; // 0 means all
private $whiteActiveGroup = 0; // 0 means all
private $commandCodes = array(
//RGBW Bulb commands
'rgbwAllOn' => array(0x42, 0x00),
'rgbwAllOff' => array(0x41, 0x00),
'rgbwGroup0Off' => array(0x41, 0x00),
'rgbwGroup0On' => array(0x42, 0x00),
'rgbwGroup1On' => array(0x45, 0x00),
'rgbwGroup2On' => array(0x47, 0x00),
'rgbwGroup3On' => array(0x49, 0x00),
'rgbwGroup4On' => array(0x4B, 0x00),
'rgbwGroup1Off' => array(0x46, 0x00),
'rgbwGroup2Off' => array(0x48, 0x00),
'rgbwGroup3Off' => array(0x4a, 0x00),
'rgbwGroup4Off' => array(0x4c, 0x00),
'rgbwAllNightMode' => array(0xC1, 0x00),
'rgbwGroup0NightMode' => array(0xC1, 0x00),
'rgbwGroup1NightMode' => array(0xC6, 0x00),
'rgbwGroup2NightMode' => array(0xC8, 0x00),
'rgbwGroup3NightMode' => array(0xCA, 0x00),
'rgbwGroup4NightMode' => array(0xCC, 0x00),
'rgbwBrightnessMax' => array(0x4e, 0x1b),
'rgbwBrightnessMin' => array(0x4e, 0x02),
'rgbwDiscoMode' => array(0x4d, 0x00),
'rgbwDiscoSlower' => array(0x43, 0x00),
'rgbwDiscoFaster' => array(0x44, 0x00),
'rgbwAllSetToWhite' => array(0xc2, 0x00),
'rgbwGroup0SetToWhite' => array(0xc2, 0x00),
'rgbwGroup1SetToWhite' => array(0xc5, 0x00),
'rgbwGroup2SetToWhite' => array(0xc7, 0x00),
'rgbwGroup3SetToWhite' => array(0xc9, 0x00),
'rgbwGroup4SetToWhite' => array(0xcb, 0x00),
'rgbwSetColorToViolet' => array(0x40, 0x00),
'rgbwSetColorToRoyalBlue' => array(0x40, 0x10),
'rgbwSetColorToBabyBlue' => array(0x40, 0x20),
'rgbwSetColorToAqua' => array(0x40, 0x30),
'rgbwSetColorToRoyalMint' => array(0x40, 0x40),
'rgbwSetColorToSeafoamGreen' => array(0x40, 0x50),
'rgbwSetColorToGreen' => array(0x40, 0x60),
'rgbwSetColorToLimeGreen' => array(0x40, 0x70),
'rgbwSetColorToYellow' => array(0x40, 0x80),
'rgbwSetColorToYellowOrange' => array(0x40, 0x90),
'rgbwSetColorToOrange' => array(0x40, 0xa0),
'rgbwSetColorToRed' => array(0x40, 0xb0),
'rgbwSetColorToPink' => array(0x40, 0xc0),
'rgbwSetColorToFusia' => array(0x40, 0xd0),
'rgbwSetColorToLilac' => array(0x40, 0xe0),
'rgbwSetColorToLavendar' => array(0x40, 0xf0),
// White Bulb commands
'whiteAllOn' => array(0x35, 0x00),
'whiteAllOff' => array(0x39, 0x00),
'whiteGroup0On' => array(0x35, 0x00),
'whiteGroup0Off' => array(0x39, 0x00),
'whiteBrightnessUp' => array(0x3c, 0x00),
'whiteBrightnessDown' => array(0x34, 0x00),
'whiteGroup0BrightnessMax' => array(0xb5, 0x00),
'whiteGroup0NightMode' => array(0xbb, 0x00),
'whiteAllBrightnessMax' => array(0xb5, 0x00),
'whiteAllNightMode' => array(0xbb, 0x00),
'whiteWarmIncrease' => array(0x3e, 0x00),
'whiteCoolIncrease' => array(0x3f, 0x00),
'whiteGroup1On' => array(0x38, 0x00),
'whiteGroup1Off' => array(0x3b, 0x00),
'whiteGroup2On' => array(0x3d, 0x00),
'whiteGroup2Off' => array(0x33, 0x00),
'whiteGroup3On' => array(0x37, 0x00),
'whiteGroup3Off' => array(0x3a, 0x00),
'whiteGroup4On' => array(0x32, 0x00),
'whiteGroup4Off' => array(0x36, 0x00),
'whiteGroup1BrightnessMax' => array(0xb8, 0x00),
'whiteGroup2BrightnessMax' => array(0xbd, 0x00),
'whiteGroup3BrightnessMax' => array(0xb7, 0x00),
'whiteGroup4BrightnessMax' => array(0xb2, 0x00),
'whiteGroup1NightMode' => array(0xbb, 0x00),
'whiteGroup2NightMode' => array(0xb3, 0x00),
'whiteGroup3NightMode' => array(0xba, 0x00),
'whiteGroup4NightMode' => array(0xb6, 0x00),
);
/**
* @param int $delay
*/
public function sdk_setDelay($delay)
{
$this->delay = $delay;
}
/**
* @return int
*/
public function sdk_getDelay()
{
return $this->delay;
}
public function sdk_setRepeats($repeats)
{
$this->command_repeats = $repeats;
}
public function sdk_setActiveGroup($Group)
{
if ($Group < 0 || $Group > 4)
{
die('Active group must be between 0 and 4. 0 means all groups');
}
return $Group;
}
/**
* @param int $rgbwActiveGroup
* @throws Exception
*/
public function sdk_setRgbwActiveGroup($rgbwActiveGroup)
{
$this->rgbwActiveGroup = $this->sdk_setActiveGroup($rgbwActiveGroup);
}
// Same as setRgbwActiveGroup. Exists just to make method invocation easier according to the convention
/**
* @param int $rgbwActiveGroup
* @throws Exception
*/
public function sdk_rgbwSetActiveGroup($rgbwActiveGroup)
{
$this->sdk_setRgbwActiveGroup($rgbwActiveGroup);
}
/**
* @throws Exception
* @return int
*/
private function sdk_getRgbwActiveGroup()
{
return $this->rgbwActiveGroup;
}
/**
* @param int $whiteActiveGroup
* @throws Exception
*/
public function sdk_setWhiteActiveGroup($whiteActiveGroup)
{
$this->whiteActiveGroup = $this->sdk_setActiveGroup($whiteActiveGroup);
}
// Same as setWhiteActiveGroup. Exists just to make method invocation easier according to the convention
/**
* @param int $whiteActiveGroup
* @throws Exception
*/
public function sdk_whiteSetActiveGroup($whiteActiveGroup)
{
$this->sdk_setWhiteActiveGroup($whiteActiveGroup);
}
/**
* @throws Exception
* @return int
*/
public function sdk_getWhiteActiveGroup()
{
return $this->whiteActiveGroup;
}
public function sdk___construct($host = '10.10.100.254', $port = 8899)
{
$this->host = $host;
$this->port = $port;
}
public function sdk_sendCommand(Array $command)
{
$command[] = 0x55; // last byte is always 0x55, will be appended to all commands
$message = vsprintf(str_repeat('%c', count($command)), $command);
for($repetition=0; $repetition<$this->command_repeats; $repetition++)
{
if ($socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))
{
socket_sendto($socket, $message, strlen($message), 0, $this->host, $this->port);
socket_close($socket);
usleep($this->sdk_getDelay()); //wait 100ms before sending next command
}
}
}
public function sdk_command($commandName)
{
$this->sdk_sendCommand($this->commandCodes[$commandName]);
}
public function sdk_rgbwSendOnToActiveGroup() {
$this->sdk_rgbwSendOnToGroup($this->sdk_getRgbwActiveGroup());
}
public function sdk_rgbwSendOnToGroup($group) {
$activeGroupOnCommand = 'rgbwGroup' . $group . 'On';
$this->sdk_command($activeGroupOnCommand);
}
public function sdk_rgbwSendOffToGroup($group) {
$activeGroupOffCommand = 'rgbwGroup' . $group . 'Off';
$this->sdk_command($activeGroupOffCommand);
}
public function sdk_rgbwSetGroupToWhite($group) {
$activeCommand = 'rgbwGroup' . $group . 'SetToWhite';
$this->sdk_command($activeCommand);
}
public function sdk_rgbwSetGroupToNightMode($group) {
$this->sdk_rgbwSendOffToGroup($group);
$activeCommand = 'rgbwGroup' . $group . 'NightMode';
$this->sdk_command($activeCommand);
}
public function sdk_whiteSendOnToGroup($group) {
$activeGroupOnCommand = 'whiteGroup' . $group . 'On';
$this->sdk_command($activeGroupOnCommand);
}
public function sdk_whiteSendOffToGroup($group) {
$activeGroupOffCommand = 'whiteGroup' . $group . 'Off';
$this->sdk_command($activeGroupOffCommand);
}
public function sdk_whiteSetGroupToNightMode($group) {
$activeCommand = 'whiteGroup' . $group . 'NightMode';
$this->sdk_command($activeCommand);
}
public function sdk_whiteSendOnToActiveGroup() {
$this->sdk_whiteSendOnToGroup($this->sdk_getWhiteActiveGroup());
}
public function sdk_rgbwAllOn()
{
$this->sdk_command('rgbwAllOn');
}
public function sdk_rgbwAllOff()
{
$this->sdk_command('rgbwAllOff');
}
public function sdk_rgbwGroup1On()
{
$this->sdk_command('rgbwGroup1On');
}
public function sdk_rgbwGroup2On()
{
$this->sdk_command('rgbwGroup2On');
}
public function sdk_rgbwGroup3On()
{
$this->sdk_command('rgbwGroup3On');
}
public function sdk_rgbwGroup4On()
{
$this->sdk_command('rgbwGroup4On');
}
public function sdk_rgbwGroup1Off()
{
$this->sdk_command('rgbwGroup1Off');
}
public function sdk_rgbwGroup2Off()
{
$this->sdk_command('rgbwGroup2Off');
}
public function sdk_rgbwGroup3Off()
{
$this->sdk_command('rgbwGroup3Off');
}
public function sdk_rgbwGroup4Off()
{
$this->sdk_command('rgbwGroup4Off');
}
public function sdk_rgbwAllNightMode()
{
$this->sdk_rgbwAlloff();
$this->sdk_command('rgbwAllNightMode');
}
public function sdk_rgbwGroup1NightMode()
{
$this->sdk_rgbwGroup1off();
$this->sdk_command('rgbwGroup1NightMode');
}
public function sdk_rgbwGroup2NightMode()
{
$this->sdk_rgbwGroup2off();
$this->sdk_command('rgbwGroup2NightMode');
}
public function sdk_rgbwGroup3NightMode()
{
$this->sdk_rgbwGroup3off();
$this->sdk_command('rgbwGroup3NightMode');
}
public function sdk_rgbwGroup4NightMode()
{
$this->sdk_rgbwGroup4off();
$this->sdk_command('rgbwGroup4NightMode');
}
public function sdk_rgbwBrightnessMax()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMax');
}
public function sdk_rgbwBrightnessMin()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMin');
}
public function sdk_rgbwAllBrightnessMin()
{
$this->sdk_setRgbwActiveGroup(0);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMin');
}
public function sdk_rgbwAllBrightnessMax()
{
$this->sdk_setRgbwActiveGroup(0);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMax');
}
public function sdk_rgbwGroup1BrightnessMax()
{
$this->sdk_setRgbwActiveGroup(1);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMax');
}
public function sdk_rgbwGroup2BrightnessMax()
{
$this->sdk_setRgbwActiveGroup(2);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMax');
}
public function sdk_rgbwGroup3BrightnessMax()
{
$this->sdk_setRgbwActiveGroup(3);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMax');
}
public function sdk_rgbwGroup4BrightnessMax()
{
$this->sdk_setRgbwActiveGroup(4);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMax');
}
public function sdk_rgbwGroup1BrightnessMin()
{
$this->sdk_setRgbwActiveGroup(1);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMin');
}
public function sdk_rgbwGroup2BrightnessMin()
{
$this->sdk_setRgbwActiveGroup(2);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMin');
}
public function sdk_rgbwGroup3BrightnessMin()
{
$this->sdk_setRgbwActiveGroup(3);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMin');
}
public function sdk_rgbwGroup4BrightnessMin()
{
$this->sdk_setRgbwActiveGroup(4);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwBrightnessMin');
}
public function sdk_rgbwBrightnessPercent($brightnessPercent,$group=null) {
if ($brightnessPercent < 0 || $brightnessPercent > 100) {
die('Brightness percent must be between 0 and 100');
}
$brightnessPercent = round(2+(($brightnessPercent/100)*25));
$group = isset($group) ? $group : $this->sdk_getRgbwActiveGroup();
$this->sdk_rgbwSendOnToGroup($group);
$this->sdk_sendCommand(array(0x4e, $brightnessPercent));
}
public function sdk_rgbwDiscoMode()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwDiscoMode');
}
public function sdk_rgbwDiscoSlower()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwDiscoSlower');
}
public function sdk_rgbwDiscoFaster()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwDiscoFaster');
}
public function sdk_rgbwAllSetToWhite()
{
$this->sdk_command('rgbwAllSetToWhite');
}
public function sdk_rgbwGroup1SetToWhite()
{
$this->sdk_command('rgbwGroup1SetToWhite');
}
public function sdk_rgbwGroup2SetToWhite()
{
$this->sdk_command('rgbwGroup2SetToWhite');
}
public function sdk_rgbwGroup3SetToWhite()
{
$this->sdk_command('rgbwGroup3SetToWhite');
}
public function sdk_rgbwGroup4SetToWhite()
{
$this->sdk_command('rgbwGroup4SetToWhite');
}
public function sdk_rgbwSetColorToViolet()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToViolet');
}
public function sdk_rgbwSetColorToRoyalBlue()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToRoyalBlue');
}
public function sdk_rgbwSetColorToBabyBlue()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToBabyBlue');
}
/**
* Sets color of the currently active group to white.
*/
public function sdk_rgbwSetColorToWhite()
{
if ($this->sdk_getRgbwActiveGroup() == 0) {
$this->sdk_rgbwAllSetToWhite();
return;
}
$this->sdk_command('rgbwGroup'.strval($this->sdk_getRgbwActiveGroup()).'SetToWhite');
}
public function sdk_rgbwSetColorToAqua()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToAqua');
}
public function sdk_rgbwSetColorToRoyalMint()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToRoyalMint');
}
public function sdk_rgbwSetColorToSeafoamGreen()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToSeafoamGreen');
}
public function sdk_rgbwSetColorToGreen()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToGreen');
}
public function sdk_rgbwSetColorToLimeGreen()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToLimeGreen');
}
public function sdk_rgbwSetColorToYellow()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToYellow');
}
public function sdk_rgbwSetColorToYellowOrange()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToYellowOrange');
}
public function sdk_rgbwSetColorToOrange()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToOrange');
}
public function sdk_rgbwSetColorToRed()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToRed');
}
public function sdk_rgbwSetColorToPink()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToPink');
}
public function sdk_rgbwSetColorToFusia()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToFusia');
}
public function sdk_rgbwSetColorToLilac()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToLilac');
}
public function sdk_rgbwSetColorToLavendar()
{
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_command('rgbwSetColorToLavendar');
}
public function sdk_whiteAllOn()
{
$this->sdk_command('whiteAllOn');
}
public function sdk_whiteAllOff()
{
$this->sdk_command('whiteAllOff');
}
public function sdk_whiteBrightnessUp()
{
$this->sdk_whiteSendOnToActiveGroup();
$this->sdk_command('whiteBrightnessUp');
}
public function sdk_whiteBrightnessDown()
{
$this->sdk_whiteSendOnToActiveGroup();
$this->sdk_command('whiteBrightnessDown');
}
public function sdk_whiteAllBrightnessMax()
{
$this->sdk_command('whiteAllBrightnessMax');
}
public function sdk_whiteAllBrightnessMin()
{
$this->sdk_setWhiteActiveGroup(0);
$this->sdk_whiteSendOnToActiveGroup();
for ($i = 0; $i < 10; $i++) {
$this->sdk_command('whiteBrightnessDown');
}
}
public function sdk_whiteAllNightMode()
{
$this->sdk_command('whiteAllNightMode');
}
public function sdk_whiteWarmIncrease()
{
$this->sdk_whiteSendOnToActiveGroup();
$this->sdk_command('whiteWarmIncrease');
}
public function sdk_whiteCoolIncrease()
{
$this->sdk_whiteSendOnToActiveGroup();
$this->sdk_command('whiteCoolIncrease');
}
public function sdk_whiteGroup1On()
{
$this->sdk_command('whiteGroup1On');
}
public function sdk_whiteGroup1Off()
{
$this->sdk_command('whiteGroup1Off');
}
public function sdk_whiteGroup2On()
{
$this->sdk_command('whiteGroup2On');
}
public function sdk_whiteGroup2Off()
{
$this->sdk_command('whiteGroup2Off');
}
public function sdk_whiteGroup3On()
{
$this->sdk_command('whiteGroup3On');
}
public function sdk_whiteGroup3Off()
{
$this->sdk_command('whiteGroup3Off');
}
public function sdk_whiteGroup4On()
{
$this->sdk_command('whiteGroup4On');
}
public function sdk_whiteGroup4Off()
{
$this->sdk_command('whiteGroup4Off');
}
public function sdk_whiteGroup1BrightnessMax()
{
$this->sdk_command('whiteGroup1BrightnessMax');
}
public function sdk_whiteGroup2BrightnessMax()
{
$this->sdk_command('whiteGroup2BrightnessMax');
}
public function sdk_whiteGroup3BrightnessMax()
{
$this->sdk_command('whiteGroup3BrightnessMax');
}
public function sdk_whiteGroup4BrightnessMax()
{
$this->sdk_command('whiteGroup4BrightnessMax');
}
public function sdk_whiteGroup1BrightnessMin()
{
$this->sdk_setWhiteActiveGroup(1);
$this->sdk_whiteSendOnToActiveGroup();
for ($i = 0; $i < 10; $i++) {
$this->sdk_command('whiteBrightnessDown');
}
}
public function sdk_whiteGroup2BrightnessMin()
{
$this->sdk_setWhiteActiveGroup(2);
$this->sdk_whiteSendOnToActiveGroup();
for ($i = 0; $i < 10; $i++) {
$this->sdk_command('whiteBrightnessDown');
}
}
public function sdk_whiteGroup3BrightnessMin()
{
$this->sdk_setWhiteActiveGroup(3);
$this->sdk_whiteSendOnToActiveGroup();
for ($i = 0; $i < 10; $i++) {
$this->sdk_command('whiteBrightnessDown');
}
}
public function sdk_whiteGroup4BrightnessMin()
{
$this->sdk_setWhiteActiveGroup(4);
$this->sdk_whiteSendOnToActiveGroup();
for ($i = 0; $i < 10; $i++) {
$this->sdk_command('whiteBrightnessDown');
}
}
public function sdk_whiteGroup1NightMode()
{
$this->sdk_command('whiteGroup1NightMode');
}
public function sdk_whiteGroup2NightMode()
{
$this->sdk_command('whiteGroup2NightMode');
}
public function sdk_whiteGroup3NightMode()
{
$this->sdk_command('whiteGroup3NightMode');
}
public function sdk_whiteGroup4NightMode()
{
$this->sdk_command('whiteGroup4NightMode');
}
public function sdk_rgbwSetColorHsv(Array $hsvColor)
{
$milightColor = $this->sdk_hslToMilightColor($hsvColor);
$activeGroupOnCommand = 'rgbwGroup' . $this->sdk_getRgbwActiveGroup() . 'On';
$this->sdk_command($activeGroupOnCommand);
$this->sdk_sendCommand(array(0x40, $milightColor));
}
public function sdk_rgbwSetColorHexString($color)
{
$rgb = $this->sdk_rgbHexToIntArray($color);
$hsl = $this->sdk_rgbToHsl($rgb[0], $rgb[1], $rgb[2]);
$milightColor = $this->sdk_hslToMilightColor($hsl);
$this->sdk_rgbwSendOnToActiveGroup();
$this->sdk_sendCommand(array(0x40, $milightColor));
}
public function sdk_rgbHexToIntArray($hexColor)
{
$hexColor = str_replace('#', '', $hexColor);
$hexColorLenghth = strlen($hexColor);
if ($hexColorLenghth != 8 && $hexColorLenghth != 6) {
die('Color hex code must match 8 or 6 characters');
}
if ($hexColorLenghth == 8) {
$r = hexdec(substr($hexColor, 2, 2));
$g = hexdec(substr($hexColor, 4, 2));
$b = hexdec(substr($hexColor, 6, 2));
if (($r == 0 && $g == 0 && $b == 0) || ($r == 255 && $g == 255 && $b == 255)) {
die('Color cannot be black or white');
}
return array($r, $g, $b);
}
$r = hexdec(substr($hexColor, 0, 2));
$g = hexdec(substr($hexColor, 2, 2));
$b = hexdec(substr($hexColor, 4, 2));
if (($r == 0 && $g == 0 && $b == 0) || ($r == 255 && $g == 255 && $b == 255)) {
die('Color cannot be black or white');
}
return array($r, $g, $b);
}
public function sdk_rgbToHsl($r, $g, $b)
{
$r = $r / 255;
$g = $g / 255;
$b = $b / 255;
$max = max($r, $g, $b);
$min = min($r, $g, $b);
$l = ($max + $min) / 2;
$d = $max - $min;
$h = '';
if ($d == 0) {
$h = $s = 0;
} else {
$s = $d / (1 - abs(2 * $l - 1));
switch ($max) {
case $r:
$h = 60 * fmod((($g - $b) / $d), 6);
if ($b > $g) {
$h += 360;
}
break;
case $g:
$h = 60 * (($b - $r) / $d + 2);
break;
case $b:
$h = 60 * (($r - $g) / $d + 4);
break;
}
}
return array($h, $s, $l);
}
public function sdk_hslToMilightColor($hsl)
{
$color = (256 + 176 - (int)($hsl[0] / 360.0 * 255.0)) % 256;
return $color + 0xfa;
}
}
?>
anne-marie a écrit:Bon moi, depuis une semaine, j'ai un souci avec ma box qui me fait plein de time out sur mes requetes HTTP. Même la team ne comprend pas trop ce qui se passe
Il se trouve que ça recommence dès que j'installe une lampe yeelight mais je je pense que ça serait pareil avec un autre script.
socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>2, 'usec'=>0));
socket_set_option($sock, SOL_SOCKET, SO_SNDTIMEO, array('sec'=>2, 'usec'=>0));
anne-marie a écrit:Sinon, le mode moon ne marche pas sur mon plafonnier. Il ne se passe rien
sdk_send_command('set_power', array($value, $effect_type, $effect_duration, 5));
anne-marie a écrit:Sinon, le mode moon ne marche pas sur mon plafonnier. Il ne se passe rien
merguez07 a écrit:idem chez moi mais c'est peut être normal car j'ai une yeelight YLDP02YL
merguez07 a écrit:Après il me manque les modes Flash notify et music flow
fullpower a écrit:J'ai mis le script sur ma Eedomus (en y mettant l'IP du pont WIFI) ...mais bon ...
![]()
anne-marie a écrit:Curieux...Moon marche soudainement mais j'avais d'abord éteint la lampe. C'est probablement la raison.
Sinon, ça reste sur "en cours" pendant un bail même si l'action est déjà exécutée.
P@t. Merci pour les conseils. Je testerai demain matin car mes perroquets sont couchés![]()
D'où mes demandes particulières sur le mode lune
P@t a écrit:fullpower a écrit:J'ai mis le script sur ma Eedomus (en y mettant l'IP du pont WIFI) ...mais bon ...
![]()
Il ne se passe rien quand tu l'exécutes????
$milight = new sdk_Milight($ip);
$milight = new sdk_Milight();
$milight->sdk___construct($ip);
Retour vers Scripts & Périphériques du store
Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 23 invité(s)