Skip to content

Commit

Permalink
Merge pull request #87 from Mips2648/patch-gsh_ColorSetting
Browse files Browse the repository at this point in the history
Patch gsh color setting
  • Loading branch information
Mips2648 authored May 11, 2024
2 parents 55a79a7 + 712b493 commit ae17723
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 42 deletions.
79 changes: 39 additions & 40 deletions core/class/gsh_ColorSetting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';

class gsh_ColorSetting {

/* * *************************Attributs****************************** */

private static $_COLOR = array('LIGHT_SET_COLOR');
private static $_COLOR_STATE = array('LIGHT_COLOR');
private static $_COLOR_TEMP = array('LIGHT_SET_COLOR_TEMP');
private static $_COLOR_TEMP_STATE = array('LIGHT_COLOR_TEMP');

/* * ***********************Methode static*************************** */
public static function discover($_device,$_eqLogic){
$return = array('traits' => array(),'customData' => array());

public static function discover($_device, $_eqLogic) {
$return = array('traits' => array(), 'customData' => array());
foreach ($_eqLogic->getCmd() as $cmd) {
if (in_array($cmd->getGeneric_type(), self::$_COLOR)) {
if (!in_array('action.devices.traits.ColorSetting', $return['traits'])) {
Expand All @@ -43,7 +43,7 @@ public static function discover($_device,$_eqLogic){
}
$return['attributes']['colorModel'] = 'rgb';
}
if (in_array($cmd->getGeneric_type(),self::$_COLOR_TEMP)) {
if (in_array($cmd->getGeneric_type(), self::$_COLOR_TEMP)) {
if (!in_array('action.devices.traits.ColorSetting', $return['traits'])) {
$return['traits'][] = 'action.devices.traits.ColorSetting';
}
Expand All @@ -65,45 +65,45 @@ public static function discover($_device,$_eqLogic){
}
return $return;
}
public static function needGenericType(){

public static function needGenericType() {
return array(
__('Couleur',__FILE__) => self::$_COLOR,
__('Etat couleur',__FILE__) => self::$_COLOR_STATE,
__('Couleur', __FILE__) => self::$_COLOR,
__('Etat couleur', __FILE__) => self::$_COLOR_STATE,
);
}
public static function exec($_device, $_executions, $_infos){

public static function exec($_device, $_executions, $_infos) {
$return = array();
foreach ($_executions as $execution) {
try {
switch ($execution['command']) {
case 'action.devices.commands.ColorAbsolute':
if (isset($execution['params']['color']['spectrumRGB'])) {
if (isset($_infos['customData']['ColorSetting_cmdSetColor'])) {
$cmd = cmd::byId($_infos['customData']['ColorSetting_cmdSetColor']);
}
if(is_object($cmd)){
$cmd->execCmd(array('color' => '#' . str_pad(dechex($execution['params']['color']['spectrumRGB']), 6, '0', STR_PAD_LEFT)));
if (isset($execution['params']['color']['spectrumRGB'])) {
if (isset($_infos['customData']['ColorSetting_cmdSetColor'])) {
$cmd = cmd::byId($_infos['customData']['ColorSetting_cmdSetColor']);
}
if (is_object($cmd)) {
$cmd->execCmd(array('color' => '#' . str_pad(dechex($execution['params']['color']['spectrumRGB']), 6, '0', STR_PAD_LEFT)));
}
}
}
if (isset($execution['params']['color']['temperature'])) {
if (isset($_infos['customData']['ColorSetting_cmdSetTempColor'])) {
$cmd = cmd::byId($_infos['customData']['ColorSetting_cmdSetTempColor']);
if (isset($execution['params']['color']['temperature'])) {
if (isset($_infos['customData']['ColorSetting_cmdSetTempColor'])) {
$cmd = cmd::byId($_infos['customData']['ColorSetting_cmdSetTempColor']);
}
if (is_object($cmd)) {
$cmd->execCmd(array('slider' => $execution['params']['color']['temperature']));
}
}
if(is_object($cmd)){
$cmd->execCmd(array('slider' => $execution['params']['color']['temperature']));
$return = array('status' => 'SUCCESS');
if (isset($_infos['customData']['OnOff_cmdGetState'])) {
$state = cmd::byId($_infos['customData']['OnOff_cmdGetState']);
if (is_object($state)) {
sleep(1);
$return['on'] = boolval($state->execCmd());
}
}
}
$return = array('status' => 'SUCCESS');
if(isset($_infos['customData']['OnOff_cmdGetState'])){
$state = cmd::byId($_infos['customData']['OnOff_cmdGetState']);
if(is_object()){
sleep(1);
$return['on'] = boolval($state->execCmd());
}
}
break;
break;
}
} catch (Exception $e) {
log::add('gsh', 'error', $e->getMessage());
Expand All @@ -112,25 +112,24 @@ public static function exec($_device, $_executions, $_infos){
}
return $return;
}
public static function query($_device, $_infos){

public static function query($_device, $_infos) {
$return = array();
$cmd = null;
if (isset($_infos['customData']['ColorSetting_cmdGetColor'])) {
$cmd = cmd::byId($_infos['customData']['ColorSetting_cmdGetColor']);
if(!isset($return['color'])){
if (!isset($return['color'])) {
$return['color'] = array();
}
$return['color']['spectrumRGB'] = hexdec(str_replace('#', '', $cmd->execCmd()));
}
if (isset($_infos['customData']['ColorSetting_cmdGetTempColor'])) {
$cmd = cmd::byId($_infos['customData']['ColorSetting_cmdGetTempColor']);
if(!isset($return['color'])){
if (!isset($return['color'])) {
$return['color'] = array();
}
$return['color']['temperatureK'] = $cmd->execCmd();
}
return $return;
}

}
8 changes: 6 additions & 2 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
>
>Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte
# 09/05/2024

- Correction de bugs

# 29/04/2024

- Correction d'un bug avec Jeedom 4.4
- Version uniquement compatible avec Jeedom 4.4 ou plus
Expand Down Expand Up @@ -45,7 +50,7 @@
- Possibilité d'interdir toute requete de Google en fonction d'une condition
- Possibilité de ne pas avoir de code lors d'une demande de déverouillage d'une serrure

# 05/04/2021
# 05/04/2021

- Passage a nodejs 14

Expand Down Expand Up @@ -183,7 +188,6 @@
- Ajout du control de volumes et commande media (stop,pause,lecture,suivant,précedent) pour le type enceinte (nécessite jeedom 3.3.x ou plus)
- Correction d'un soucis de non désactivation de la transmission lors de la désactivation d'un équipement


# 07/01/2018

- Mise à jour de la documentation
Expand Down

0 comments on commit ae17723

Please sign in to comment.