[Store] Lampes et plafonniers Yeelight

Discussion et échanges de scripts pour la box eedomus

Re: [Store] Lampes et plafonniers Yeelight

Messagepar john56 » 14 Juin 2018 11:29

Il est au taquet, c'est son petit bébé :)
john56
 
Messages : 331
Inscription : 27 Nov 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 14 Juin 2018 16:09

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)
Dernière édition par P@t le 14 Juin 2018 16:13, édité 1 fois.
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 14 Juin 2018 16:12

La version 1.1.0 est disponible. Les valeurs "Non joignable" ont été rajoutées pour tous les périphériques, donc je vous invite à supprimer et réinstaller les lampes que vous avez déjà ajoutés dans eedomus: oui je sais, c'est pénible ;-)

Je vous rappelle également qu'en attendant la prochaine mise à jour eedomus, vous pouvez forcer la mise à jour en vous rendant sur http://IP_BOX_EEDOMUS/config afin d'avoir un fonctionnement correct du polling.
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar merguez07 » 14 Juin 2018 16:35

je viens de tester p@t, Nickel Chrome
merci mille fois
tuto 1 -->Programmation des scripts Eedomus
tuto 2 -->SmartDevice
tuto 3 -->Le déclenchement de règles
scripts -->Météo du jour | GH Thermostat | TotalWatt | Detecfire | smartbattery
Skype Eedomus -->lien vers le skype Eedomus
merguez07
 
Messages : 2346
Inscription : 15 Sep 2017
Localisation : Le Teil en Ardèche

Re: [Store] Lampes et plafonniers Yeelight

Messagepar fullpower » 14 Juin 2018 18:34

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)


Euh...tu veux pas nous faire un truc vite fait sur les Milight ?
C'est un peu l'equivalent des RGB Yeelight ...
:D
Programmation ARDUINO, NodeMCU, ESP8266 Eedomus + / Raspberry Pi 3 B + & Raspberry Pi 3 en programmation (Magic mirror)
Elegoo Mars - Artillery Sidewinder V2 - modélisation 3D sur Sketchup, Rhino 3d, Fusion 360, etc.
fullpower
 
Messages : 1161
Inscription : 11 Déc 2015
Localisation : Elsass

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 15 Juin 2018 14:35

Pour les Milight, j'ai trouvé ce script sur github écrit en php:
https://github.com/yasharrashedi/LimitlessLED

Je l'ai adapté vite fait pour le faire valider par la box eedomus (il n'y avait quasiment rien à faire à part préfixer les fonctions avec sdk_), mais je ne sais pas si ça marche... Voici le code si tu veux tester:
Code : Tout sélectionner
<?

$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;
   }
}

?>


Tu as juste à changer l'adresse IP (j'imagine que c'est celle du HUB Milight).
Pour les exemples de commandes (lignes 7 à 26), j'ai repris ceux sur Github.
Mais je te propose d'ouvrir un autre fil de discussion...
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar anne-marie » 15 Juin 2018 18:18

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.
Du coup, je suis vachement frustrée de ne pas pouvoir commander toutes mes yeelight :(
Sinon, le mode moon ne marche pas sur mon plafonnier. Il ne se passe rien
Netatmo - Nabaztag2 - Karotz - Mirror - caméras IP - Zwave - RFXCOM - zigate - ecodevice - Enocean - orvibo - connexoon- google Home - Echo - yeelight etc....
anne-marie
 
Messages : 2456
Inscription : 19 Fév 2014
Localisation : 77

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 15 Juin 2018 18:36

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.

Pour le timeout des commandes TCP du plugin yeelight, c'est réglé sur 5 secondes. Essaye de le baisser à 2 en changeant les lignes 348-349 du script:
Code : Tout sélectionner
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));

Parce que du coup, si tu fais un jumelage de 5 lampes par exemple, et qu'elles sont toutes éteintes, le script va poireauter au moins 25 secondes avec un timeout de 5 secondes par lampe...

anne-marie a écrit:Sinon, le mode moon ne marche pas sur mon plafonnier. Il ne se passe rien

Bizarre... la commande marchait chez fullpower, mais il me semble que tu avais utilisé l'autre méthode. Juste pour tester, essaye de modifier la ligne 364 du script en ajoutant un 5 dans les paramètres:
Code : Tout sélectionner
sdk_send_command('set_power', array($value, $effect_type, $effect_duration, 5));

Puis allume normalement ta lampe en mettant 25% par exemple.
Dernière édition par P@t le 15 Juin 2018 18:37, édité 2 fois.
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar merguez07 » 15 Juin 2018 18:36

anne-marie a écrit:Sinon, le mode moon ne marche pas sur mon plafonnier. Il ne se passe rien


idem chez moi mais c'est peut être normal car j'ai une yeelight YLDP02YL

Après il me manque les modes Flash notify et music flow
tuto 1 -->Programmation des scripts Eedomus
tuto 2 -->SmartDevice
tuto 3 -->Le déclenchement de règles
scripts -->Météo du jour | GH Thermostat | TotalWatt | Detecfire | smartbattery
Skype Eedomus -->lien vers le skype Eedomus
merguez07
 
Messages : 2346
Inscription : 15 Sep 2017
Localisation : Le Teil en Ardèche

Re: [Store] Lampes et plafonniers Yeelight

Messagepar fullpower » 15 Juin 2018 18:39

Merci P@t !

Je testerai bien ce script..mais là..c'est un peu comme donner un couteau à une poule...
:lol:
J'ai mis le script sur ma Eedomus (en y mettant l'IP du pont WIFI) ...mais bon ...
:roll:

Oui à l'occasion, j'ouvrirai un nouveau post pour les Milight ..pas de pb !
Programmation ARDUINO, NodeMCU, ESP8266 Eedomus + / Raspberry Pi 3 B + & Raspberry Pi 3 en programmation (Magic mirror)
Elegoo Mars - Artillery Sidewinder V2 - modélisation 3D sur Sketchup, Rhino 3d, Fusion 360, etc.
fullpower
 
Messages : 1161
Inscription : 11 Déc 2015
Localisation : Elsass

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 15 Juin 2018 18:42

merguez07 a écrit:idem chez moi mais c'est peut être normal car j'ai une yeelight YLDP02YL

Oui, le mode lune n'est présent que sur les plafonniers. Ca serait pas déjà mentionné lors de l'installation? ;-)

merguez07 a écrit:Après il me manque les modes Flash notify et music flow

Pour le flash notify, je n'ai pas réussit à trouver les paramètres correspondant malheureusement.
Et pour le music flow, il me semble que c'est le téléphone qui fait office de micro, non? Donc aucun intérêt dans eedomus (enfin, là, je suis pas sûr de mon coup...)
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 15 Juin 2018 18:42

fullpower a écrit:J'ai mis le script sur ma Eedomus (en y mettant l'IP du pont WIFI) ...mais bon ...
:roll:

Il ne se passe rien quand tu l'exécutes????
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar anne-marie » 15 Juin 2018 18:45

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
D'où mes demandes particulières sur le mode lune ;)
Netatmo - Nabaztag2 - Karotz - Mirror - caméras IP - Zwave - RFXCOM - zigate - ecodevice - Enocean - orvibo - connexoon- google Home - Echo - yeelight etc....
anne-marie
 
Messages : 2456
Inscription : 19 Fév 2014
Localisation : 77

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 15 Juin 2018 19:03

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
D'où mes demandes particulières sur le mode lune ;)

Normalement ça fonctionne avec la lampe allumée et éteinte... Et c'est normal que ça reste sur en cours quelques secondes (mais pas plus de 6-7 secondes)
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar fullpower » 15 Juin 2018 20:08

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 ...
:roll:

Il ne se passe rien quand tu l'exécutes????


Non, absolument rien, sous chrome, l'onglet mouline un peu durant qq secondes ..et l’écran reste tout blanc sans aucun message, ni aucune erreur ...
Programmation ARDUINO, NodeMCU, ESP8266 Eedomus + / Raspberry Pi 3 B + & Raspberry Pi 3 en programmation (Magic mirror)
Elegoo Mars - Artillery Sidewinder V2 - modélisation 3D sur Sketchup, Rhino 3d, Fusion 360, etc.
fullpower
 
Messages : 1161
Inscription : 11 Déc 2015
Localisation : Elsass

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 16 Juin 2018 00:26

Désolé @fullpower, je ne vais pas pouvoir faire grand chose de plus. Même si tu m'ouvres un port pour accéder au hub milight, ça ne servira à rien. Les commandes sont envoyées en UDP ce qui ne permet pas de recevoir de réponse de la lampe (contrairement aux yeelight qui utilisent le TCP).
En gros, on ne peux tester qu'en visuel ;-)
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar fullpower » 16 Juin 2018 08:59

Ce n'est pas grave ...
je vais les remplacer par des Yeelight dans un futur proche ..ça sera beaucoup + pratique !
Une vraie galère ces commandes UDP ...
Merci quand même p@t !
Programmation ARDUINO, NodeMCU, ESP8266 Eedomus + / Raspberry Pi 3 B + & Raspberry Pi 3 en programmation (Magic mirror)
Elegoo Mars - Artillery Sidewinder V2 - modélisation 3D sur Sketchup, Rhino 3d, Fusion 360, etc.
fullpower
 
Messages : 1161
Inscription : 11 Déc 2015
Localisation : Elsass

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 16 Juin 2018 09:31

Je pense savoir pourquoi ça ne fonctionne pas, j'ai fait une boulette dans le code...
Au début du script, remplace ceci:
Code : Tout sélectionner
$milight = new sdk_Milight($ip);

par ceci:
Code : Tout sélectionner
$milight = new sdk_Milight();
$milight->sdk___construct($ip);

Puis exécute le script à nouveau.
P@t
 
Messages : 223
Inscription : 04 Déc 2017

Re: [Store] Lampes et plafonniers Yeelight

Messagepar anne-marie » 23 Juin 2018 19:10

Suite de mes problèmes (j'en parle sur un autre post)
J'ai de nouveau supprimé les yeelights ainsi que quelques script que j'utilise peu. C'est devenu nickel.
J'ai réussi à installer quelques scripts du store ainsi que les google home.
Puis j'installe une lampe avec le script yeelight. Rebelote. Les "time out" reviennent sur des périphériques créés depuis longtemps et les google home. Je supprime la lampe, je redémarre la box et je n'ai plus de notifications.
Je suis en contact avec le support qui n'a toujours pas trouvé de réponse à ce problème.
Netatmo - Nabaztag2 - Karotz - Mirror - caméras IP - Zwave - RFXCOM - zigate - ecodevice - Enocean - orvibo - connexoon- google Home - Echo - yeelight etc....
anne-marie
 
Messages : 2456
Inscription : 19 Fév 2014
Localisation : 77

Re: [Store] Lampes et plafonniers Yeelight

Messagepar P@t » 26 Juin 2018 10:21

Salut @anne-marie,

Avec le support, on a essayé de comprendre le problème avec ta lampe, mais sans succès...
Le support a tenté une connexion telnet, mais bizarrement la connexion se ferme immédiatement. Est-ce que tu as plusieurs yeelight et est-ce qu'il n'y en a qu'une qui ne fonctionne pas?

En attendant, j'ai mis à jour le script pour éviter que le timeout ne fasse planter la box eedomus.
P@t
 
Messages : 223
Inscription : 04 Déc 2017

PrécédentSuivant

Retour vers Scripts & Périphériques du store

Qui est en ligne ?

Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 21 invité(s)