Bonjour
J’ai longtemps pensé, à tord, que node-red était compliqué. Après avoir visionné ce tuto sur Youtube [https://www.youtube.com/watch?v=d1s9VAD1ClM], je me suis rendu compte, qu’en fait, pas du tout.
J’ai donc commencé à faire des flows le week-end dernier. Ce WE, ayant déplacé quelques ampoules Hue de l’intégration Hue vers Z2Mqtt, je n’avais plus la scène faisant scintiller mes ampoules comme une bougie.
J’ai réalisé le flow suivant, et j’avoue être plutôt satisfait du résultat.
Edit, je vous ajoute l’import du flow
[{"id":"0c938fc265357a7b","type":"tab","label":"Flux 4","disabled":false,"info":"","env":[]},{"id":"1f38ca0ae15191ef","type":"server-state-changed","z":"0c938fc265357a7b","name":"Hue dimmer switch 1","server":"cfe85b65.cca4e8","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.hue_dimmer_switch_lustre_salon_action","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":220,"y":260,"wires":[["e4168d471315446d"]]},{"id":"e4168d471315446d","type":"switch","z":"0c938fc265357a7b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on-press","vt":"str"},{"t":"eq","v":"on-hold","vt":"str"},{"t":"eq","v":"on-hold-release","vt":"str"},{"t":"eq","v":"up-press","vt":"str"},{"t":"eq","v":"up-hold","vt":"str"},{"t":"eq","v":"up-hold-release","vt":"str"},{"t":"eq","v":"down-press","vt":"str"},{"t":"eq","v":"down-hold","vt":"str"},{"t":"eq","v":"down-hold-release","vt":"str"},{"t":"eq","v":"off-press","vt":"str"},{"t":"eq","v":"off-hold","vt":"str"},{"t":"eq","v":"off-hold-release","vt":"str"}],"checkall":"true","repair":false,"outputs":12,"x":420,"y":260,"wires":[["6488f2743d92a8fd"],[],[],[],[],[],[],[],[],[],[],[]]},{"id":"23252155c92a3d09","type":"api-call-service","z":"0c938fc265357a7b","name":"Candel on","server":"cfe85b65.cca4e8","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.groupe_lampadaire_salon"],"data":"{\"brightness\":{{brightness}},\"color_temp\":{{color_temp}},\"transition\":{{transition}}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":200,"wires":[["009ba3bd95cae238"]]},{"id":"6488f2743d92a8fd","type":"random","z":"0c938fc265357a7b","name":"Brightness","low":"30","high":"200","inte":"true","property":"brightness","x":670,"y":200,"wires":[["9f97e921670cd51d"]]},{"id":"9f97e921670cd51d","type":"random","z":"0c938fc265357a7b","name":"Temperature","low":"420","high":"500","inte":"true","property":"color_temp","x":850,"y":200,"wires":[["d21341b13210a1ac"]]},{"id":"009ba3bd95cae238","type":"loop","z":"0c938fc265357a7b","name":"","kind":"fcnt","count":"","initial":"1","step":"1","condition":"","conditionType":"js","when":"before","enumeration":"enum","enumerationType":"msg","limit":"","loopPayload":"loop-index","finalPayload":"final-count","x":970,"y":340,"wires":[["6488f2743d92a8fd"],[]]},{"id":"d21341b13210a1ac","type":"random","z":"0c938fc265357a7b","name":"Transition","low":"0","high":"0.500","inte":"false","property":"transition","x":1020,"y":200,"wires":[["23252155c92a3d09"]]},{"id":"cfe85b65.cca4e8","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
Le déclencheur est un hue dimmer swith.
Je commence à créer un switch node-red pour récuper toutes les sorties du bouton :
Je déclenche ma scène avec le bouton ON.
Le flow continue en sortant 3 valeurs aléatoires pour la luminosité, la température de couleur et la durée de transition entre les 2 types d’éclairage demandés.
Je borne les valeurs aléatoires.
Pour la luminosité : de 30 à 200 (pas trop éteinte ni trop lumineuse), pour la température : de 420 à 500 (je reste dans des couleurs plutôt chaudes et pour la transition: de 0 à 0.500 (attention de bien modifier la valeur de « generate » à « a real number - floating point » pour avoir des chiffres avec la virgule. Je n’oublie pas de modifier la valeur de la propriété à « msg.brightness », « msg.color_temp » et « msg.transition »
Ensuite je pose un noeud « call service » :
Dans la cellule « data », je mets le sélectionneur sur « {}JSON » et inscrit le code suivant :
`{"brightness":{{brightness}},"color_temp":{{color_temp}},"transition":{{transition}}}`
Enfin, je pose une boucle infini (loop) qui retourne au premier noeud random.
Par contre, cette boucle empêche d’éteindre l’ampoule. Pour l’instant, je suis obligé de supprimer un des lien de la boucle et déployer pour stopper le flow.
J’ai donc aussi besoin de votre aide pour trouver une solution d’extinction.
Merci
Stéphane