henry-spanka / node-red-contrib-hikvision

Hikvision API for Node Red
MIT License
10 stars 1 forks source link

catch "connection closed" from camera-node possible? & text-data outside root-node #19

Open ozett opened 4 years ago

ozett commented 4 years ago

hi, is it possible to filter/catch the "connection closed" message in a flow? i am asking, because i cannot see that the message is within msg.payload as an property (2).

how do i catch this within node-red?

image

maybe there is room for improvement to send as a msg.property?

image

henry-spanka commented 4 years ago

You can check the message directly: if (msg == "Connection closed!") { ... }

ozett commented 4 years ago

👍 will see if i can set up some sort of watchdog.. thx.

ozett commented 4 years ago

do you think that this will work within a node?

image

ozett commented 4 years ago

not really... image

can the "connection closed" get into a >>more<< node-red-stylish property for use in a switch-node?

ozett commented 4 years ago

i will try it with jsonata meanwhile...

image

henry-spanka commented 4 years ago

You need to set the output of the error node to "Complete message object" and not "msg.payload".

ozett commented 4 years ago

yeah, but most nodes want msg.payload, or i have to use change-node to move properties. but that will work at the moment also, of course. to have it in payload would make chaining some nodes a bit easyier. ..

henry-spanka commented 4 years ago

Try msg.error.

See: https://cookbook.nodered.org/basic/trigger-on-error#example

I don't think there is a way to set msg.payload. Which node requires msg.payload? Normally you can set the object namespace yourself.

ozett commented 4 years ago

i always make the mistake, that the inject-node injects only into msg.payload. a change-node has to follow to move it..

i try to avoid function-node and at firstplace use only the basic-nodes. but that way i have to use too much change-nodes to transfer properties from/in outside of .payload.

but a good hint with the catch-node, as i believe, one could filter on catching only certain node.. i will try this, too.