Custom node - how to specify json data

#1

Hi folks,

My first question on this new forum ...

I'm currently developing a new contribution to control IP devices using the OnVif protocol. For example you should be able to add new users to the IP device, which I could implement using following code snippet:

var params = {
  'User' : [
    {'Username': 'user1', 'Password' : 'pwd1', 'UserLevel': 'Administrator'},
    {'Username': 'user2', 'Password' : 'pwd2', 'UserLevel': 'Operator'},
    {'Username': 'user3', 'Password' : 'pwd3', 'UserLevel': 'User'}
  ]
};

someIpDevice.createUsers(params);

Since I have a lot of available actions, the 'create users' can be selected on the config screen:

image

But what is the best way to offer those 'params' to my node?

  1. Should I provide a table on the node's config screen with an 'add user' button (which becomes only visible when 'add users' is selected in the dropdown). But that seems a bit weird, since you need to redeploy the flow to set those new users? Or am I completely mistaken about this?
  2. Should the payload of the input message contain the entire JSON.
  3. Both 1 and 2 ?
  4. Others ?

Thanks a lot !!!
Bart

0 Likes

#2

It has been a while since I looked at this so sorry, I’m rather rusty.

However, if you look at some of the built-in nodes, they are also building a nested dataset like yours. So the best thing to do is to find a node that requires similar settings and then copy that. I can’t think of a specific example off the top of my head, hopefully someone with a better memory will chip in. But if I think of one, I will update.

0 Likes

#3

Hi Julian,

Appreciate your help !!

Have been doing some homework by examing other nodes...
I could show a list of users on the node's config screen:

image

As soon as an input message triggers this node, those specified users will be created on the OnVif-compatible IP device. And when list of users on the config screen is empty, the input message should contain a user list in JSON format.

P.S. When I need to pass a JSON with more levels (to the IP camera), I'm scr*wed with this table design ...

Thanks !!
Bart

0 Likes

#4

I remember seeing some nodes with nested config, I just can’t remember where I’m afraid.

0 Likes

#5

Good old MQTT :wink: with TLS enabled - gives you a 2nd config for the TLS part.

0 Likes

#6

Hi Julian, Dave,

New forum, old acquaintances :wink:

The MQTT broker config node indeed seems to have a nested config node. For anybody reading this, this is the field Dave is talking about:

image

Thanks !
Bart

0 Likes

#7

Hi guys,

My Onvif implementation for Node-Red is growing, but still a lot of work. For each OnVif function, the user can select an action from a combobox, and then corresponding input fields become visible (i.e. the input for that function).

Now I need to add the setVideoEncoder action, which needs a lot of input:

  1. This is the OnVif function, with options as parameter
  2. The user can select a corresponding action from the combobox
  3. The input fields become visible for all the (required or optional) options. For the options of depth 1 (i.e. option.xxx) this is no problem: I just show them below the combobox.
  4. However some options have more than 1 level depth (options.mpeg4.profile). How could I visualize this? Can I have some indentation ?

Can't remember that I have seen other nodes with such a config screen ...

Thanks !!!!
Bart

0 Likes

#8

Wow ! Thanks ! I have to see how it works, I thought I read somewhere it was not possible to have a config-node within another config-node …

0 Likes

#9

Hi Bart,
I’m using a camera just with the RTSP stream starting with the tutorial/flow done by Csongor at https://www.youtube.com/watch?v=ihZWrJmbGFY&t=228s however I just ordered a cheap NVR/onvif compatble camera and will play a bit.

Will be great if you share your job a bit when you have something so it will help other ppl like me, will be much appreciated.

Regards

0 Likes

#10

Hi David,

I will release the OnVif node suite as soon as it is ready. The code is at node-red-contrib-onvif, but it is far from finished (missing functionality, lot of bugs, …). It will change a lot soon, so don’t use it yet !!! Give me a couple of weeks …

Bart

0 Likes

#11

Thanks a lot mate, take it easy is not urgent at all but a nice flow will guide a lot other people like me.

Regards

0 Likes

#12

Hey boss, remember to let me know when it’s released so I can play a bit with it if you don’t mind.

Thanks in advance

0 Likes