originallyus / node-red-contrib-alexa-local

An easy-to-use NodeRED node for adding Alexa capability to NodeRED. NO Alexa Skills required.
106 stars 25 forks source link

High cpu % usage with this node #67

Open MattL0 opened 5 years ago

MattL0 commented 5 years ago

Hi,

all my nodered, npm, node.js, debian etc are updated to their latest stable release.

I created 11 nodes (alexa devices) with you plugin/package.

Today i was looking at htop and ...i saw node-red cpu usage is more or less constant to 50% usage. ( I have a amd 2700x cpu).

So, this is the only change in nodes i made to my node-red setup in the last days. I tried to clean the cache of npm... but it doe nothing.

One thing I try is copy paste the flows i created with your npm package, then i removed them...and i deployed node-red. Since then.. my cpu usage is back to normal (0-5%). Finally I putted the flows i just remove into node-red ... and deployed again.. ( had to rediscover with ALexa but this is normal). Unfortunatly, node-red process is back to 50% again.

I will send you my two flows in another message

MattL0 commented 5 years ago

So this is the first flow. I use those nodes to triggers events ( same as scene if you want) of my Homeseer automation system ( an example in homeseer would be...: when an specific mqtt message receive a payload with ''on'' then turn on the event ''goodnight''

[ { "id": "e2ccb4ed.a4bb08", "type": "tab", "label": "Alexa local scene", "disabled": false, "info": "" }, { "id": "9f37aac0.e2c218", "type": "debug", "z": "e2ccb4ed.a4bb08", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 510, "y": 40, "wires": [] }, { "id": "231edb20.0d5e04", "type": "alexa-local", "z": "e2ccb4ed.a4bb08", "devicename": "Scene goodight", "inputtrigger": false, "x": 110, "y": 40, "wires": [ [ "17de273b.17f719", "9f37aac0.e2c218" ] ] }, { "id": "e8192bf7.f4e6c8", "type": "debug", "z": "e2ccb4ed.a4bb08", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 570, "y": 120, "wires": [] }, { "id": "34ba2295.98e1ae", "type": "mqtt out", "z": "e2ccb4ed.a4bb08", "name": "", "topic": "AlexaMqtt/scene/goodmornig", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 320, "y": 120, "wires": [] }, { "id": "ec4101bc.6ddf2", "type": "alexa-local", "z": "e2ccb4ed.a4bb08", "devicename": "scene goodmorning", "inputtrigger": false, "x": 110, "y": 120, "wires": [ [ "34ba2295.98e1ae", "e8192bf7.f4e6c8" ] ] }, { "id": "17de273b.17f719", "type": "mqtt out", "z": "e2ccb4ed.a4bb08", "name": "", "topic": "AlexaMqtt/scene/goodnight", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 320, "y": 40, "wires": [] }, { "id": "85f0912d.a08af", "type": "debug", "z": "e2ccb4ed.a4bb08", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 555, "y": 186.5, "wires": [] }, { "id": "48157ac7.a367d4", "type": "mqtt out", "z": "e2ccb4ed.a4bb08", "name": "", "topic": "AlexaMqtt/scene/TurnOfElectronics", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 360, "y": 180, "wires": [] }, { "id": "463bef17.d6022", "type": "alexa-local", "z": "e2ccb4ed.a4bb08", "devicename": "scene turnoffelectronics", "inputtrigger": false, "x": 120, "y": 200, "wires": [ [ "48157ac7.a367d4" ] ] }, { "id": "4c706bef.646df4", "type": "mqtt-broker", "z": "", "name": "", "broker": "127.0.0.1", "port": "1883", "clientid": "", "usetls": false, "compatmode": true, "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "closeTopic": "", "closePayload": "", "willTopic": "", "willQos": "0", "willPayload": "" } ]

MattL0 commented 5 years ago

So this is the second flow. I use those nodes to directly ( by mqtt) associate the value receives in the payload to a specific node in my Homeseer HS3 system. I needed to write a function for some of those to work, because they are dimming node in my Homeseer setup .

[ { "id": "7c2c5a91.cc0744", "type": "tab", "label": "Alexa local device", "disabled": false, "info": "" }, { "id": "7f95d6a6.5380c8", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 530, "y": 60, "wires": [] }, { "id": "5b73fb85.85eb34", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/Bouba", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 390, "y": 60, "wires": [] }, { "id": "7d9c98c7.06ecd8", "type": "function", "z": "7c2c5a91.cc0744", "name": "payload", "func": "var a = {payload :msg.bri };\nvar b = {payload: msg.payload};\n \nif ( msg.on_off_command === true){\n return b;\n} else {\n return a;\n}\n\n\n", "outputs": 1, "noerr": 0, "x": 220, "y": 60, "wires": [ [ "7f95d6a6.5380c8", "5b73fb85.85eb34" ] ] }, { "id": "a4eb70fb.3ad6b", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "All the light", "inputtrigger": false, "x": 110, "y": 60, "wires": [ [ "7d9c98c7.06ecd8" ] ] }, { "id": "f2ad8c6e.337b7", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 570, "y": 120, "wires": [] }, { "id": "476c0e2.f7737f", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/GroupeSalon", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 450, "y": 120, "wires": [] }, { "id": "24df53da.0ba71c", "type": "function", "z": "7c2c5a91.cc0744", "name": "payload", "func": "var a = {payload :msg.bri };\nvar b = {payload: msg.payload};\n \nif ( msg.on_off_command === true){\n return b;\n} else {\n return a;\n}\n\n\n", "outputs": 1, "noerr": 0, "x": 280, "y": 120, "wires": [ [ "f2ad8c6e.337b7", "476c0e2.f7737f" ] ] }, { "id": "6f12b0e1.bd937", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "LivingRoom group", "inputtrigger": false, "x": 130, "y": 120, "wires": [ [ "24df53da.0ba71c" ] ] }, { "id": "6503a5d1.60777c", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 690, "y": 200, "wires": [] }, { "id": "f1cd51f1.1bf08", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/Groupebedroom", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 460, "y": 200, "wires": [] }, { "id": "eeb6aaf7.773398", "type": "function", "z": "7c2c5a91.cc0744", "name": "payload", "func": "var a = {payload :msg.bri };\nvar b = {payload: msg.payload};\n \nif ( msg.on_off_command === true){\n return b;\n} else {\n return a;\n}\n\n\n", "outputs": 1, "noerr": 0, "x": 280, "y": 200, "wires": [ [ "6503a5d1.60777c", "f1cd51f1.1bf08" ] ] }, { "id": "b737d090.d0918", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "Bedroom Group", "inputtrigger": false, "x": 120, "y": 200, "wires": [ [ "eeb6aaf7.773398" ] ] }, { "id": "e1e9c4f5.39d0b8", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 650, "y": 260, "wires": [] }, { "id": "14f9c829.30d538", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/GroupKitchen", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 450, "y": 280, "wires": [] }, { "id": "50deac38.308574", "type": "function", "z": "7c2c5a91.cc0744", "name": "payload", "func": "var a = {payload :msg.bri };\nvar b = {payload: msg.payload};\n \nif ( msg.on_off_command === true){\n return b;\n} else {\n return a;\n}\n\n\n", "outputs": 1, "noerr": 0, "x": 280, "y": 280, "wires": [ [ "e1e9c4f5.39d0b8", "14f9c829.30d538" ] ] }, { "id": "5b1b933e.e98cac", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "Kitchen group", "inputtrigger": false, "x": 120, "y": 260, "wires": [ [ "50deac38.308574" ] ] }, { "id": "7cf19f32.40fdd", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 650, "y": 340, "wires": [] }, { "id": "1afa681b.959ef8", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/GroupHallway", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 450, "y": 380, "wires": [] }, { "id": "d65bbb99.853708", "type": "function", "z": "7c2c5a91.cc0744", "name": "payload", "func": "var a = {payload :msg.bri };\nvar b = {payload: msg.payload};\n \nif ( msg.on_off_command === true){\n return b;\n} else {\n return a;\n}\n\n\n", "outputs": 1, "noerr": 0, "x": 280, "y": 380, "wires": [ [ "7cf19f32.40fdd", "1afa681b.959ef8" ] ] }, { "id": "d4e40c4d.04a4c", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "Hallway group", "inputtrigger": false, "x": 110, "y": 360, "wires": [ [ "d65bbb99.853708" ] ] }, { "id": "9c18a546.94aa88", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 670, "y": 480, "wires": [] }, { "id": "d5f59e64.1d6f8", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/Bathroom", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 440, "y": 480, "wires": [] }, { "id": "d7dff348.d5554", "type": "function", "z": "7c2c5a91.cc0744", "name": "payload", "func": "var a = {payload :msg.bri };\nvar b = {payload: msg.payload};\n \nif ( msg.on_off_command === true){\n return b;\n} else {\n return a;\n}\n\n\n", "outputs": 1, "noerr": 0, "x": 280, "y": 480, "wires": [ [ "9c18a546.94aa88", "d5f59e64.1d6f8" ] ] }, { "id": "8dcbbf29.af808", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "Bathroom Group", "inputtrigger": false, "x": 120, "y": 460, "wires": [ [ "d7dff348.d5554" ] ] }, { "id": "fd248931.53a298", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "x": 1210, "y": 60, "wires": [] }, { "id": "d9b908b7.54cfb8", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/Watermachine", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 1030, "y": 60, "wires": [] }, { "id": "c6bdf4e4.a29598", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "Water machine", "inputtrigger": false, "x": 850, "y": 60, "wires": [ [ "d9b908b7.54cfb8", "fd248931.53a298" ] ] }, { "id": "b502fd8b.e4c41", "type": "debug", "z": "7c2c5a91.cc0744", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "x": 1210, "y": 120, "wires": [] }, { "id": "7f959817.758b58", "type": "mqtt out", "z": "7c2c5a91.cc0744", "name": "", "topic": "AlexaMqtt/LivingRoomTV", "qos": "2", "retain": "", "broker": "4c706bef.646df4", "x": 1030, "y": 120, "wires": [] }, { "id": "59bd9adb.04f214", "type": "alexa-local", "z": "7c2c5a91.cc0744", "devicename": "Living room tv", "inputtrigger": false, "x": 850, "y": 120, "wires": [ [ "7f959817.758b58", "b502fd8b.e4c41" ] ] }, { "id": "4c706bef.646df4", "type": "mqtt-broker", "z": "", "name": "", "broker": "127.0.0.1", "port": "1883", "clientid": "", "usetls": false, "compatmode": true, "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "closeTopic": "", "closePayload": "", "willTopic": "", "willQos": "0", "willPayload": "" } ]

MattL0 commented 5 years ago

I think i know when the issue happen ( with dimming lights)

  1. When i say alexa light to 25% ''
  2. Alexa light off 3: alexa light on.

then the node-red process goes directly to 50%