Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Garage Node #27

Closed
wolli112 opened this issue Nov 5, 2023 · 7 comments
Closed

Smart Garage Node #27

wolli112 opened this issue Nov 5, 2023 · 7 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@wolli112
Copy link

wolli112 commented Nov 5, 2023

Hello, I have a problem with the Smart Garage Node.

I can open via Inject Node True and close via False.

As soon as I send a True from my logic I get an error message:
"There was an Error: Error: socket hang up"

If my logic says False it works

[{"id":"ba6fe5dfd84fa54c","type":"function","z":"ea46c87a4f403cf3","name":"Logic","func":"// Globale Variablen zum Speichern der Zustände\ncontext.set('input1', context.get('input1') || null);\ncontext.set('input2', context.get('input2') || null);\n\n// Eingangsnachrichten aktualisieren\nif (msg.topic === \"öffner\") {\n context.set('input2', msg.payload);\n} else if (msg.topic === \"garage\") {\n context.set('input1', msg.payload);\n}\n\n// Zustände abrufen\nvar input1 = context.get('input1');\nvar input2 = context.get('input2');\n\n// Überprüfen, ob beide Zustände gesetzt sind\nif (input1 !== null && input2 !== null) {\n if (input2 && !input1) {\n msg.payload = true;\n } else if (input2 && input1) {\n msg.payload = false;\n }\n context.set('input1', null);\n context.set('input2', null);\n return msg; // Nachricht senden, wenn beide Zustände gesetzt sind\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1450,"y":240,"wires":[["4390c1b3138aceaf","94215792b28f06a5","0ca60b227692d41d"]]},{"id":"0ca60b227692d41d","type":"smartgarage-control","z":"ea46c87a4f403cf3","confignode":"6c0bd9f2.e89438","name":"Garage 2","ip":"172.22.100.213","channel":"0","x":1620,"y":340,"wires":[["94215792b28f06a5"]]},{"id":"6c0bd9f2.e89438","type":"meross-config","name":"Meross App","key":"xxx Key has been removed here yyy"}]

@dehsgr
Copy link
Owner

dehsgr commented Nov 14, 2023

@wolli112 difficult to diagnose without having your input data and your attached code is not easily to parse. In future you should use code formatting when posting.

I suggest you output your message to a debug node side-by-side with Meross node. So you should see if "true" is really sent – I think it won't.

@dehsgr dehsgr added help wanted Extra attention is needed question Further information is requested labels Nov 14, 2023
@wolli112
Copy link
Author

I have inserted the code which is an export of the Node Red Flow as code.

You can simply import this into Node Red.

I have already used the debug node and the result is “true”.

The Meross Garage Node still reports:
"There was an Error: Error: socket hang up"

@dehsgr
Copy link
Owner

dehsgr commented Nov 16, 2023

Sorry, but I‘m not able to import the code here. I just tried it without luck. Nevertheless I already analyzed your code with nonspecific result. If outcome is „true“ and true works without your function node via direct inject the issue must be in your function node. 🤷🏼‍♂️

@wolli112
Copy link
Author

This code works

[{"id":"70058ccddaee11bc","type":"smartgarage-control","z":"ea46c87a4f403cf3","confignode":"6c0bd9f2.e89438","name":"Garage 2","ip":"172.22.100.213","channel":"0","x":1580,"y":680,"wires":[[]]},{"id":"2686f54f526dbdf2","type":"inject","z":"ea46c87a4f403cf3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1330,"y":680,"wires":[["70058ccddaee11bc","49d44a8606afaf9d"]]},{"id":"49d44a8606afaf9d","type":"debug","z":"ea46c87a4f403cf3","name":"debug 12","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1580,"y":760,"wires":[]},{"id":"6c0bd9f2.e89438","type":"meross-config","name":"Meross App","key":"xxx Key has been removed here yyy"}]

@wolli112
Copy link
Author

wolli112 commented Nov 16, 2023

This code doesn't work

[{"id":"bc8f84cd9b205ce9","type":"function","z":"ea46c87a4f403cf3","name":"Logic","func":"// Globale Variablen zum Speichern der Zustände\ncontext.set('input1', context.get('input1') || null);\ncontext.set('input2', context.get('input2') || null);\n\n// Eingangsnachrichten aktualisieren\nif (msg.topic === \"öffner\") {\n context.set('input2', msg.payload);\n} else if (msg.topic === \"garage\") {\n context.set('input1', msg.payload);\n}\n\n// Zustände abrufen\nvar input1 = context.get('input1');\nvar input2 = context.get('input2');\n\n// Überprüfen, ob beide Zustände gesetzt sind\nif (input1 !== null && input2 !== null) {\n if (input2 && !input1) {\n msg.payload = true;\n } else if (input2 && input1) {\n msg.payload = false;\n }\n context.set('input1', null);\n context.set('input2', null);\n return msg; // Nachricht senden, wenn beide Zustände gesetzt sind\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":880,"wires":[["567fd680b44181e7","78c54c8b205a5d87","1d7e44c9be3e1127"]]},{"id":"78c54c8b205a5d87","type":"debug","z":"ea46c87a4f403cf3","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1200,"y":880,"wires":[]},{"id":"567fd680b44181e7","type":"BDebug","z":"ea46c87a4f403cf3","name":"Debug","x":1030,"y":800,"wires":[]},{"id":"2df5f7d8044dcf8b","type":"function","z":"ea46c87a4f403cf3","name":"Garage","func":"msg.topic = \"garage\"; \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":820,"wires":[["bc8f84cd9b205ce9","e6df8a79681963e1"]]},{"id":"0911c0b5d0656d6a","type":"function","z":"ea46c87a4f403cf3","name":"Öffner","func":"msg.topic = \"öffner\"; \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":920,"wires":[["bc8f84cd9b205ce9","a45903cd65fc60f1"]]},{"id":"a45903cd65fc60f1","type":"BDebug","z":"ea46c87a4f403cf3","name":"Debug","x":870,"y":980,"wires":[]},{"id":"e6df8a79681963e1","type":"BDebug","z":"ea46c87a4f403cf3","name":"Debug","x":870,"y":760,"wires":[]},{"id":"bbc4a904d6d87253","type":"inject","z":"ea46c87a4f403cf3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":390,"y":820,"wires":[["2df5f7d8044dcf8b"]]},{"id":"3b9d40745475f32d","type":"inject","z":"ea46c87a4f403cf3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":390,"y":920,"wires":[["0911c0b5d0656d6a"]]},{"id":"1d7e44c9be3e1127","type":"smartgarage-control","z":"ea46c87a4f403cf3","confignode":"6c0bd9f2.e89438","name":"Garage 2","ip":"172.22.100.213","channel":"0","x":1200,"y":940,"wires":[[]]},{"id":"6c0bd9f2.e89438","type":"meross-config","name":"Meross App","key":"xxx Key has been removed here yyy"}]

At the end "true" should be sent to the Meross node if "Garage" is "false" and "Öffner" is "true".

The "true" also comes, only the Meross node brings the error.

@wolli112
Copy link
Author

wolli112 commented Nov 16, 2023

The two inject nodes are just for testing, but it doesn't work that way either, the Meross always gives the error.

And of course I removed my app code in the code inserted here.

@wolli112
Copy link
Author

wolli112 commented Jan 3, 2024

I was able to solve the problem, the nodes are as shown above.
In addition, I simply installed a delay of 1s in front of the Meross node, now it works without an error message!

@wolli112 wolli112 closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants