Hi,
hier der Flow zu einem der verbauten Shellies. Mit diesem Shelly dimme ich die Beleuchtung an der Regenrinne über der Schiebetür. Dieser Teil ist in diem Flow enthalten. Eine der Shelly Eingänge hängt an Kl15 und prüft damit, ob die Zündung an ist. Ich schalte dann die Regenrinne Aus. An den beiden noch freien Schlterplätzen hängen weitere LED Leuchten, dei ich genauso dimme wie die Regenrinne. Die sind in diesen Flow Ausschnitt nicht enthalten.
Ich benutze ein paar Variablen, um mir den Status der Taster zu merken. Es gibt eine Wartezeit vorm eigentlichen Dimmen, damit ich das Dimmen nicht beginne, wenn der Taster nur kurz gedrückt wurde. Kurzer Tastendruck toggelt die LED, langer Tastendruck dimmt zyklisch runter und rauf, bis man loslässt. Doppelklick schaltet die gedimmte LED auf 100%.
[{“id”:“a8d6bcfb423e4fc6”,“type”:“tab”,“label”:“Flow 1”,“disabled”:false,“info”:“”,“env”:},{“id”:“fdd50a75d9d27784”,“type”:“mqtt in”,“z”:“a8d6bcfb423e4fc6”,“name”:“Shelly Doorstep”,“topic”:“Sh_Doorstep/events/rpc”,“qos”:“2”,“datatype”:“utf8”,“broker”:“0ddb07c65cbb68bc”,“nl”:false,“rap”:true,“rh”:0,“inputs”:0,“x”:220,“y”:380,“wires”:[[“df7c8321271af0d9”,“be96dd7a10ce46fc”]]},{“id”:“df7c8321271af0d9”,“type”:“switch”,“z”:“a8d6bcfb423e4fc6”,“name”:“Which switch?”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“"input:0"”,“vt”:“str”},{“t”:“cont”,“v”:“input:1”,“vt”:“str”},{“t”:“cont”,“v”:“input:2”,“vt”:“str”},{“t”:“cont”,“v”:“input:3”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:4,“x”:440,“y”:380,“wires”:[[“50febd5b378ace70”],[“f7af6e9485402aca”],,]},{“id”:“b6bbab7bb0965741”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:" toggle Regenrinne",“func”:“let dimmer = global.get("dimmer0");\n//node.warn(dimmer);\n\n if (dimmer == 0){\n dimmer = 100;\n }else{\n dimmer = 0;\n }\n//node.warn(dimmer); \nmsg.payload = dimmer;\nmsg.label = global.get("Ndimmer0")\nreturn msg;\n”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1050,“y”:360,“wires”:[[“81ea4e536011c9eb”,“45df9ae0fc9217dd”]]},{“id”:“922e99961c4c68df”,“type”:“comment”,“z”:“a8d6bcfb423e4fc6”,“name”:“Handle Doorstep switch actions”,“info”:“”,“x”:250,“y”:280,“wires”:},{“id”:“37c66aecdcdd4db4”,“type”:“comment”,“z”:“a8d6bcfb423e4fc6”,“name”:“LED Regenrinne”,“info”:“”,“x”:820,“y”:260,“wires”:},{“id”:“630a17c7a3821bd3”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“set KL15, Dimmer off”,“func”:“\nglobal.set("Kl15", true);\nglobal.set("dimmer0",0);\n \n \nmsg.payload = 0;\nmsg.label = global.get("Ndimmer0")\nreturn msg;\n\n/\n{"src":"shellyplusi4-c049ef87e544",\n "dst":"Sh_Doorstep/events",\n "method":"NotifyStatus",\n "params":\n {"ts":1670601187.06,\n "input:1":\n {"id":1,\n "state":true}}}\n/”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1060,“y”:460,“wires”:[[“81ea4e536011c9eb”,“45df9ae0fc9217dd”]]},{“id”:“b4cd255fc95344e2”,“type”:“comment”,“z”:“a8d6bcfb423e4fc6”,“name”:“LED Regenrinne aus, wenn Kl15”,“info”:“”,“x”:1250,“y”:500,“wires”:},{“id”:“81ea4e536011c9eb”,“type”:“debug”,“z”:“a8d6bcfb423e4fc6”,“name”:“Value Regenrinne”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“statusVal”:“”,“statusType”:“auto”,“x”:1970,“y”:460,“wires”:},{“id”:“5c8f846b6dd37c0a”,“type”:“inject”,“z”:“a8d6bcfb423e4fc6”,“name”:“Init Shellies 180s”,“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:“”,“crontab”:“”,“once”:true,“onceDelay”:“180”,“topic”:“”,“payload”:“”,“payloadType”:“date”,“x”:250,“y”:180,“wires”:[[“891d242798c8b0c5”]]},{“id”:“891d242798c8b0c5”,“type”:“http request”,“z”:“a8d6bcfb423e4fc6”,“name”:“”,“method”:“GET”,“ret”:“txt”,“paytoqs”:“ignore”,“url”:“http://ShellyIP/rpc/Input.GetStatus?id=1",“tls”:“”,“persist”:true,“proxy”:“”,“authType”:“”,“senderr”:false,“x”:470,“y”:180,“wires”:[[“d174485feb8212cb”]]},{“id”:“648362b22cea8124”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:"set Kl15, Dimmlogic”,“func”:“const object = msg.payload;\nlet state = object.state;\nglobal.set("Kl15", state);\n\n//global variables for Dimm Action\nglobal.set("dimRegenrinne", false);\nglobal.set("dimMain", false);\nglobal.set("dimEingang", false);\nglobal.set("dimMaxxAir", false);\nglobal.set("dimEsstisch", false);\nglobal.set("dimGalley", false);\nglobal.set("dimFrontLED", false);\n\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:880,“y”:180,“wires”:[]},{“id”:“d174485feb8212cb”,“type”:“json”,“z”:“a8d6bcfb423e4fc6”,“name”:“”,“property”:“payload”,“action”:“obj”,“pretty”:false,“x”:670,“y”:180,“wires”:[[“648362b22cea8124”]]},{“id”:“f79552909337b5fb”,“type”:“comment”,“z”:“a8d6bcfb423e4fc6”,“name”:“set global variable for Kl15 and Dimming”,“info”:“”,“x”:280,“y”:120,“wires”:},{“id”:“be96dd7a10ce46fc”,“type”:“debug”,“z”:“a8d6bcfb423e4fc6”,“name”:“”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“statusVal”:“”,“statusType”:“auto”,“x”:410,“y”:320,“wires”:},{“id”:“cd59c89c4156d220”,“type”:“switch”,“z”:“a8d6bcfb423e4fc6”,“name”:“Which event?”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“"btn_down"”,“vt”:“str”},{“t”:“cont”,“v”:“"btn_up"”,“vt”:“str”},{“t”:“cont”,“v”:“"single_push"”,“vt”:“str”},{“t”:“cont”,“v”:“"double_push"”,“vt”:“str”},{“t”:“cont”,“v”:“"long_push"”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:5,“x”:820,“y”:360,“wires”:[[“46afcd4d1a987ddb”],[“b25d4f64aaad19e1”],[“b6bbab7bb0965741”],[“5da172ca8c9f066c”],]},{“id”:“46afcd4d1a987ddb”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“set dimRegenrinne”,“func”:“global.set("dimRegenrinne", true);\nif (global.get("dimmer0") == 0){\n flow.set("dimRegenrinneUp", true);\n} else if (global.get("dimmer0") <= 100){\n flow.set("dimRegenrinneUp", false);\n}\n\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1050,“y”:280,“wires”:[[“b0edb32fcbb1bdf0”]]},{“id”:“b8ad69f1fd843ffd”,“type”:“delay”,“z”:“a8d6bcfb423e4fc6”,“name”:“50 ms”,“pauseType”:“delay”,“timeout”:“100”,“timeoutUnits”:“milliseconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:1370,“y”:280,“wires”:[[“e4bea3e83ea74f28”]]},{“id”:“4d6d793843d752de”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“Dim Regenrinne Up”,“func”:“let dimmer = global.get("dimmer0");\n\nif (global.get("dimRegenrinne")){\n dimmer += 1;\n if (dimmer == 100){\n flow.set("dimRegenrinneUp", false);\n }\n\n} \n\n\nmsg.payload = dimmer;\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1830,“y”:280,“wires”:[[“81ea4e536011c9eb”,“a3f403fe37d6dfae”,“45df9ae0fc9217dd”]]},{“id”:“b25d4f64aaad19e1”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“reset dimRegenrinne”,“func”:“global.set("dimRegenrinne", false);\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1060,“y”:320,“wires”:[]},{“id”:“b0edb32fcbb1bdf0”,“type”:“delay”,“z”:“a8d6bcfb423e4fc6”,“name”:“300 ms”,“pauseType”:“delay”,“timeout”:“200”,“timeoutUnits”:“milliseconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:1220,“y”:280,“wires”:[[“b8ad69f1fd843ffd”]]},{“id”:“e4bea3e83ea74f28”,“type”:“switch”,“z”:“a8d6bcfb423e4fc6”,“name”:“dim Regenrinne Up?”,“property”:“dimRegenrinneUp”,“propertyType”:“flow”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“false”,“repair”:false,“outputs”:2,“x”:1580,“y”:280,“wires”:[[“4d6d793843d752de”],[“7cddc1f1022c891c”]]},{“id”:“7cddc1f1022c891c”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“Dim Regenrinne Down”,“func”:“let dimmer = global.get("dimmer0");\n\nif (global.get("dimRegenrinne")){\n dimmer -= 1;\n if (dimmer == 0){\n flow.set("dimRegenrinneUp", true);\n }\n\n} \n\n\nmsg.payload = dimmer;\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1720,“y”:340,“wires”:[[“a3f403fe37d6dfae”,“81ea4e536011c9eb”,“45df9ae0fc9217dd”]]},{“id”:“50febd5b378ace70”,“type”:“switch”,“z”:“a8d6bcfb423e4fc6”,“name”:“Kl15?”,“property”:“Kl15”,“propertyType”:“global”,“rules”:[{“t”:“false”},{“t”:“true”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:630,“y”:360,“wires”:[[“cd59c89c4156d220”],]},{“id”:“a3f403fe37d6dfae”,“type”:“switch”,“z”:“a8d6bcfb423e4fc6”,“name”:“dim Regenrinne ?”,“property”:“dimRegenrinne”,“propertyType”:“global”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:1910,“y”:240,“wires”:[[“b8ad69f1fd843ffd”],]},{“id”:“f7af6e9485402aca”,“type”:“switch”,“z”:“a8d6bcfb423e4fc6”,“name”:“Kl15 state?”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“"state":true”,“vt”:“str”},{“t”:“cont”,“v”:“"state":false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:810,“y”:460,“wires”:[[“630a17c7a3821bd3”],[“e8cdf3ae0485c194”]]},{“id”:“e8cdf3ae0485c194”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“reset KL15”,“func”:“\nglobal.set("Kl15", false);\nglobal.set("dimmer0",0);\n \n \nmsg.payload = 0;\nmsg.label = global.get("Ndimmer0")\nreturn msg;\n\n/\n{"src":"shellyplusi4-c049ef87e544",\n "dst":"Sh_Doorstep/events",\n "method":"NotifyStatus",\n "params":\n {"ts":1670601187.06,\n "input:1":\n {"id":1,\n "state":true}}}\n/”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1030,“y”:500,“wires”:[]},{“id”:“5da172ca8c9f066c”,“type”:“function”,“z”:“a8d6bcfb423e4fc6”,“name”:“Regenrinne to 100”,“func”:“global.set("dimmer0", 100);\nmsg.payload = 100;\n\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:1050,“y”:400,“wires”:[[“45df9ae0fc9217dd”]]},{“id”:“45df9ae0fc9217dd”,“type”:“mqtt out”,“z”:“a8d6bcfb423e4fc6”,“name”:“”,“topic”:“pkw/cmnd/dimmer/1/POWER”,“qos”:“”,“retain”:“”,“respTopic”:“”,“contentType”:“”,“userProps”:“”,“correl”:“”,“expiry”:“”,“broker”:“0ddb07c65cbb68bc”,“x”:2120,“y”:400,“wires”:},{“id”:“b055a26d99d8fe5d”,“type”:“comment”,“z”:“a8d6bcfb423e4fc6”,“name”:“send value to MQTT API”,“info”:“”,“x”:2130,“y”:360,“wires”:},{“id”:“0ddb07c65cbb68bc”,“type”:“mqtt-broker”,“name”:“”,“broker”:“http://localhost”,“port”:“1883”,“clientid”:“”,“usetls”:false,“protocolVersion”:“4”,“keepalive”:“60”,“cleansession”:true,“birthTopic”:“”,“birthQos”:“0”,“birthPayload”:“”,“birthMsg”:{},“closeTopic”:“”,“closeQos”:“0”,“closePayload”:“”,“closeMsg”:{},“willTopic”:“”,“willQos”:“0”,“willPayload”:“”,“willMsg”:{},“sessionExpiry”:“”}]