Skip to content

Node-RED Flow Examples

How to activate and deactivate a relay?

Copy this flow and take it to Node-Red.

[
   {
      "disabled" : false,
      "id" : "645afa1a.2f5174",
      "info" : "",
      "label" : "eMOD API general calls demo",
      "type" : "tab"
   },
   {
      "active" : true,
      "complete" : "false",
      "console" : false,
      "id" : "eb8b1d6.b4f0ce",
      "name" : "",
      "tosidebar" : true,
      "tostatus" : false,
      "type" : "debug",
      "wires" : [],
      "x" : 1296,
      "y" : 306,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "9f13be8c.823e6",
      "name" : "Activate a relay",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"set_one\": {\"index\": 0, \"value\": true}}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 606,
      "y" : 66,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "3479e74c.70c7d8",
      "name" : "Deactivate all relays",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"set_all\": false}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 586,
      "y" : 526,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "ea79a682.3cdc48",
      "name" : "Get all relays status",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"get_all\": \"status\"}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 436,
      "y" : 326,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "ce9a35ef.f33158",
      "name" : "Activate some relays",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"set\":[true, true, true, null, null, true, null, null]}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 596,
      "y" : 126,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "19fed071.5ee9b",
      "name" : "Activate all relays",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"set_all\": true}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 606,
      "y" : 186,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "7202cf4b.5a7ff",
      "name" : "Deactivate some relays",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"set\":[null, null, false, null, null, false, null, null]}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 576,
      "y" : 466,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "c43e4e6e.3b661",
      "name" : "Deactivate a relay",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"set_one\": {\"index\": 0, \"value\": false}}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 596,
      "y" : 406,
      "z" : "645afa1a.2f5174"
   },
   {
      "crontab" : "",
      "id" : "c4cc007.3049f",
      "name" : "Get a relays status",
      "once" : false,
      "onceDelay" : 0.1,
      "payload" : "{\"get_one\":0}",
      "payloadType" : "json",
      "repeat" : "",
      "topic" : "",
      "type" : "inject",
      "wires" : [
         [
            "d7bbcac8.655c68"
         ]
      ],
      "x" : 436,
      "y" : 266,
      "z" : "645afa1a.2f5174"
   },
   {
      "id" : "d7bbcac8.655c68",
      "modConfig" : "65d777a.058a188",
      "modNum" : "",
      "modNumEnabled" : false,
      "name" : "",
      "type" : "8SR",
      "wires" : [
         [
            "eb8b1d6.b4f0ce"
         ]
      ],
      "x" : 996,
      "y" : 306,
      "z" : "645afa1a.2f5174"
   },
   {
      "id" : "65d777a.058a188",
      "name" : "",
      "pulseWidthMsR1" : "0",
      "pulseWidthMsR2" : "",
      "pulseWidthMsR3" : "",
      "pulseWidthMsR4" : "",
      "pulseWidthMsR5" : "",
      "pulseWidthMsR6" : "",
      "pulseWidthMsR7" : "",
      "pulseWidthMsR8" : "",
      "type" : "8SR-Config",
      "z" : ""
   }
]