๐ŸŒ UIBUILDER FAQ: Control your UI from Node-RED

Just a reminder that you can use Node-RED flows to control a UIBUILDER-driven web UI without the need for any coding.

Any uibuilder-managed web page understands a number of command messages. Full details on the Control from Node-RED page of the documentation.

Possible msg._uib.command values at the time of writing this (prior to v8.0.0 being released) are:

  • elementExists - does an element exist in the HTML DOM?
  • get - gets a uibuilder client managed variable.
  • getManagedVarList - gets the list of uibuilder client managed variables.
  • getWatchedVars - gets the list of uibuilder client managed variables that are currently being watched for changes.
  • htmlSend - gets the current full HTML as text.
  • include - Dynamically Add (Include) external content to the page.
  • navigate - Triggers a page change or a route change.
  • scrollTo - Scroll visible page to an element based on a CSS Selector.
  • set - set a uibuilder client managed variable.
  • showMsg - Turn on/off the display of the latest msg from Node-RED.
  • showOverlay - Displays an overlay window with customizable content and behavior.
  • showStatus - Turn on/off the display of the uibuilder client library settings.
  • uiGet - get detailed information about an HTML DOM element.
  • uiWatch - watch for changes to the HTML DOM, return messages about changes.
  • watchUrlHash - watch for URL Hash changes. Used for front-end routing.

As you can see, some commands get information from the page, others make changes to the page.

Couple the set command with uibuilder's custom HTML features like <div uib-var="myvar"> or <uib-var variable="myvar"></uib-var> to have your UI updated by Node-RED (or from front-end code).

Of course, using <div uib-topic="mytopic"></div> is even easier since you only need to send a standard message to the uibuilder node. The msg.payload replaces the inner HTML (AKA "slot") of the defined element.

From v8.0.0, handling of the custom HTML features will be improved and will fully support setting/changing of any HTML attribute (e.g. class, style, href, etc, Also checked or value for input elements). Also adding custom data to an element via the dataset property.

1 Like