dmamontov / node-red-contrib-magic-home

Node-red integration magic-home
GNU General Public License v3.0
5 stars 9 forks source link

Issues setting the color of my RGB Controller #3

Closed Voltfest closed 3 years ago

Voltfest commented 3 years ago

Hello,

I face some issues when trying to change the color of my LED Stripe. After reading the other thread, I found out what to inject into the rgb node to change the color. As my device just supports rgb, I get the best results when not injecting any ww or cw values. However, this still works only once or twice until I recieve the following message "Command timed out" from the Magic Home Node.

It should be the controller type ZJ-MWIR-RGB, the wifi hostname is ZENGGE_33_A0F10F (if thats helpfull) and Firmware is 33.v8.57.7134-A

Thanks a lot! Voltfest

dmamontov commented 3 years ago

he joins every time. I have such an error, but there is a re-logging and everything is ok. or are you trying to make an effect? everything works with exactly the same controller.

dmamontov commented 3 years ago

Try changing the timeout on this line

https://github.com/dmamontov/node-red-contrib-magic-home/blob/master/nodes/magic-home-rgbcw.js#L9

Perhaps you just do not have a sufficiently stable connection.

Voltfest commented 3 years ago

Hi, thanks for your reply! Yes, I am trying to make a dimming effect. If I inject a payload like {"r":255,"g":0,"b":0}, the color will change, and after the 10s timeout I recieve the error message. I am not able to control the LEDs until then, any injected commands will stack up and be executed in 10s steps. If I ping the LED it takes less than 10ms to answer reliably. So one way would be to reduce the timeout like you proposed but I don't feel like that would be clean. Do you have another idea how to avoid this timeout error?

dmamontov commented 3 years ago

Another option is to use the pattern node and add an effect there. all colors will be loaded at once.

blaxwan01 commented 3 years ago

Hi, found a kind of solution, I send anything (empty string) to the status node every second for example, and any other node of the same device reacts to their inputs almost without delay

dmamontov commented 3 years ago

Hi, found a kind of solution, I send anything (empty string) to the status node every second for example, and any other node of the same device reacts to their inputs almost without delay

Can you give more details?

blaxwan01 commented 3 years ago

image with this simple refreshing, I have almost no delay, not sure that is the best way :|

blaxwan01 commented 3 years ago

~17 days it turned on constantly and I use it every day, and everything works perfectly yet

blaxwan01 commented 3 years ago

Here is the code of my flow with a fully working setup for my system

[ { "id": "4f5786c2.ed5908", "type": "function", "z": "63b92d89.6b32b4", "name": "Color Separator", "func": "msg.payload=msg.payload.color\nreturn msg;", "outputs": 1, "noerr": 0, "x": 620, "y": 240, "wires": [ [ "f1395fa1.62f6b" ] ] }, { "id": "502a6ed5.95101", "type": "inject", "z": "63b92d89.6b32b4", "name": "Refresh 1 sec", "topic": "", "payload": "", "payloadType": "str", "repeat": "1", "crontab": "", "once": false, "onceDelay": 0.1, "x": 160, "y": 160, "wires": [ [ "151b159.e7f8eea" ] ] }, { "id": "63a7da5f.544f24", "type": "function", "z": "63b92d89.6b32b4", "name": "Interpret", "func": "var r=msg.payload.red;\nvar g=msg.payload.green;\nvar b=msg.payload.blue;\n\nmsg.payload={\"r\":r,\"g\":g,\"b\":b};\nreturn msg;", "outputs": 1, "noerr": 0, "x": 780, "y": 400, "wires": [ [ "35f80b.1fa567f6" ] ] }, { "id": "35f80b.1fa567f6", "type": "magic-home-rgb", "z": "63b92d89.6b32b4", "name": "RGB - RGB BackTV Stripe", "device": "192.168.50.94", "x": 1060, "y": 400, "wires": [ [] ] }, { "id": "99bd6bda.7aa0a8", "type": "magic-home-on", "z": "63b92d89.6b32b4", "name": "ON/OFF RGB BackTV Stripe", "device": "192.168.50.94", "x": 1060, "y": 340, "wires": [ [] ] }, { "id": "f1395fa1.62f6b", "type": "color-convert", "z": "63b92d89.6b32b4", "input": "rgb", "output": "hsv", "outputType": "array", "x": 830, "y": 240, "wires": [ [ "220c81b8.cd3aae" ] ] }, { "id": "220c81b8.cd3aae", "type": "function", "z": "63b92d89.6b32b4", "name": "Format", "func": "var outmsg={};\nvar Hue = flow.get('Hue')||0;\nvar Saturation = flow.get('Saturation')||0;\nvar Brightness = flow.get('Brightness')||100;\nvar status = flow.get('status');\n\nif(msg.payload[0]===0 && msg.payload[1]===0 && msg.payload[2]===0){\n outmsg.payload={\"On\":false};\n} else{\n Hue = msg.payload[0];\n flow.set('Hue',Hue);\n Saturation = msg.payload[1];\n flow.set('Saturation',Saturation);\n Brightness = msg.payload[2];\n flow.set('Brightness',Brightness);\n outmsg.payload={\n \"On\":status,\n \"Hue\":Hue,\n \"Saturation\":Saturation,\n \"Brightness\":Brightness\n }\n}\nreturn [outmsg];\n", "outputs": 1, "noerr": 0, "x": 1000, "y": 240, "wires": [ [ "5cf3bd20.2f2174" ] ] }, { "id": "5cf3bd20.2f2174", "type": "homekit-service", "z": "63b92d89.6b32b4", "isParent": true, "bridge": "9adfee52.1e87e", "parentService": "", "name": "TV Back", "serviceName": "Lightbulb", "topic": "", "filter": false, "manufacturer": "Default Manufacturer", "model": "Default Model", "serialNo": "Default Serial Number", "firmwareRev": "", "hardwareRev": "", "softwareRev": "", "cameraConfigVideoProcessor": "", "cameraConfigSource": "", "cameraConfigStillImageSource": "", "cameraConfigMaxStreams": "", "cameraConfigMaxWidth": "", "cameraConfigMaxHeight": "", "cameraConfigMaxFPS": "", "cameraConfigMaxBitrate": "", "cameraConfigVideoCodec": "", "cameraConfigAudioCodec": "", "cameraConfigAudio": false, "cameraConfigPacketSize": "", "cameraConfigVerticalFlip": false, "cameraConfigHorizontalFlip": false, "cameraConfigMapVideo": "", "cameraConfigMapAudio": "", "cameraConfigVideoFilter": "", "cameraConfigAdditionalCommandLine": "", "cameraConfigDebug": false, "cameraConfigInterfaceName": "", "characteristicProperties": "{ \"Brightness\":true, \"Hue\":true, \"Saturation\":true}", "waitForSetupMsg": false, "outputs": 2, "x": 160, "y": 340, "wires": [ [ "d543ad57.a4197", "926e40d9.571ab" ], [] ] }, { "id": "d543ad57.a4197", "type": "function", "z": "63b92d89.6b32b4", "name": "Output", "func": "var Hue = flow.get('Hue')||0;\nvar Saturation = flow.get('Saturation')||0;\nvar Brightness = flow.get('Brightness')||100;\n\nif(msg.payload.Hue){\n Hue = msg.payload.Hue;\n flow.set('Hue',Hue);\n}\nif(msg.payload.Saturation){\n Saturation = msg.payload.Saturation;\n flow.set('Saturation',Saturation);\n}\nif(msg.payload.Brightness){\n Brightness = msg.payload.Brightness;\n flow.set('Brightness',Brightness);\n}\nif (msg.hap.context !== undefined) {\n if(msg.payload.On === true){\n return [{\"payload\":[Hue,Saturation,Brightness]}]\n }\n if(msg.payload.On === false){\n return [{\"payload\":[0,0,0]}]\n }\n else{\n return [{\"payload\":[Hue,Saturation,Brightness]}]\n }\n}", "outputs": 1, "noerr": 0, "x": 450, "y": 400, "wires": [ [ "b99a6c60.9ad71" ] ] }, { "id": "b99a6c60.9ad71", "type": "color-convert", "z": "63b92d89.6b32b4", "input": "hsv", "output": "rgb", "outputType": "object", "scaleInput": false, "x": 610, "y": 400, "wires": [ [ "63a7da5f.544f24" ] ] }, { "id": "926e40d9.571ab", "type": "function", "z": "63b92d89.6b32b4", "name": "On/Off Converter", "func": "var outmsg ={};\n\nif (msg.payload.On===true)\n {outmsg.payload= {\"on\":true}, flow.set(\"status\",true)} else \n {if (msg.payload.On===false)\n {outmsg.payload= {\"on\":false},flow.set(\"status\",false)} else {return}\n \n}\n\n\nreturn [outmsg];\n", "outputs": 1, "noerr": 0, "x": 490, "y": 340, "wires": [ [ "99bd6bda.7aa0a8" ] ] }, { "id": "151b159.e7f8eea", "type": "magic-home-status", "z": "63b92d89.6b32b4", "name": "RGB BackTV Stripe", "device": "192.168.50.94", "x": 400, "y": 160, "wires": [ [ "148bcae3.03da85" ] ] }, { "id": "148bcae3.03da85", "type": "function", "z": "63b92d89.6b32b4", "name": "OnOff Status", "func": "\nif (msg.payload.on===true)\n{flow.set(\"status\",true)}\n\nif (msg.payload.on===false)\n{flow.set(\"status\",false)} \n\nmsg.payload = flow.get(\"status\");\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "x": 610, "y": 160, "wires": [ [] ] }, { "id": "5d391ce6.c9bcd4", "type": "magic-home-status", "z": "63b92d89.6b32b4", "name": "RGB BackTV Stripe", "device": "192.168.50.94", "x": 400, "y": 240, "wires": [ [ "4f5786c2.ed5908" ] ] }, { "id": "d548b533.6edf08", "type": "inject", "z": "63b92d89.6b32b4", "name": "Refresh 1 min", "topic": "", "payload": "", "payloadType": "str", "repeat": "60", "crontab": "", "once": false, "onceDelay": 0.1, "x": 160, "y": 240, "wires": [ [ "5d391ce6.c9bcd4" ] ] }, { "id": "9adfee52.1e87e", "type": "homekit-bridge", "z": "", "bridgeName": "RedNode", "pinCode": "111-11-111", "port": "", "allowInsecureRequest": false, "manufacturer": "EVIX LTD", "model": "1.2.0", "serialNo": "Default Serial Number", "firmwareRev": "1.2.0", "hardwareRev": "1.2.0", "softwareRev": "1.2.0", "customMdnsConfig": false, "mdnsMulticast": true, "mdnsInterface": "", "mdnsPort": "", "mdnsIp": "", "mdnsTtl": "", "mdnsLoopback": true, "mdnsReuseAddr": true, "allowMessagePassthrough": true } ]

blaxwan01 commented 3 years ago

and video comparing between MagicHome app and HomeKit app delays

https://user-images.githubusercontent.com/69650500/104231253-5a5f1200-5457-11eb-8c6f-c72cec020bc9.MP4

hasspi88 commented 3 years ago

和MagicHome应用程序和HomeKit应用程序延迟之间的视频比较

IMG_0897.MP4

I imported your stream and found that you can only turn on the light, but not turn on the light and adjust the brightness and color

hasspi88 commented 3 years ago

[ { "id": "4f5786c2.ed5908", "type": "function", "z": "63b92d89.6b32b4", "name": "Color Separator", "func": "msg.payload=msg.payload.color\nreturn msg;", "outputs": 1, "noerr": 0, "x": 620, "y": 240, "wires": [ [ "f1395fa1.62f6b" ] ] }, { "id": "502a6ed5.95101", "type": "inject", "z": "63b92d89.6b32b4", "name": "Refresh 1 sec", "topic": "", "payload": "", "payloadType": "str", "repeat": "1", "crontab": "", "once": false, "onceDelay": 0.1, "x": 160, "y": 160, "wires": [ [ "151b159.e7f8eea" ] ] }, { "id": "63a7da5f.544f24", "type": "function", "z": "63b92d89.6b32b4", "name": "Interpret", "func": "var r=msg.payload.red;\nvar g=msg.payload.green;\nvar b=msg.payload.blue;\n\nmsg.payload={\"r\":r,\"g\":g,\"b\":b};\nreturn msg;", "outputs": 1, "noerr": 0, "x": 780, "y": 400, "wires": [ [ "35f80b.1fa567f6" ] ] }, { "id": "35f80b.1fa567f6", "type": "magic-home-rgb", "z": "63b92d89.6b32b4", "name": "RGB - RGB BackTV Stripe", "device": "192.168.50.94", "x": 1060, "y": 400, "wires": [ [] ] }, { "id": "99bd6bda.7aa0a8", "type": "magic-home-on", "z": "63b92d89.6b32b4", "name": "ON/OFF RGB BackTV Stripe", "device": "192.168.50.94", "x": 1060, "y": 340, "wires": [ [] ] }, { "id": "f1395fa1.62f6b", "type": "color-convert", "z": "63b92d89.6b32b4", "input": "rgb", "output": "hsv", "outputType": "array", "x": 830, "y": 240, "wires": [ [ "220c81b8.cd3aae" ] ] }, { "id": "220c81b8.cd3aae", "type": "function", "z": "63b92d89.6b32b4", "name": "Format", "func": "var outmsg={};\nvar Hue = flow.get('Hue')||0;\nvar Saturation = flow.get('Saturation')||0;\nvar Brightness = flow.get('Brightness')||100;\nvar status = flow.get('status');\n\nif(msg.payload[0]===0 && msg.payload[1]===0 && msg.payload[2]===0){\n outmsg.payload={\"On\":false};\n} else{\n Hue = msg.payload[0];\n flow.set('Hue',Hue);\n Saturation = msg.payload[1];\n flow.set('Saturation',Saturation);\n Brightness = msg.payload[2];\n flow.set('Brightness',Brightness);\n outmsg.payload={\n \"On\":status,\n \"Hue\":Hue,\n \"Saturation\":Saturation,\n \"Brightness\":Brightness\n }\n}\nreturn [outmsg];\n", "outputs": 1, "noerr": 0, "x": 1000, "y": 240, "wires": [ [ "5cf3bd20.2f2174" ] ] }, { "id": "5cf3bd20.2f2174", "type": "homekit-service", "z": "63b92d89.6b32b4", "isParent": true, "bridge": "9adfee52.1e87e", "parentService": "", "name": "TV Back", "serviceName": "Lightbulb", "topic": "", "filter": false, "manufacturer": "Default Manufacturer", "model": "Default Model", "serialNo": "Default Serial Number", "firmwareRev": "", "hardwareRev": "", "softwareRev": "", "cameraConfigVideoProcessor": "", "cameraConfigSource": "", "cameraConfigStillImageSource": "", "cameraConfigMaxStreams": "", "cameraConfigMaxWidth": "", "cameraConfigMaxHeight": "", "cameraConfigMaxFPS": "", "cameraConfigMaxBitrate": "", "cameraConfigVideoCodec": "", "cameraConfigAudioCodec": "", "cameraConfigAudio": false, "cameraConfigPacketSize": "", "cameraConfigVerticalFlip": false, "cameraConfigHorizontalFlip": false, "cameraConfigMapVideo": "", "cameraConfigMapAudio": "", "cameraConfigVideoFilter": "", "cameraConfigAdditionalCommandLine": "", "cameraConfigDebug": false, "cameraConfigInterfaceName": "", "characteristicProperties": "{ \"Brightness\":true, \"Hue\":true, \"Saturation\":true}", "waitForSetupMsg": false, "outputs": 2, "x": 160, "y": 340, "wires": [ [ "d543ad57.a4197", "926e40d9.571ab" ], [] ] }, { "id": "d543ad57.a4197", "type": "function", "z": "63b92d89.6b32b4", "name": "Output", "func": "var Hue = flow.get('Hue')||0;\nvar Saturation = flow.get('Saturation')||0;\nvar Brightness = flow.get('Brightness')||100;\n\nif(msg.payload.Hue){\n Hue = msg.payload.Hue;\n flow.set('Hue',Hue);\n}\nif(msg.payload.Saturation){\n Saturation = msg.payload.Saturation;\n flow.set('Saturation',Saturation);\n}\nif(msg.payload.Brightness){\n Brightness = msg.payload.Brightness;\n flow.set('Brightness',Brightness);\n}\nif (msg.hap.context !== undefined) {\n if(msg.payload.On === true){\n return [{\"payload\":[Hue,Saturation,Brightness]}]\n }\n if(msg.payload.On === false){\n return [{\"payload\":[0,0,0]}]\n }\n else{\n return [{\"payload\":[Hue,Saturation,Brightness]}]\n }\n}", "outputs": 1, "noerr": 0, "x": 450, "y": 400, "wires": [ [ "b99a6c60.9ad71" ] ] }, { "id": "b99a6c60.9ad71", "type": "color-convert", "z": "63b92d89.6b32b4", "input": "hsv", "output": "rgb", "outputType": "object", "scaleInput": false, "x": 610, "y": 400, "wires": [ [ "63a7da5f.544f24" ] ] }, { "id": "926e40d9.571ab", "type": "function", "z": "63b92d89.6b32b4", "name": "On/Off Converter", "func": "var outmsg ={};\n\nif (msg.payload.On===true)\n {outmsg.payload= {\"on\":true}, flow.set(\"status\",true)} else \n {if (msg.payload.On===false)\n {outmsg.payload= {\"on\":false},flow.set(\"status\",false)} else {return}\n \n}\n\n\nreturn [outmsg];\n", "outputs": 1, "noerr": 0, "x": 490, "y": 340, "wires": [ [ "99bd6bda.7aa0a8" ] ] }, { "id": "151b159.e7f8eea", "type": "magic-home-status", "z": "63b92d89.6b32b4", "name": "RGB BackTV Stripe", "device": "192.168.50.94", "x": 400, "y": 160, "wires": [ [ "148bcae3.03da85" ] ] }, { "id": "148bcae3.03da85", "type": "function", "z": "63b92d89.6b32b4", "name": "OnOff Status", "func": "\nif (msg.payload.on===true)\n{flow.set(\"status\",true)}\n\nif (msg.payload.on===false)\n{flow.set(\"status\",false)} \n\nmsg.payload = flow.get(\"status\");\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "x": 610, "y": 160, "wires": [ [] ] }, { "id": "5d391ce6.c9bcd4", "type": "magic-home-status", "z": "63b92d89.6b32b4", "name": "RGB BackTV Stripe", "device": "192.168.50.94", "x": 400, "y": 240, "wires": [ [ "4f5786c2.ed5908" ] ] }, { "id": "d548b533.6edf08", "type": "inject", "z": "63b92d89.6b32b4", "name": "Refresh 1 min", "topic": "", "payload": "", "payloadType": "str", "repeat": "60", "crontab": "", "once": false, "onceDelay": 0.1, "x": 160, "y": 240, "wires": [ [ "5d391ce6.c9bcd4" ] ] }, { "id": "9adfee52.1e87e", "type": "homekit-bridge", "z": "", "bridgeName": "RedNode", "pinCode": "111-11-111", "port": "", "allowInsecureRequest": false, "manufacturer": "EVIX LTD", "model": "1.2.0", "serialNo": "Default Serial Number", "firmwareRev": "1.2.0", "hardwareRev": "1.2.0", "softwareRev": "1.2.0", "customMdnsConfig": false, "mdnsMulticast": true, "mdnsInterface": "", "mdnsPort": "", "mdnsIp": "", "mdnsTtl": "", "mdnsLoopback": true, "mdnsReuseAddr": true, "allowMessagePassthrough": true } ]

I used your stream, he can't use it normally, he can feedback the status of the light normally. But I can't turn off the lights

dmamontov commented 3 years ago

The controller does not actually support changing the brightness, it just pulls out the colors based on the brightness using the formula. Turning it on and off works great. I think it's about the times, in one of the latest versions they can be changed. I'll close this question, it's not very clear who has any problems left. If anything, start a new one. I am back from a long vacation and am ready to refine.