bcaro a écrit : ↑12 avr. 2017, 20:42
Comme Lunarok donne le code pour le faire, tu crées une commande (voir la doc) mais il faut utiliser la syntaxe yeelight.
Extrait de l'API (http://www.yeelight.com/download/Yeelig ... n_Spec.pdf) :
Method : start_cf
Usage :This method is used to start a color flow. Color flow is a series of smart
LED visible state changing. It can be brightness changing, color changing or color temperature changing.
This is themost powerful command. All our recommended scenes,
e.g. Sunrise/Sunset effect is implemented using this method.
With the flow expression, user can actually “program”the light effect.
Parameters: 3.
"count" is the total number of visible state changing before color flow stopped. 0means infinite loop on the state changing.
"action"is the action taken after the flow is stopped.
0 means smart LED recover to the state before the color flow started.
1 means smart LED stay at the state when the flow is stopped.
2 means turn off the smart LED after the flow is stopped.
"flow_expression"
is the expression of the state changing series.
Request Example:
{"id":1,"method":"start_cf","params":[ 4, 2, "1000, 2, 2700, 100, 500, 1, 255, 10,5000, 7, 0,0,500, 2, 5000, 1"]}
Response Example:
{"id":1, "result":["ok"]}
NOTE: Each visible state changing is defined to be a flow tuple that contains 4 elements: [duration, mode, value, brightness]. A flow expression is a series of flow tuples.
So for above request example, it means: change CT to 2700K & maximum brightness gradually in 1000ms, then change color to red & 10% brightness gradually in 500ms, then stay at this state for 5 seconds, then change CT to 5000K & minimum brightness gradually in 500ms. After 4 changes reached, stopped the flow and power off the smart LED.
[duration, mode, value, brightness] :
Duration: Gradual change timeor sleeptime, in milliseconds, minimum value 50.
Mode:
1 –color,
2 –color temperature,
7 -sleep.
Value: RGB value when mode is 1, CT value when mode is 2, Ignored when mode is 7.
Brightness:
Brightness value, 1 ~ 100.
Ignored when mode is 7.
Only accepted if the smart LED is currently in "on" state.
Transcodage de la commande d'aube :
30 off rgb,255,0,0,300,50-wait,4000-rgb,255,255,0,300,50-wait,7000-rgb,255,0,255,300,50-wait,8000
Devient avec la syntaxe de l'API Yeelight (pour le plugin wifilightV2, ne pas mettre les accolades) :
"id":1,"method":"start_cf","params":[
30, // 30 fois
2, // off à la fin
"300, 1,255*65436+0*255+0, 50, // duration,mode,value,brightness= lunarok rgb,red,green,blue,duration,brightness : rgb,255,0,0,300,50
4000,7,0,0, // duration,mode,value,brightness = lunarok : wait,4000
300, 1,255*65436+0*255+255, 50, // duration,mode,value,brightness= lunarok rgb,red,green,blue,duration,brightness : rgb,255,255,0,300,50
7000,7,0,0, // duration,mode,value,brightness = lunarok : wait,7000
300, 1,255*65436+0*255+255, 50, // duration,mode,value,brightness= lunarok rgb,red,green,blue,duration,brightness : rgb,255,0,255,300
8000,7,0,0 // duration,mode,value,brightness = lunarok : wait,8000
"]
Pour les couleurs il faut faire le calcul :
255*65536+0*256+0 = 16711680
255*65536+255*256+0 = 16776960
255*65536+0*256+255 = 16711935
Au final la commande est :
"id":1,"method":"start_cf","params":[ 30,2,"300, 1,16711680, 50, -- 4000,7,0,0, -- 300, 1,16776960, 50, -- 7000,7,0,0, -- 300, 1,16711935, 50, -- 8000,7,0,0"]
(j'ai mis des -- pour mieux comprendre)
Dans le plugin, créer une commande action de type Défaut. L'appeler Scene03 (par exemple) et copier :
"id":1,"method":"start_cf","params":[ 30,2,"300,1,16711680,50,4000,7,0,0,300,1,16776960,50,7000,7,0,0,300,1,16711935,50, 8000,7,0,0"]
dans le champ commande.
Sauvegarder.
Il faut quand même vérifier mon transcodage.
Faire pareil pour :
1 stay temp,2500,30000,30-wait,1000-temp,3000,30000,40-wait,1000-temp,3500,30000,50-wait,1000-temp,3700,30000,60-wait,1000-temp,4000,50000,100
Si tu as le courage de transcoder le deuxième et de valider, je peux inclure dans le plugin le mode en question lors de la création de l'équipement.