Share property information


I am trying to make a node to control some digital outputs. I am facing a problem, because my digital outputs have the possibility to use external voltage reference. I have made the node, but I cannot seem to find a way for implementing a feature for when I select the node to be external voltage or not, to update all the nodes with that option in my current flow.

Here is my "edit dialoag" html code

<div class="form-row">
    <label for="node-input-vexternal"><i class="fa fa-plug"></i></i><span data-i18n="digital-outputs.label.source"></span></label>
	<select type="text" id="node-input-vexternal">
        <option value="no" data-i18n=""></option>
        <option value="yes" data-i18n="digital-outputs.ext_v.yes"></option>

Here is my .js code the node.

if(this.v_external === "yes") {
    fs.writeFileSync(ENA_V_DO_path, '0');
    else if(this.v_external === "no") {
        fs.writeFileSync(ENA_V_DO_path, '1');

I was thinking something like adding the oneditprepare to poll the directories ENA_V_DO_path. But I dont know if its is possible to use nodejs filesystem api inside the oneditprepare object.

What you have will require you to edit each node / gpio pin. You could possibly create a config node that sits behind that that all your nodes could share but then they would all be set to the same value all the time. See the serial port or mqtt ports for examples of nodes that use config nodes.

The oneditprepare runs in the browser side so has no access to the filesystem - you could use an ajax/http call to call back to the runtime (again like the serialport checks for avaliable ports) - and maybe query an environment variable or some other long term value.

1 Like

Thanks for the reply. I will try to look further on the config node, even though it seems a bit overkill. Maybe I should just create a node besides the digital output node, that controls if the external voltage reference is on or not.