Bonjour,
J’ai remarqué un fonctionnement embêtant lorsque l’on allume des lampes avec la commande On.
Celle-ci ne reprend pas son état antérieur.
Pour corriger cela j’ai effectué quelques correctifs dans la fonction execute du plugin.
Celui-ci n’étant pas disponible en github je ne peux pas pousser les modifications, voici donc la fonction ici.
Les modifications concernent surtout le placement du On et du TransitionTime.
Cédric
public function execute($_options = null) {
if ($this->getType() != 'action') {
return;
}
$eqLogic = $this->getEqLogic();
$hue = philipsHue::getPhilipsHue();
if ($eqLogic->getConfiguration('category') == 'sensor') {
$sensors = philipsHue::sanitizeSensors($hue->getSensors());
if (!isset($sensors[$eqLogic->getConfiguration('id')])) {
return;
}
$sensor = $sensors[$eqLogic->getConfiguration('id')];
foreach ($sensor as $mine) {
foreach ($this->getConfiguration('toUpdate') as $value) {
if (isset($value['onType']) && $value['onType'] != $mine->getType()) {
continue;
}
$toSet = $value['value'];
if (isset($value['valueType'])) {
switch ($value['valueType']) {
case 'boolean':
$toSet = (boolean) $value['value'];
break;
case 'int':
$toSet = (int) $value['value'];
break;
}
}
if ($value['type'] == 'config') {
$command = new \Phue\Command\UpdateSensorConfig($mine);
$command = $command->configAttribute($value['key'], $toSet);
$hue->sendCommand($command);
}
}
}
return;
}
$transition = $eqLogic->getCmd(null, 'transition_state');
$transistion_time = 0;
if (is_object($transition)) {
$transistion_time = $transition->execCmd(null, 2);
if ($transistion_time !== 0) {
$transition->event(0);
}
}
$transistion_time = ($transistion_time == 0) ? 1 : $transistion_time;
switch ($eqLogic->getConfiguration('category')) {
case 'light':
$command = new \Phue\Command\SetLightState($eqLogic->getConfiguration('id'));
break;
case 'group':
$command = new \Phue\Command\SetGroupState($eqLogic->getConfiguration('id', 0));
break;
default:
return;
}
//$command->transitionTime($transistion_time);
$command->on(true);
if ($this->getLogicalId() != 'animation' && $eqLogic->getCache('current_animate', 0) == 1) {
$eqLogic->stopAnimation();
}
switch ($this->getLogicalId()) {
case 'on':
$command->on(true);
$command->transitionTime($transistion_time);
//$command->brightness(255);
//$command->rgb(255, 255, 255);
break;
case 'off':
//if ($eqLogic->getConfiguration('model') != "LWB004") {
//$command->effect('none');
//}
//$command->alert('none');
$command->on(false);
break;
case 'luminosity':
if ($_options['slider'] == 0) {
if ($eqLogic->getConfiguration('model') != "LWB004") {
$command->effect('none');
}
$command->alert('none');
$command->on(false);
} else {
$command->brightness($_options['slider']);
$command->transitionTime($transistion_time);
}
break;
case 'color_temp':
$command->colorTemp((int) $_options['slider']);
$command->transitionTime($transistion_time);
break;
case 'color':
if ($_options['color'] == '#000000') {
if ($eqLogic->getConfiguration('model') != "LWB004") {
$command->effect('none');
}
$command->alert('none');
$command->on(false);
} else {
list($r, $g, $b) = str_split(str_replace('#', '', $_options['color']), 2);
$command->rgb(hexdec($r), hexdec($g), hexdec($b));
$command->transitionTime($transistion_time);
}
break;
case 'alert_on':
$command->alert('lselect');
break;
case 'alert_off':
$command->alert('none');
break;
case 'rainbow_on':
$command->effect('colorloop');
$command->transitionTime($transistion_time);
break;
case 'rainbow_off':
$command->effect('none');
$command->transitionTime($transistion_time);
break;
case 'transition':
if (is_object($transition)) {
$transition->event($_options['slider']);
}
return;
case 'scene':
$command->scene($_options['select']);
$command->transitionTime($transistion_time);
break;
case 'animation':
$eqLogic->animation($_options['title'], $_options['message']);
$command->transitionTime($transistion_time);
return;
}
$hue->sendCommand($command);
}