Kleines Update
Ich musste noch eine Sicherheitsabschaltung einbauen , da der homee bei fehlendem Abschaltsignal vom Taster immer weiter mit befehlen befeuert wird.
Daher hier der Flow mit der Abschaltung.
[{"id":"95ee282b.531148","type":"function","z":"c8fce8a4.e63828","name":"Dimmer","func":"var count1 = msg.payload;\nvar count = context.get('count')||0;\nglobal.set ('dimmcounter',count);\nif( count > 100){count = 98}\nif(count < 4){count=4} \ncount += count1;\ncontext.set('count',count);\nvar Dimmer = global.get('Dimmer');\nif (msg.payload && Dimmer === 1) \n// im nächsten Schritt wird der Wert an homee gesendet , hier muss die AttributID eingetragen werden\n{ return [{payload: String
PUT:/nodes/7/attributes/19/?target_value=+ JSON.stringify(count)},null];}\n","outputs":2,"noerr":0,"x":1040,"y":280,"wires":[["bb851f2.192fce","c9fe4fe2.9b04b"],[]]},{"id":"52410a00.da60f4","type":"function","z":"c8fce8a4.e63828","name":"Status Taster und Dimmer abrufen","func":"var StatusTaster = global.get('StatusTaster');\nvar Dimmer = global.get('Dimmer');\nif (StatusTaster === 1 && Dimmer === 1)\n{return {payload: -2}} // die -2 ist der Wert um wieviel runtergedimmt wird\nif (StatusTaster === 2 && Dimmer === 1)\n{return {payload: 2}} // die 2 ist der Wert um wieviel hochgedimmt wird\n","outputs":1,"noerr":0,"x":800,"y":280,"wires":[["95ee282b.531148","d8f4f0e7.09a66"]]},{"id":"542962f3.f0129c","type":"function","z":"c8fce8a4.e63828","name":"Status des Tasters speichern","func":"global.set ('StatusTaster',msg.payload)\nif (msg.payload === 0 )\n{ global.set ('Dimmer',0)}","outputs":1,"noerr":0,"x":780,"y":240,"wires":[[]]},{"id":"d8f4f0e7.09a66","type":"delay","z":"c8fce8a4.e63828","name":"Dimmgeschwindigkeit","pauseType":"delayv","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"milliseconds","drop":false,"x":780,"y":320,"wires":[["52410a00.da60f4"]]},{"id":"548856d2.13e678","type":"delay","z":"c8fce8a4.e63828","name":"Dauer des Tastendruck für Dimmer","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":620,"y":400,"wires":[["e133f0e8.df1fd"]]},{"id":"e133f0e8.df1fd","type":"function","z":"c8fce8a4.e63828","name":"Dimmer aktivieren","func":"var StatusTaster = global.get('StatusTaster');\nif (msg.payload && StatusTaster === 1 || 2) \nglobal.set('Dimmer',1)\nreturn{payload: 1} ","outputs":1,"noerr":0,"x":900,"y":400,"wires":[["d8f4f0e7.09a66"]]},{"id":"1dbc2231.cc2d3e","type":"delay","z":"c8fce8a4.e63828","name":"Dauer für das Ausschalten der Lampe","pauseType":"delay","timeout":"1100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":460,"wires":[["7183039f.25b0cc"]]},{"id":"7183039f.25b0cc","type":"function","z":"c8fce8a4.e63828","name":"Lampe ausschalten","func":"var StatusTaster = global.get('StatusTaster');\nif ( msg.payload === 1 && StatusTaster === 0){return {payload: String
PUT:/nodes/7/attributes/19/?target_value=0}}\n","outputs":1,"noerr":0,"x":910,"y":460,"wires":[["bb851f2.192fce"]]},{"id":"d5af7587.a0d8b8","type":"function","z":"c8fce8a4.e63828","name":"Umwandeln des Tastersignal ","func":"if (msg.payload.attribute && msg.payload.attribute.id === 111 && msg.payload.attribute.current_value === 1){\nreturn {payload: 1}}\nif (msg.payload.attribute && msg.payload.attribute.id === 111 && msg.payload.attribute.current_value === 2){\nreturn {payload: 0}}\nif (msg.payload.attribute && msg.payload.attribute.id === 111 && msg.payload.attribute.current_value === 0){\nreturn {payload: 2}}","outputs":1,"noerr":0,"x":340,"y":260,"wires":[["542962f3.f0129c","52410a00.da60f4","548856d2.13e678","1dbc2231.cc2d3e"]]},{"id":"c9fe4fe2.9b04b","type":"function","z":"c8fce8a4.e63828","name":"Sicherheitsabschaltung","func":"var count = global.get('dimmcounter');\nif (count >100 || count <4) {\nreturn {payload: 0}}\n","outputs":1,"noerr":0,"x":770,"y":200,"wires":[["542962f3.f0129c"]]}]