|
[ |
|
{ |
|
"id": "506075f2.fc33c4", |
|
"type": "comment", |
|
"z": "4d2d578e.6cea28", |
|
"name": "README Shelly RGBW 2", |
|
"info": "// README in Dutch\nIk moest even uitvogelen wat precies wat is. Zoals ik het nu begrijp:\n\nJe kan de RGB kleuren mixen door de waardes van red, green, blue een waarde te geven van 0...255. Nu kan je met de gain 0...100 bepalen hoe vel de red, green, blue moet branden.\n\nVerder is er nog een white kanaal, dit kanaal stuurt de apparte strook witte leds aan. White kan je instellen van 0...255.\n\nMeer is het niet.\n\n{\n \"mode\": \"color\",\n \"red\": 255,\n \"green\": 255,\n \"blue\": 255,\n \"gain\": 100,\n \"white\": 255,\n \"effect\": 0,\n \"turn\": \"on\"\n}\n\nApple's homekit gebruikt HSL\n\nHSL (hue, saturation, lightness) or HSB (hue, saturation, brightness) are similar.\n\n- Hue (Nederlands: tint), is wat we gewoonlijk 'kleur' noemen, zeg een punt op de regenboog.\n In het HSV-model wordt de kleur uitgezet op een cirkel, en wordt de plek aangeduid in graden: Hue loopt dus van 0 tot 360 (graden).\n\n- Saturation (Nederlands: verzadiging) dit geeft een hoeveelheid (of felheid) van een kleur aan.\n Wordt uitgedrukt in procenten, en loopt van 0% (flets, grijs) naar 100% (volle kleur).\n\n- Value of Brightness (Nederlands: intensiteit): staat voor de lichtheid van de kleur.\n Wordt uitgedrukt in procenten, en loopt van 0% (zwart) naar 100% (wit).", |
|
"x": 170, |
|
"y": 1700, |
|
"wires": [] |
|
}, |
|
{ |
|
"id": "d84ed564.16e178", |
|
"type": "mqtt in", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Regenboog RGB", |
|
"topic": "shellies/regenboog/color/0/status", |
|
"qos": "0", |
|
"datatype": "auto", |
|
"broker": "707b233c.d0ad2c", |
|
"x": 140, |
|
"y": 1740, |
|
"wires": [ |
|
[ |
|
"ff38dc1e.bb4e1" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "ff38dc1e.bb4e1", |
|
"type": "json", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"property": "payload", |
|
"action": "", |
|
"pretty": false, |
|
"x": 275, |
|
"y": 1740, |
|
"wires": [ |
|
[ |
|
"3eda36df.27cf82" |
|
] |
|
], |
|
"l": false |
|
}, |
|
{ |
|
"id": "92d9884c.6977f8", |
|
"type": "homekit-service", |
|
"z": "4d2d578e.6cea28", |
|
"isParent": true, |
|
"bridge": "93e1fd.7adf2e", |
|
"parentService": "", |
|
"name": "🌈 Regenboog", |
|
"serviceName": "Lightbulb", |
|
"topic": "", |
|
"filter": false, |
|
"manufacturer": "Default Manufacturer", |
|
"model": "Default Model", |
|
"serialNo": "Default Serial Number", |
|
"cameraConfigVideoProcessor": "ffmpeg", |
|
"cameraConfigSource": "", |
|
"cameraConfigStillImageSource": "", |
|
"cameraConfigMaxStreams": 2, |
|
"cameraConfigMaxWidth": 1280, |
|
"cameraConfigMaxHeight": 720, |
|
"cameraConfigMaxFPS": 10, |
|
"cameraConfigMaxBitrate": 300, |
|
"cameraConfigVideoCodec": "libx264", |
|
"cameraConfigAudioCodec": "libfdk_aac", |
|
"cameraConfigAudio": false, |
|
"cameraConfigPacketSize": 1316, |
|
"cameraConfigVerticalFlip": false, |
|
"cameraConfigHorizontalFlip": false, |
|
"cameraConfigMapVideo": "0:0", |
|
"cameraConfigMapAudio": "0:1", |
|
"cameraConfigVideoFilter": "scale=1280:720", |
|
"cameraConfigAdditionalCommandLine": "-tune zerolatency", |
|
"cameraConfigDebug": false, |
|
"cameraConfigSnapshotOutput": "disabled", |
|
"cameraConfigInterfaceName": "", |
|
"characteristicProperties": "{\"Name\":\"🌈 Regenboog\", \"Brightness\":true, \"Hue\":true, \"Saturation\":true}", |
|
"x": 620, |
|
"y": 2000, |
|
"wires": [ |
|
[ |
|
"c4a71908.de05d", |
|
"1f4ac2c.0b63ebd" |
|
], |
|
[] |
|
] |
|
}, |
|
{ |
|
"id": "5f0061da.774fa8", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "input", |
|
"active": true, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": false, |
|
"complete": "true", |
|
"targetType": "full", |
|
"x": 250, |
|
"y": 1800, |
|
"wires": [] |
|
}, |
|
{ |
|
"id": "3eda36df.27cf82", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "∞", |
|
"func": "// fix repeated messages\nlet millisecondsBetweenMessages = 200;\nlet previousTime=context.get('time') || 0;\nlet currentTime=Math.round(Date.now());\nlet timeDifference=currentTime-previousTime;\n\n// set variable for next round\ncontext.set('time', currentTime);\n\nif (timeDifference < millisecondsBetweenMessages){\n node.warn('To fast: '+timeDifference+'ms');\n msg = null; // stop msg from sending\n}\n\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 335, |
|
"y": 1740, |
|
"wires": [ |
|
[ |
|
"5f0061da.774fa8", |
|
"396bdb58.3a6554", |
|
"b6da17f1.206948", |
|
"82771e64.77a57", |
|
"473256d6.641858", |
|
"ab3bf9d.85b4108", |
|
"8c7a3254.d34138" |
|
] |
|
], |
|
"icon": "node-red/timer.svg", |
|
"l": false |
|
}, |
|
{ |
|
"id": "ae269011.b4365", |
|
"type": "ui_colour_picker", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Regenboog RGB", |
|
"label": "", |
|
"group": "efa9c015.d79758", |
|
"format": "rgb", |
|
"outformat": "object", |
|
"showSwatch": false, |
|
"showPicker": true, |
|
"showValue": false, |
|
"showHue": false, |
|
"showAlpha": false, |
|
"showLightness": false, |
|
"square": "false", |
|
"dynOutput": "false", |
|
"order": 11, |
|
"width": 0, |
|
"height": 0, |
|
"passthru": true, |
|
"topic": "", |
|
"x": 710, |
|
"y": 1700, |
|
"wires": [ |
|
[ |
|
"605e4d0c.6aaf3c", |
|
"b5e3fbc4.8217c8" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "3049ca84.56d01e", |
|
"type": "ui_switch", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Regenboog", |
|
"label": "Regenboog", |
|
"tooltip": "", |
|
"group": "efa9c015.d79758", |
|
"order": 9, |
|
"width": 0, |
|
"height": 0, |
|
"passthru": false, |
|
"decouple": "true", |
|
"topic": "", |
|
"style": "", |
|
"onvalue": "on", |
|
"onvalueType": "str", |
|
"onicon": "", |
|
"oncolor": "", |
|
"offvalue": "off", |
|
"offvalueType": "str", |
|
"officon": "", |
|
"offcolor": "", |
|
"x": 690, |
|
"y": 1600, |
|
"wires": [ |
|
[ |
|
"af8189c2.2aa778" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "285f1a5a.377e46", |
|
"type": "mqtt out", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"topic": "", |
|
"qos": "", |
|
"retain": "", |
|
"broker": "707b233c.d0ad2c", |
|
"x": 1530, |
|
"y": 1700, |
|
"wires": [] |
|
}, |
|
{ |
|
"id": "605e4d0c.6aaf3c", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "prep RGB", |
|
"func": "let red = msg.payload.r\nlet green = msg.payload.g\nlet blue = msg.payload.b\n\n// create message\nmsg.payload = {\"red\": red, \"green\": green, \"blue\": blue}\n\n// return message\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 960, |
|
"y": 1700, |
|
"wires": [ |
|
[ |
|
"f240d7bd.42308", |
|
"b5e3fbc4.8217c8" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "e1ac9d4b.ec0e28", |
|
"type": "ui_slider", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Regenboog Helderheid", |
|
"label": "Helderheid", |
|
"tooltip": "", |
|
"group": "efa9c015.d79758", |
|
"order": 10, |
|
"width": "0", |
|
"height": "0", |
|
"passthru": true, |
|
"outs": "end", |
|
"topic": "", |
|
"min": 0, |
|
"max": "100", |
|
"step": 1, |
|
"x": 730, |
|
"y": 1800, |
|
"wires": [ |
|
[ |
|
"5db26680.ea692" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "5db26680.ea692", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "prep gain", |
|
"func": "// create message\nmsg.payload = {\"gain\": msg.payload}\n\n// return message\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 960, |
|
"y": 1800, |
|
"wires": [ |
|
[ |
|
"f240d7bd.42308", |
|
"2ec6f3f6.80e3a4" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "396bdb58.3a6554", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "on/off", |
|
"func": "msg.payload = msg.payload.ison ? 'on' : 'off';\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 490, |
|
"y": 1600, |
|
"wires": [ |
|
[ |
|
"3049ca84.56d01e", |
|
"3dae9441.f72184" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "3dae9441.f72184", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 455, |
|
"y": 1640, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "f240d7bd.42308", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "complete payload & set topic", |
|
"func": "// b.nelissen\n// 2020 augustus\n// get the default payload\n// add the payload of the flow\n// add the new values to the flow payload\n// safe the new payload\n// return the new payload\n\n// a bug in the colorpicker:\n// when the colorpicker gets a 0,0,0 it stops sending changes in color signal\n// therefor I send 123, 123, 123 by default\n\nmsg.topic = \"shellies/regenboog/color/0/set\"\n\n// msg.payload[\"On\"]\n\ndefaultPayload = {\n \"mode\": \"color\",\n \"red\": 123,\n \"green\": 123,\n \"blue\": 123,\n \"gain\": 0,\n \"white\": 0,\n \"effect\": 0,\n \"turn\": \"off\"\n}\n\n// merge payloads & remove all unneeded keys\nfunction mergePayloads(dest, src) {\n for(var key in src) {\n if (key in defaultPayload){\n dest[key] = src[key];\n }\n } \n return dest; \n}\n\n// default + flow\nvar newPayload = mergePayloads(defaultPayload, flow.get('flowPayload'));\n\n// flow + new\nnewPayload = mergePayloads(newPayload, msg.payload);\n\n// store new payload in flow\nflow.set('flowPayload', newPayload)\n\n// get the data from the flow variable (so we get we stored)\nmsg.payload = flow.get('flowPayload')\n\n// return the new payload\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 1300, |
|
"y": 1700, |
|
"wires": [ |
|
[ |
|
"1f279ef3.a277d9", |
|
"285f1a5a.377e46" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "1f279ef3.a277d9", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "output", |
|
"active": true, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 1290, |
|
"y": 1780, |
|
"wires": [] |
|
}, |
|
{ |
|
"id": "af8189c2.2aa778", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "prep ison", |
|
"func": "// create message\nmsg.payload = {\"turn\": msg.payload}\n\n// return message\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 960, |
|
"y": 1600, |
|
"wires": [ |
|
[ |
|
"f240d7bd.42308", |
|
"766035b2.e88514" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "b6da17f1.206948", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Helderheid", |
|
"func": "msg.payload = msg.payload.gain;\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 510, |
|
"y": 1800, |
|
"wires": [ |
|
[ |
|
"e1ac9d4b.ec0e28", |
|
"9f50d198.1dac4" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "9f50d198.1dac4", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 455, |
|
"y": 1840, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "7504975a.a1e1d", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 455, |
|
"y": 1740, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "82771e64.77a57", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "rgb", |
|
"func": "msg.payload = { \"r\" : msg.payload.red,\n \"g\" : msg.payload.green,\n \"b\" : msg.payload.blue\n };\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 490, |
|
"y": 1700, |
|
"wires": [ |
|
[ |
|
"7504975a.a1e1d", |
|
"ae269011.b4365" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "dd0a5f34.e89268", |
|
"type": "ui_slider", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Regenboog Wit", |
|
"label": "Wit", |
|
"tooltip": "", |
|
"group": "efa9c015.d79758", |
|
"order": 12, |
|
"width": 0, |
|
"height": 0, |
|
"passthru": true, |
|
"outs": "end", |
|
"topic": "", |
|
"min": 0, |
|
"max": "255", |
|
"step": 1, |
|
"x": 700, |
|
"y": 1900, |
|
"wires": [ |
|
[ |
|
"49a4579c.35cf4" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "49a4579c.35cf4", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "prep white", |
|
"func": "// create message\nmsg.payload = {\"white\": msg.payload}\n\n// return message\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 970, |
|
"y": 1900, |
|
"wires": [ |
|
[ |
|
"f240d7bd.42308", |
|
"b4a3ea6a.519b4" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "473256d6.641858", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "white", |
|
"func": "msg.payload = msg.payload.white;\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 490, |
|
"y": 1900, |
|
"wires": [ |
|
[ |
|
"dd0a5f34.e89268", |
|
"cb8850d7.0965d" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "cb8850d7.0965d", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 455, |
|
"y": 1940, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "b4a3ea6a.519b4", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 915, |
|
"y": 1940, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "2ec6f3f6.80e3a4", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 915, |
|
"y": 1840, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "b5e3fbc4.8217c8", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 915, |
|
"y": 1740, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "766035b2.e88514", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 915, |
|
"y": 1640, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "c4a71908.de05d", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Complete msg", |
|
"func": "// defaultPayload = {\n// \"mode\": \"color\",\n// \"red\": 123,\n// \"green\": 123,\n// \"blue\": 123,\n// \"gain\": 0,\n// \"white\": 0,\n// \"effect\": 0,\n// \"turn\": \"off\"\n// }\n\n// create complete message, fill with buffer from the previous messages\nlet Hue = msg.payload.Hue || flow.get(\"Hue\");\nlet Saturation = msg.payload.Saturation || flow.get(\"Saturation\");\nlet Brightness = msg.payload.Brightness || flow.get(\"Brightness\");\n\n// store variables\nflow.set(\"Hue\", Hue);\nflow.set(\"Saturation\", Saturation);\nflow.set(\"Brightness\", Brightness);\n\n// prep hsl message\nlet hsl = {\"payload\": [Hue, Saturation, Brightness]}\n\n// prep gain\n// brightness of 100 makes the RGB go white\nif ( Brightness >= 100 ){\n Brightness = 99;\n}\nmsg.payload[\"gain\"] = Brightness;\n\n// set on/off\nif (msg.payload.On === true){\n msg.payload[\"turn\"]=\"on\"\n}\nif (msg.payload.On === false){\n msg.payload[\"turn\"]=\"off\"\n}\n\n// return message\nreturn [msg, hsl];", |
|
"outputs": 2, |
|
"noerr": 0, |
|
"x": 755, |
|
"y": 2000, |
|
"wires": [ |
|
[ |
|
"5ba540d6.f3b59" |
|
], |
|
[ |
|
"b4c6a5b1.1b65c8" |
|
] |
|
], |
|
"inputLabels": [ |
|
"homekit" |
|
], |
|
"outputLabels": [ |
|
"msg", |
|
"hsl" |
|
], |
|
"icon": "font-awesome/fa-list", |
|
"l": false |
|
}, |
|
{ |
|
"id": "b4c6a5b1.1b65c8", |
|
"type": "color-convert", |
|
"z": "4d2d578e.6cea28", |
|
"input": "hsl", |
|
"output": "rgb", |
|
"outputType": "object", |
|
"scaleInput": false, |
|
"x": 815, |
|
"y": 2020, |
|
"wires": [ |
|
[ |
|
"ac05db56.788c48", |
|
"5ba540d6.f3b59" |
|
] |
|
], |
|
"inputLabels": [ |
|
"homekit" |
|
], |
|
"outputLabels": [ |
|
"rgb" |
|
], |
|
"l": false |
|
}, |
|
{ |
|
"id": "ac05db56.788c48", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 875, |
|
"y": 2040, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "fc05e859.2b22f", |
|
"type": "comment", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Homekit bugs", |
|
"info": "The HomeKit node has a problem when ever it is deployed. If you have to deploy it more than once (hint: you will have to) then you’ll want to restart node-red for HomeKit to keep working. \n\nReload the browser window\n\n```\ncommand-R\n```\n\n\nEasiest restart:\n\n```\nsudo systemctl restart nodered.service\n```\n\n[source:](https://community.openhab.org/t/my-node-red-homekit-openhab-setup/54577)", |
|
"x": 130, |
|
"y": 1660, |
|
"wires": [] |
|
}, |
|
{ |
|
"id": "5ba540d6.f3b59", |
|
"type": "join", |
|
"z": "4d2d578e.6cea28", |
|
"name": "merge", |
|
"mode": "custom", |
|
"build": "merged", |
|
"property": "payload", |
|
"propertyType": "msg", |
|
"key": "topic", |
|
"joiner": "\\n", |
|
"joinerType": "str", |
|
"accumulate": false, |
|
"timeout": "0.2", |
|
"count": "", |
|
"reduceRight": false, |
|
"reduceExp": "", |
|
"reduceInit": "", |
|
"reduceInitType": "", |
|
"reduceFixup": "", |
|
"x": 950, |
|
"y": 2000, |
|
"wires": [ |
|
[ |
|
"3563ac62.a322dc", |
|
"f240d7bd.42308" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "3563ac62.a322dc", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 1035, |
|
"y": 2020, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "ab3bf9d.85b4108", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "prep homekit", |
|
"func": "// convert RGB to HSL for Homekit\nfunction rgbToHsl(r, g, b) {\n r /= 255, g /= 255, b /= 255;\n\n var max = Math.max(r, g, b), min = Math.min(r, g, b);\n var h, s, l = (max + min) / 2;\n\n if (max == min) {\n h = s = 0; // achromatic\n } else {\n var d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n // rounding to whole numbers prevents decline due to decimal rounding in loops.\n h = Math.round(h*360);\n s = Math.round(s*100);\n l = Math.round(l*100);\n return [ h, s, l ];\n}\n\n// set hsl\nlet hsl = rgbToHsl( msg.payload.red,\n msg.payload.green,\n msg.payload.blue\n )\n\n// brightness of 100 makes the RGB go white\nif ( msg.payload.gain >= 100 ){\n msg.payload.gain = 99;\n}\n\nvar homekitMsg = { payload:{ \"Hue\": hsl[0],\n \"Saturation\": hsl[1],\n \"Brightness\": msg.payload.gain}\n };\n\nhomekitMsg.payload[\"On\"]=msg.payload.ison\n\nreturn homekitMsg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 455, |
|
"y": 2000, |
|
"wires": [ |
|
[ |
|
"92d9884c.6977f8", |
|
"c2653069.94d33" |
|
] |
|
], |
|
"icon": "node-red-contrib-homekit-bridged/homekit.png", |
|
"l": false |
|
}, |
|
{ |
|
"id": "c2653069.94d33", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 455, |
|
"y": 2040, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "1f4ac2c.0b63ebd", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": false, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 675, |
|
"y": 2040, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "2ecc8160.9aeb2e", |
|
"type": "homekit-service", |
|
"z": "4d2d578e.6cea28", |
|
"isParent": true, |
|
"bridge": "93e1fd.7adf2e", |
|
"parentService": "", |
|
"name": "🌻 Zonnebloem", |
|
"serviceName": "Lightbulb", |
|
"topic": "", |
|
"filter": false, |
|
"manufacturer": "Default Manufacturer", |
|
"model": "Default Model", |
|
"serialNo": "Default Serial Number", |
|
"cameraConfigVideoProcessor": "ffmpeg", |
|
"cameraConfigSource": "", |
|
"cameraConfigStillImageSource": "", |
|
"cameraConfigMaxStreams": 2, |
|
"cameraConfigMaxWidth": 1280, |
|
"cameraConfigMaxHeight": 720, |
|
"cameraConfigMaxFPS": 10, |
|
"cameraConfigMaxBitrate": 300, |
|
"cameraConfigVideoCodec": "libx264", |
|
"cameraConfigAudioCodec": "libfdk_aac", |
|
"cameraConfigAudio": false, |
|
"cameraConfigPacketSize": 1316, |
|
"cameraConfigVerticalFlip": false, |
|
"cameraConfigHorizontalFlip": false, |
|
"cameraConfigMapVideo": "0:0", |
|
"cameraConfigMapAudio": "0:1", |
|
"cameraConfigVideoFilter": "scale=1280:720", |
|
"cameraConfigAdditionalCommandLine": "-tune zerolatency", |
|
"cameraConfigDebug": false, |
|
"cameraConfigSnapshotOutput": "disabled", |
|
"cameraConfigInterfaceName": "", |
|
"characteristicProperties": "{\"name\":\"🌻 Zonnebloem\", \"Brightness\":true, \"On\": false}", |
|
"x": 900, |
|
"y": 2120, |
|
"wires": [ |
|
[ |
|
"b8541a02.9c2918" |
|
], |
|
[] |
|
] |
|
}, |
|
{ |
|
"id": "be6b91e3.bbe8a8", |
|
"type": "inject", |
|
"z": "4d2d578e.6cea28", |
|
"name": "debug", |
|
"topic": "", |
|
"payload": "{\"see\":\"options\"}", |
|
"payloadType": "json", |
|
"repeat": "", |
|
"crontab": "", |
|
"once": false, |
|
"onceDelay": 0.1, |
|
"x": 750, |
|
"y": 2100, |
|
"wires": [ |
|
[ |
|
"2ecc8160.9aeb2e" |
|
] |
|
] |
|
}, |
|
{ |
|
"id": "8c7a3254.d34138", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "prep homekit", |
|
"func": "// set payload\nvar homekitMsg = { payload:{ \"Brightness\": msg.payload.white,\n \"On\": msg.payload.ison }};\nreturn homekitMsg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 455, |
|
"y": 2120, |
|
"wires": [ |
|
[ |
|
"2ecc8160.9aeb2e" |
|
] |
|
], |
|
"icon": "node-red-contrib-homekit-bridged/homekit.png", |
|
"l": false |
|
}, |
|
{ |
|
"id": "60104f0d.7edd58", |
|
"type": "debug", |
|
"z": "4d2d578e.6cea28", |
|
"name": "", |
|
"active": true, |
|
"tosidebar": true, |
|
"console": false, |
|
"tostatus": true, |
|
"complete": "payload", |
|
"targetType": "msg", |
|
"x": 1035, |
|
"y": 2180, |
|
"wires": [], |
|
"l": false |
|
}, |
|
{ |
|
"id": "b8541a02.9c2918", |
|
"type": "function", |
|
"z": "4d2d578e.6cea28", |
|
"name": "Complete msg", |
|
"func": "// defaultPayload = {\n// \"mode\": \"color\",\n// \"red\": 123,\n// \"green\": 123,\n// \"blue\": 123,\n// \"gain\": 0,\n// \"white\": 0,\n// \"effect\": 0,\n// \"turn\": \"off\"\n// }\n\n// homekit calles it Brightness, Shelly calls it White.\nlet white = msg.payload.Brightness || flow.get(\"white\");\n\n// prep gain\nmsg.payload[\"white\"] = white;\n\n// set on/off\nif (msg.payload.Brightness != flow.get(\"white\") ){\n // brightness changed\n msg.payload[\"turn\"]=\"on\"\n}\nif (msg.payload.On === true){\n msg.payload[\"turn\"]=\"on\"\n}\nif (msg.payload.On === false){\n msg.payload[\"turn\"]=\"off\"\n}\n\n// store variables\nflow.set(\"white\", white);\n\n// delete Brightness\ndelete msg.payload.Brightness;\n\n// return message\nreturn msg;", |
|
"outputs": 1, |
|
"noerr": 0, |
|
"x": 1035, |
|
"y": 2120, |
|
"wires": [ |
|
[ |
|
"60104f0d.7edd58", |
|
"f240d7bd.42308" |
|
] |
|
], |
|
"inputLabels": [ |
|
"homekit" |
|
], |
|
"outputLabels": [ |
|
"msg" |
|
], |
|
"icon": "font-awesome/fa-list", |
|
"l": false |
|
}, |
|
{ |
|
"id": "707b233c.d0ad2c", |
|
"type": "mqtt-broker", |
|
"z": "", |
|
"name": "KoekoekPi", |
|
"broker": "localhost", |
|
"port": "1883", |
|
"clientid": "", |
|
"usetls": false, |
|
"compatmode": false, |
|
"keepalive": "60", |
|
"cleansession": true, |
|
"birthTopic": "", |
|
"birthQos": "0", |
|
"birthRetain": "false", |
|
"birthPayload": "", |
|
"closeTopic": "", |
|
"closeQos": "0", |
|
"closeRetain": "false", |
|
"closePayload": "", |
|
"willTopic": "", |
|
"willQos": "0", |
|
"willRetain": "false", |
|
"willPayload": "" |
|
}, |
|
{ |
|
"id": "93e1fd.7adf2e", |
|
"type": "homekit-bridge", |
|
"z": "", |
|
"bridgeName": "Koekoek Home", |
|
"pinCode": "111-11-111", |
|
"port": "", |
|
"allowInsecureRequest": false, |
|
"manufacturer": "Koekoek", |
|
"model": "Model", |
|
"serialNo": "Serial Number", |
|
"customMdnsConfig": false, |
|
"mdnsMulticast": true, |
|
"mdnsInterface": "", |
|
"mdnsPort": "", |
|
"mdnsIp": "", |
|
"mdnsTtl": "", |
|
"mdnsLoopback": true, |
|
"mdnsReuseAddr": true, |
|
"allowMessagePassthrough": true |
|
}, |
|
{ |
|
"id": "efa9c015.d79758", |
|
"type": "ui_group", |
|
"z": "", |
|
"name": "Woonkamer", |
|
"tab": "f529ddcc.a47f8", |
|
"order": 1, |
|
"disp": true, |
|
"width": "6", |
|
"collapse": true |
|
}, |
|
{ |
|
"id": "f529ddcc.a47f8", |
|
"type": "ui_tab", |
|
"z": "", |
|
"name": "Lichten", |
|
"icon": "dashboard", |
|
"order": 1, |
|
"disabled": false, |
|
"hidden": false |
|
} |
|
] |