Handles to indiviudal nodes

Is there some way to access all nodes of type ui-switch from inside a function node. i.e. can one query all nodes and filter out the nodes of the type ui-switch?

@magnusso are you creating a new node that you will publish to the flows library (e.g. node-red-contrib-my-new-node) ?

If you are simply creating a flow with a function node, please move this to the #general category.

Also, please clarify what you are attempting to do? A function node cannot access other nodes!

What do you mean by "access"?
Do you just want a list?
You can extract the ids of nodes which are type ui_switch from the flows file.

Since each node's record in flows.json is multiple lines, a simple grep won't work.
I'd do it with an exec node and awk, but I suspect it's very easy to do with Jsonata. (If only you can get the expletive deleted thing to do anything at all)

So, due to astronomical electricity prices in Scandinavia, which currently vary within a magnitude of 10^4, depending on the day and the time of day, I’m trying to create the following. At the time of writing this the price is some 630 EUR/MWh, while a couple of days back it was 0,015 EUR/MWh in the morning.

All lights are controlled by Eltako Series 14 actuators on a RS485 bus, works as they should, no problems. There are lights on 3 floors, plus the garage, cellar, outdoor etc.

The Node Red Dashboard consists of a large number of ui-switches, which either sends a ON or OFF telegram, when pressed, depending on the state. The state of each switch is not determined by the output, but by the Enocean confirmation telegram, sent by each actuator, in repose to a telegram which is has received. This allow me to monitor the status of each actuator, even if the state of each actuator is change with physical Enocean switches mounted to the wall, which operate on the Enocean bus only. The physical switches follow the logic of the Dashboard, up is ON, Down is OFF. In addition node red as buttons such as Master ON, Master OFF. All of this works pretty well

Next, I’d like to turn off lights automatically. My plan is to maintain a set of objects, I call them leases and have them stored in a global javascript variable of type map. For a light to be switched on it must have a valid lease. When the lease expires or gets deleted, for whatever reason, the corresponding actuator must be switched off.

I would like to have a more tight integration between ui-switches and the leases. Hence I’m trying to figure out how to access the instances of ui-switch, or to understand how the ui-switches are set up.

To start, I would like to have a variable upper boundary for lease lifetime, here 15 minutes, after which the lease is automatically deleted. I'm thinking that perhaps the best way would be to incorporate this lease functionality into the individual instances of ui-button, or the either way around.

class Lease {
   constructor(payload) {


   turnOn() {
   turnOff() {
      return { 
         payload: {
            button: 0,
            channel: this.transmitterId,
            event: "click"

let leases = global.get("leases");
let l = new lease(msg.payload);
global.set("leases", leases)

Returning to your original question, you can identify all the nodes of type ui-switch by parsing the flows file, as @jbudd suggests, or you can use an http request node to access the admin API:

This will return an array of objects, each of which is a node or tab. You can easily find the ones with type property equal to ui-switch .

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