# How to create a hidden node property

**URL:** <https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934>\
**Category:** Developing Nodes\
**Tags:** node-red-mcu\
**Created:** [25 March 2023 15:18 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934 "2023-03-25T15:18:02Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 March 2023 15:18 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/1 "2023-03-25T15:18:02Z")

</div>

I am trying to create a hidden node property ("moddable\_manifest") in a contrib node, in order to provide a property in the nodes exported JSON, where the JSON should be something like

```auto
{
    "id": "39f01371482a60fb",
    "type": "pid",
    "z": "fd7d965ef27a87e2",
    "moddable_manifest": {
        "include": [
            "path/to/manifest.json"
        ]
    },
    ...
}

```

The purpose is explained [here](https://github.com/phoddie/node-red-mcu/discussions/106)

I have only a little experience with creating nodes and am obviously missing something. Possibly I am on the wrong track completely.  
In the node's html file, in the `defaults` section I have added

```auto
            moddable_manifest: {
              include: [
                "path/to/manifest.json"
              ]

```

and in the UI section there I have

```auto
<script type="text/x-red" data-template-name="PID">
    <div class="form-row">
        ...
    </div>
    ...
    ...
    <input type="hidden" id="node-input-moddable_manifest">
</script>

```

I can see the hidden field in the page html in the edit screen, but it does not appear in the exported JSON. Can someone tell me what I am missing please?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [25 March 2023 15:37 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/2 "2023-03-25T15:37:14Z")

</div>

Hi @Colin

I have no experience with **node-red-mcu**.  
But what happens when you do (putting it under `value`)

```auto
defaults: {
  ...
  moddable_manifest: {
    value: {
      include: [
        "path/to/manifest.json"
      ]
    }
  }
}

```

This will set the default value for the hidden field  
There is no such property of **include** on the property API in Node RED? - at least I don't think so 😅

BUT! when you export - it should end up with the JSON below

```auto
{
    "id": "39f01371482a60fb",
    "type": "sensor",
    "z": "fd7d965ef27a87e2",
    "moddable_manifest": {
        "include": [
            "path/to/manifest.json"
        ]
    }
}

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 March 2023 16:00 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/3 "2023-03-25T16:00:10Z")

</div>

Thanks, that was it. I should have looked more carefully at the other defaults entries.  
I didn't need the hidden field spec in the UI section, I didn't think I would need that but put it in when my initial attempt failed.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [25 March 2023 19:48 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/4 "2023-03-25T19:48:23Z")

</div>

Hi @Colin !

This "procedure" is only necessary, if you intend to add an additional manifest at runtime.  
If you just need e.g. a special driver for your node, you may simply put this into the `manifest.json` you have to create anyway for your custom (MCU) node implementation.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 March 2023 21:34 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/5 "2023-03-25T21:34:50Z")

</div>

This isn't for a custom node, it is for an existing contrib node. I was planning to follow @phoddie's suggestion in the linked discussion:

This property may also be a good way for a Node-RED contributed node to signal that it is compatible with Node-RED MCU Edition. The presence of `modadble_manifest` can be considered an indication that the author intends for it to be used with the MCU

I imagine one could, for example, put in there the fact that it is safe to preload it.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [27 March 2023 18:57 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/6 "2023-03-27T18:57:20Z")

</div>

> [@Colin](#):
>
> it is for an existing contrib node

You don't have to make this detour - if your intension was just to add a `manifest.json` for your contrib node. Take the manifest the plugin created as template, modify it to your demands & drop it in the directory next to your standard Node-RED files.

It will be found there by the plugin and injected / utilized as necessary.  
And if you defined the `preload` option, your contrib node will of course be preloaded ... 😉 !

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 March 2023 20:58 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/7 "2023-03-27T20:58:07Z")

</div>

That only works if using the plugin, rather than node-red-mcu without the plugin. Also, if I understand correctly, that would be a manual operation that would need to be performed every time the node was used.

Is not providing it once with the node itself more of a shortcut than a detour? Perhaps I don't understand something relevant.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [27 March 2023 21:22 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/8 "2023-03-27T21:22:29Z")

</div>

> [@Colin](#):
>
> That only works if using the plugin, rather than node-red-mcu without the plugin.

That's true. I wonder yet how relevant this is...

> [@Colin](#):
>
> Also, if I understand correctly, that would be a manual operation that would need to be performed every time the node was used.

Not sure what you mean. There's no manual op necessary ... if you're working with the plugin. If not - see above.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 March 2023 08:12 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/9 "2023-03-28T08:12:29Z")

</div>

> [@ralphwetzel](#):
>
> There's no manual op necessary ... if you're working with the plugin

Doesn't that conflict with

> [@ralphwetzel](#):
>
> Take the manifest the plugin created as template, modify it to your demands & drop it in the directory next to your standard Node-RED files.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [28 March 2023 08:53 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/10 "2023-03-28T08:53:06Z")

</div>

Not at all - yet my description was perhaps a bit short.

You don't need more than a `manifest.json` file in the same directory as the rest of your (standard Node-RED) files, e.g. next to your package.json @ [node-red-contrib-pid](https://github.com/colinl/node-red-contrib-pid).

If you intend to separate things, you could create a dedicated folder (labeled `mcu`) to place you node-red-mcu related files there.

In both cases, those files will be found and used as intended ... if you let the plugin do its job 😉 !

In fact, when you're currently using a contrib node, the plugin already checks for the existence of a `manifest.json` at one of those locations ... and if not found, creates the necessary file for you - but in the working directory.

For reference, you may have a look at any of the already existing implementations of nodes dedicated to node-red-mcu, like e.g. [node-red-mcu-gate](https://github.com/ralphwetzel/node-red-mcu-gate).

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 March 2023 09:15 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/11 "2023-03-28T09:15:13Z")

</div>

> [@ralphwetzel](#):
>
> You don't need more than a `manifest.json` file in the same directory as the rest of your (standard Node-RED) files, e.g. next to your package.json @ [node-red-contrib-pid](https://github.com/colinl/node-red-contrib-pid).

That is exactly what I was proposing to do.  
I believe that the purpose of the addition of the manifest property to the node is to allow this tobe read when the node is used other than with the plugin.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [28 March 2023 09:33 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/12 "2023-03-28T09:33:34Z")

</div>

> [@Colin](#):
>
> I believe that the purpose of the addition of the manifest property to the node is to allow this tobe read when the node is used other than with the plugin.

I'm aware of that.  
So you create a flow, export it to ... another editor, copy/paste additional stuff ... then open a terminal, issue a build process manually & follow a flow (!) by its javascript representation --- rather than pressing a single button & enjoying the integration of node-red-mcu into the Node-RED environment?

I won't do it that way, but that's up to anyones preferred way of acting... 😉

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 March 2023 09:48 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/13 "2023-03-28T09:48:34Z")

</div>

No, for my experiments I have installed node-red-mcu (as a git submodule) inside my .node-red folder, and all I have to do is to run `mcconfig` from that folder. The advantage is that I have everything under git control, including the node-red-mcu version. See [here](https://github.com/phoddie/node-red-mcu/issues/92#issuecomment-1440180070) for exactly how I have done that.

The reason I went down that route was because at that time my flows would not run using the plugin. I think all those problems have been fixed, but I can't easily run the plugin with the Beta version of node-red so I can't switch over yet. I have submitted a [PR](https://github.com/phoddie/node-red-mcu/issues/92#issuecomment-1440180070) to allow that but it has not been merged yet.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [28 March 2023 11:36 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/14 "2023-03-28T11:36:08Z")

</div>

> [@Colin](#):
>
> but I can't easily run the plugin with the Beta version of node-red so I can't switch over yet.

There will be an open beta for the next version of the plugin released "soon" ... in the coming days.  
This is going to support NR 3.1.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 April 2023 15:42 UTC](https://discourse.nodered.org/t/how-to-create-a-hidden-node-property/76934/16 "2023-04-11T15:42:03Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
