OPNSense API Alias toggle

This flow connects to your opnsense router to grab the alias list, and then save it to a global array.

It allows you to see status of each and toggle on/off each

I have mine connected to a discord bot, with a lowercase node to get rid of the capital letters my phone inserts, and a switch reading the msg.channel.id to route it to this flow.

It all goes back out to a discord channel you can set.

https://flows.nodered.org/node/node-red-contrib-lower

This assumes you have a opnsense router with aliases made up and the relevant firewall rules, and have discord and already have a bot.

You could setup a dashboard I'm sure to use this, easier to just chat IMO.

I used this page to try and figure out the API, the alias stuff isn't documented yet.

https://github.com/opnsense/core/blob/master/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php

The firewall basics are as follows

Alias:Thing 1, LAN firewall rule which blocks all traffic from this alias.

When the alias is enabled, its traffic is blocked, disabled allows traffic.

Alias:Special, Lan firewall rule which allows all traffic from this alias.

When the alias is enabled its traffic is allowed, disabled just skips this rule.

I have this special rule right above my scheduled block rule for all their devices, allows me to give them extra time online if I want to.

The IP could also be a switch to set it if you had more than one router. I would use it this way to block my kids internet at grandmas house with only this node-red instance, zerotier installed on opnsense allows me to get to grandmas router remotely.

[{"id":"b101138b.b75dc","type":"tab","label":"API","disabled":false,"info":""},{"id":"7f93e35f.a10afc","type":"http request","z":"b101138b.b75dc","name":"API","method":"use","ret":"obj","paytoqs":false,"url":"","tls":"","proxy":"","authType":"basic","x":1350,"y":380,"wires":[["88e855d8.8f4c38"]]},{"id":"68e094ed.7a7e1c","type":"http request","z":"b101138b.b75dc","name":"API","method":"use","ret":"obj","paytoqs":false,"url":"","tls":"","proxy":"","authType":"basic","x":1350,"y":300,"wires":[["ce54ac22.a8009"]]},{"id":"4d904ab6.78dcf4","type":"link in","z":"b101138b.b75dc","name":"from discord","links":[],"x":95,"y":220,"wires":[["f6385fe.e2782a"]]},{"id":"4f78a0d4.c15fa","type":"http request","z":"b101138b.b75dc","name":"API","method":"use","ret":"obj","paytoqs":false,"url":"","tls":"","proxy":"","authType":"basic","x":430,"y":180,"wires":[["dd9d98c9.1cc018"]]},{"id":"2eea401.09af5c","type":"switch","z":"b101138b.b75dc","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"refresh","vt":"str"},{"t":"cont","v":"on","vt":"str"},{"t":"cont","v":"off","vt":"str"},{"t":"cont","v":"status","vt":"str"},{"t":"cont","v":"reload","vt":"str"},{"t":"cont","v":"help","vt":"str"}],"checkall":"false","repair":false,"outputs":6,"x":130,"y":360,"wires":[["211a0130.cd679e"],["4a79eb16.d18fe4"],["1db73fb5.1dfea"],["456dd626.00e4e8"],[],["4f9a6ba5.6ff1b4"]]},{"id":"64b29252.e4adfc","type":"link out","z":"b101138b.b75dc","name":"out to discord","links":[],"x":1875,"y":500,"wires":[]},{"id":"f977713e.5d714","type":"change","z":"b101138b.b75dc","name":"Discord Channel","rules":[{"t":"set","p":"channel.id","pt":"msg","to":"put your number here","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1820,"y":460,"wires":[["64b29252.e4adfc"]]},{"id":"4f9a6ba5.6ff1b4","type":"template","z":"b101138b.b75dc","name":"help","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Aliases on/off\n\nThe schedule blocks like normal,\nThese block before the schedule can enable\n\nthing1\nthing2\nconsoles\nkids\nspecial\n","output":"str","x":610,"y":460,"wires":[["f977713e.5d714"]]},{"id":"211a0130.cd679e","type":"function","z":"b101138b.b75dc","name":"refresh_aliases","func":"// this grabs all the aliases and pushes them into a global array\nvar ip = msg.ip;\n\nvar msg1 = {\n        name: msg.topic,\n        what: msg.payload,\n        method: \"GET\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/searchItem\"};\n\nreturn msg1;","outputs":1,"noerr":0,"x":400,"y":140,"wires":[["4f78a0d4.c15fa"]]},{"id":"98faebed.5c7168","type":"inject","z":"b101138b.b75dc","name":"5am refresh","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 05 * * *","once":false,"onceDelay":"10","x":170,"y":180,"wires":[["211a0130.cd679e"]]},{"id":"dd9d98c9.1cc018","type":"splitter","z":"b101138b.b75dc","name":"","property":"payload.rows","x":430,"y":220,"wires":[["6f9fb97c.8bc448"]]},{"id":"78bc527c.3d4b5c","type":"function","z":"b101138b.b75dc","name":"block","func":"// for block rules with an alias\n// this is to disable an alias with on, enable with off\n\nvar name = msg.payload.name;\nvar uuid = msg.payload.uuid;\nvar time = new Date().toLocaleString();\n\nvar bool1 = context.set('bool',0);\nif (msg.payload.enabled ==\"1\"){\n    context.set('bool',1);\n}\nvar stat1 = context.set('stat',\"on\");\nif (msg.payload.enabled ==\"1\"){\n    context.set('stat',\"blocked\");\n}\n\nvar stat = context.get('stat');\n\nvar bool = context.get('bool');\n\nvar all = {\"name\":\"\"+name+\"\", \"uuid\":\"\"+uuid+\"\", \"stat\": \"\"+stat+\"\", \"bool\": \"\"+bool+\"\", \"time\": \"\"+time+\"\"};\n\nglobal.set(\"\"+name+\"\", all);\n\nmsg1 = {payload: \"\"+name+\"\", uuid:\"\"+uuid+\"\", status: \"\"+stat+\"\", bool: \"\"+bool+\"\", time: \"\"+time+\"\"};\nnode.send([ msg1 ]);\n\n\n","outputs":1,"noerr":0,"x":770,"y":140,"wires":[["aade3020.54721"]]},{"id":"aade3020.54721","type":"debug","z":"b101138b.b75dc","name":"aliases","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":140,"wires":[]},{"id":"6f9fb97c.8bc448","type":"switch","z":"b101138b.b75dc","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"thing1","vt":"str"},{"t":"eq","v":"thing2","vt":"str"},{"t":"eq","v":"consoles","vt":"str"},{"t":"eq","v":"kids","vt":"str"},{"t":"eq","v":"special","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":6,"x":610,"y":160,"wires":[["78bc527c.3d4b5c"],["78bc527c.3d4b5c"],["78bc527c.3d4b5c"],["78bc527c.3d4b5c"],["4c9bf114.6799a"],[]]},{"id":"4c9bf114.6799a","type":"function","z":"b101138b.b75dc","name":"allow","func":"// for allow rules with an alias\n// this is inverted to enable an alias with on, disable with off\n\n\nvar name = msg.payload.name;\nvar uuid = msg.payload.uuid;\nvar time = new Date().toLocaleString();\n\nvar bool1 = context.set('bool',0);\nif (msg.payload.enabled ==\"1\"){\n    context.set('bool',1);\n}\nvar stat1 = context.set('stat',\"disabled\");\nif (msg.payload.enabled ==\"1\"){\n    context.set('stat',\"enabled\");\n}\n\nvar stat = context.get('stat');\n\nvar bool = context.get('bool');\n\nvar all = {\"name\":\"\"+name+\"\", \"uuid\":\"\"+uuid+\"\", \"stat\": \"\"+stat+\"\", \"bool\": \"\"+bool+\"\", \"time\": \"\"+time+\"\"};\n\nglobal.set(\"\"+name+\"\", all);\n\nmsg1 = {payload: \"\"+name+\"\", uuid:\"\"+uuid+\"\", status: \"\"+stat+\"\", bool: \"\"+bool+\"\", time: \"\"+time+\"\"};\nnode.send([ msg1 ]);\n\n\n","outputs":1,"noerr":0,"x":770,"y":180,"wires":[["aade3020.54721"]]},{"id":"8266b143.436ac","type":"switch","z":"b101138b.b75dc","name":"sort","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"kenny","vt":"str"},{"t":"cont","v":"zachary","vt":"str"},{"t":"cont","v":"consoles","vt":"str"},{"t":"cont","v":"kids","vt":"str"},{"t":"cont","v":"special","vt":"str"},{"t":"cont","v":"all","vt":"str"}],"checkall":"false","repair":false,"outputs":6,"x":430,"y":340,"wires":[["8984008f.68cb"],["701d7cf8.8f7454"],["e7c46a3c.d310b8"],["46a435a3.b42d3c"],["8d82045a.3694b8"],["8d82045a.3694b8","46a435a3.b42d3c","e7c46a3c.d310b8","701d7cf8.8f7454","8984008f.68cb"]]},{"id":"8984008f.68cb","type":"change","z":"b101138b.b75dc","name":"thing1","rules":[{"t":"set","p":"topic","pt":"msg","to":"thing1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":260,"wires":[["aee3b7ec.c40048"]]},{"id":"701d7cf8.8f7454","type":"change","z":"b101138b.b75dc","name":"thing2","rules":[{"t":"set","p":"topic","pt":"msg","to":"thing2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":300,"wires":[["aee3b7ec.c40048"]]},{"id":"e7c46a3c.d310b8","type":"change","z":"b101138b.b75dc","name":"console","rules":[{"t":"set","p":"topic","pt":"msg","to":"console","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":340,"wires":[["aee3b7ec.c40048"]]},{"id":"46a435a3.b42d3c","type":"change","z":"b101138b.b75dc","name":"kids","rules":[{"t":"set","p":"topic","pt":"msg","to":"kids","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":380,"wires":[["aee3b7ec.c40048"]]},{"id":"8d82045a.3694b8","type":"change","z":"b101138b.b75dc","name":"special","rules":[{"t":"set","p":"topic","pt":"msg","to":"special","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":420,"wires":[["48b665d.0e5ca9c"]]},{"id":"8dd36d96.b211a","type":"comment","z":"b101138b.b75dc","name":"aliases","info":"my aliases are simple\n\nthing1/2 is that kids devices\n\nconsoles is consoles\n\nkids is both of their devices and consoles\n\nspecial is to bypass their time scheduled rule\nits allow rule is before the sheduled rule","x":350,"y":100,"wires":[]},{"id":"4a79eb16.d18fe4","type":"change","z":"b101138b.b75dc","name":"on","rules":[{"t":"set","p":"what","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":300,"wires":[["8266b143.436ac"]]},{"id":"1db73fb5.1dfea","type":"change","z":"b101138b.b75dc","name":"off","rules":[{"t":"set","p":"what","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":340,"wires":[["8266b143.436ac"]]},{"id":"456dd626.00e4e8","type":"change","z":"b101138b.b75dc","name":"status","rules":[{"t":"set","p":"what","pt":"msg","to":"status","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":380,"wires":[["8266b143.436ac"]]},{"id":"aee3b7ec.c40048","type":"delay","z":"b101138b.b75dc","name":"limit","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":770,"y":240,"wires":[["10825721.c10149"]]},{"id":"8461b0e0.5ae84","type":"template","z":"b101138b.b75dc","name":"status","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}'s internet is {{status}}\n","output":"str","x":1630,"y":240,"wires":[["50f6eea5.0d242","f977713e.5d714"]]},{"id":"48b665d.0e5ca9c","type":"delay","z":"b101138b.b75dc","name":"limit","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":770,"y":420,"wires":[["6d924759.9aaa28"]]},{"id":"10825721.c10149","type":"switch","z":"b101138b.b75dc","name":"sort","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"on","vt":"str"},{"t":"cont","v":"off","vt":"str"},{"t":"cont","v":"status","vt":"str"},{"t":"cont","v":"reload","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":770,"y":300,"wires":[["e5e5d49e.0c34a8"],["270cd1c6.31dcbe"],["bb9edb5f.742168"],[]]},{"id":"bb9edb5f.742168","type":"function","z":"b101138b.b75dc","name":"status","func":"var payload = msg.what;\nvar topic = msg.topic;\nvar array = global.get(\"\"+topic+\"\");\nvar uuid = array[\"uuid\"];\nvar stat = array[\"stat\"];\n\nnode.status({fill:\"red\", shape:\"ring\", text: topic});\n\nvar stats = {payload: \"\"+topic+\"\", status: \"\"+stat+\"\"};\n\n\n///// Status Check ////\n{\nif(payload === \"status\");\n\n    node.send([ stats ]);\n    \n}\n","outputs":1,"noerr":0,"x":970,"y":380,"wires":[["7f729c5d.b21b54"]]},{"id":"e5e5d49e.0c34a8","type":"function","z":"b101138b.b75dc","name":"on","func":"var ip = msg.ip;\nvar payload = msg.what;\nvar topic = msg.topic;\nvar array = global.get(\"\"+topic+\"\");\nvar uuid = array[\"uuid\"];\nvar bool = array[\"bool\"];\nvar stat = array[\"stat\"];\n\nnode.status({fill:\"red\", shape:\"ring\", text: topic});\n\nvar stats = {payload: \"\"+topic+\"\", status: \"\"+stat+\"\"};\n\nvar refresh = {what: \"\"+payload+\"\", topic: \"\"+topic+\"\", ip: \"\"+ip+\"\"};\n    \nvar toggle = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/toggleItem/\"+uuid+\"\",\n        payload:\"\"};\n     \nvar reload = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/reconfigure\",\n        };\n      \n\n\n///// ON Check ////\nif(array[\"bool\"] !== \"1\"){\n    node.send([ stats, null, null, null ]);\n}\nelse{\n    node.send([ null, toggle, reload, refresh ]);\n    \n}","outputs":4,"noerr":0,"x":970,"y":220,"wires":[["7f729c5d.b21b54"],["13eedcaf.7762c3"],["f324f4f9.adee68"],["3684332b.766d0c"]]},{"id":"2cc86ba.6c80694","type":"debug","z":"b101138b.b75dc","name":"toggle","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1630,"y":280,"wires":[]},{"id":"dddb3676.065448","type":"debug","z":"b101138b.b75dc","name":"reload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1630,"y":360,"wires":[]},{"id":"df02d400.4b1408","type":"debug","z":"b101138b.b75dc","name":"refresh","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1390,"y":420,"wires":[]},{"id":"50f6eea5.0d242","type":"debug","z":"b101138b.b75dc","name":"no change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1810,"y":240,"wires":[]},{"id":"f324f4f9.adee68","type":"delay","z":"b101138b.b75dc","name":"reload","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1210,"y":380,"wires":[["7f93e35f.a10afc"]]},{"id":"3684332b.766d0c","type":"delay","z":"b101138b.b75dc","name":"refresh","pauseType":"delay","timeout":"2500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1210,"y":420,"wires":[["df02d400.4b1408","c35407e8.89f068","33bff14.a8aa60e"]]},{"id":"270cd1c6.31dcbe","type":"function","z":"b101138b.b75dc","name":"off","func":"var ip = msg.ip;\nvar payload = msg.what;\nvar topic = msg.topic;\nvar array = global.get(\"\"+topic+\"\");\nvar uuid = array[\"uuid\"];\nvar bool = array[\"bool\"];\nvar stat = array[\"stat\"];\n\nnode.status({fill:\"red\", shape:\"ring\", text: topic});\n\nvar stats = {payload: \"\"+topic+\"\", status: \"\"+stat+\"\"};\n\nvar refresh = {what: \"\"+payload+\"\", topic: \"\"+topic+\"\", ip: \"\"+ip+\"\"};\n    \nvar toggle = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/toggleItem/\"+uuid+\"\",\n        payload:\"\"};\n     \nvar reload = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/reconfigure\",\n        };\n      \n\n\n///// OFF Check ////\nif(array[\"bool\"] !== \"0\"){\n    node.send([ stats, null, null, null ]);\n}\nelse{\n    node.send([ null, toggle, reload, refresh ]);\n    \n}","outputs":4,"noerr":0,"x":970,"y":300,"wires":[["7f729c5d.b21b54"],["13eedcaf.7762c3"],["f324f4f9.adee68"],["3684332b.766d0c"]]},{"id":"603734e4.1f864c","type":"function","z":"b101138b.b75dc","name":"invert on","func":"var ip = msg.ip;\nvar payload = msg.what;\nvar topic = msg.topic;\nvar array = global.get(\"\"+topic+\"\");\nvar uuid = array[\"uuid\"];\nvar bool = array[\"bool\"];\nvar stat = array[\"stat\"];\n\nnode.status({fill:\"red\", shape:\"ring\", text: topic});\n\nvar stats = {payload: \"\"+topic+\"\", status: \"\"+stat+\"\"};\n\nvar refresh = {what: \"\"+payload+\"\", topic: \"\"+topic+\"\", ip: \"\"+ip+\"\"};\n    \nvar toggle = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/toggleItem/\"+uuid+\"\",\n        payload:\"\"};\n     \nvar reload = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/reconfigure\",\n        };\n      \n\n\n///// ON Check ////\nif(array[\"bool\"] !== \"0\"){\n    node.send([ stats, null, null, null ]);\n}\nelse{\n    node.send([ null, toggle, reload, refresh ]);\n    \n}","outputs":4,"noerr":0,"x":980,"y":440,"wires":[["7f729c5d.b21b54"],["13eedcaf.7762c3","4bc99f77.f420b"],["f324f4f9.adee68"],["3684332b.766d0c"]]},{"id":"249c62c8.2aac5e","type":"function","z":"b101138b.b75dc","name":"invert off","func":"var ip = msg.ip;\nvar payload = msg.what;\nvar topic = msg.topic;\nvar array = global.get(\"\"+topic+\"\");\nvar uuid = array[\"uuid\"];\nvar bool = array[\"bool\"];\nvar stat = array[\"stat\"];\n\nnode.status({fill:\"red\", shape:\"ring\", text: topic});\n\nvar stats = {payload: \"\"+topic+\"\", status: \"\"+stat+\"\"};\n\nvar refresh = {what: \"\"+payload+\"\", topic: \"\"+topic+\"\", ip: \"\"+ip+\"\"};\n    \nvar toggle = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/toggleItem/\"+uuid+\"\",\n        payload:\"\"};\n     \nvar reload = {\n\n        method: \"POST\",\n        header: \"Content-Type: application/json\",\n        url: \"http://\"+ip+\"/api/firewall/alias/reconfigure\",\n        };\n      \n\n\n///// OFF Check ////\nif(array[\"bool\"] !== \"1\"){\n    node.send([ stats, null, null, null ]);\n}\nelse{\n    node.send([ null, toggle, reload, refresh ]);\n    \n}","outputs":4,"noerr":0,"x":980,"y":520,"wires":[["7f729c5d.b21b54"],["13eedcaf.7762c3"],["f324f4f9.adee68"],["3684332b.766d0c"]]},{"id":"13eedcaf.7762c3","type":"delay","z":"b101138b.b75dc","name":"toggle","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1210,"y":300,"wires":[["68e094ed.7a7e1c"]]},{"id":"c35407e8.89f068","type":"link out","z":"b101138b.b75dc","name":"","links":["27c873ef.bdb90c"],"x":1315,"y":420,"wires":[]},{"id":"27c873ef.bdb90c","type":"link in","z":"b101138b.b75dc","name":"refresh alias","links":["c35407e8.89f068"],"x":255,"y":140,"wires":[["211a0130.cd679e"]]},{"id":"ad263a93.c75368","type":"template","z":"b101138b.b75dc","name":"toggle","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Toggle didn't work\n","output":"str","x":1630,"y":320,"wires":[["fd6e0cf7.e4051","f977713e.5d714"]]},{"id":"33bff14.a8aa60e","type":"delay","z":"b101138b.b75dc","name":"status","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1210,"y":460,"wires":[["5787bcd0.67adc4"]]},{"id":"3363c13b.c9439e","type":"link in","z":"b101138b.b75dc","name":"","links":["5787bcd0.67adc4"],"x":855,"y":380,"wires":[["bb9edb5f.742168"]]},{"id":"5787bcd0.67adc4","type":"link out","z":"b101138b.b75dc","name":"","links":["3363c13b.c9439e"],"x":1295,"y":480,"wires":[]},{"id":"88e855d8.8f4c38","type":"switch","z":"b101138b.b75dc","name":"error","property":"payload.status","propertyType":"msg","rules":[{"t":"cont","v":"ok","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":1490,"y":380,"wires":[["dddb3676.065448"],["48ca5a1d.a436b4"]]},{"id":"ce54ac22.a8009","type":"switch","z":"b101138b.b75dc","name":"error","property":"payload.changed","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":1490,"y":300,"wires":[["2cc86ba.6c80694"],["ad263a93.c75368"]]},{"id":"48ca5a1d.a436b4","type":"template","z":"b101138b.b75dc","name":"reload","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Reload failed\n","output":"str","x":1630,"y":400,"wires":[["3c783514.7bf9ea"]]},{"id":"fd6e0cf7.e4051","type":"debug","z":"b101138b.b75dc","name":"toggle err","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1800,"y":320,"wires":[]},{"id":"3c783514.7bf9ea","type":"debug","z":"b101138b.b75dc","name":"reload err","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1800,"y":400,"wires":[]},{"id":"6d924759.9aaa28","type":"switch","z":"b101138b.b75dc","name":"sort","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"on","vt":"str"},{"t":"cont","v":"off","vt":"str"},{"t":"cont","v":"status","vt":"str"},{"t":"cont","v":"reload","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":770,"y":480,"wires":[["603734e4.1f864c"],["249c62c8.2aac5e"],["bb9edb5f.742168"],[]]},{"id":"7f729c5d.b21b54","type":"delay","z":"b101138b.b75dc","name":"no change","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1230,"y":220,"wires":[["8461b0e0.5ae84"]]},{"id":"f32443c3.95ff1","type":"comment","z":"b101138b.b75dc","name":"special","info":"special is an allow rule instead of block","x":490,"y":420,"wires":[]},{"id":"fbb964ef.e44158","type":"comment","z":"b101138b.b75dc","name":"API","info":"enable use authentication, basic\n\nsetting an API up gives you a file with the proper info\n\nusername is\nkey=\n\npassword is\nsecret=","x":450,"y":100,"wires":[]},{"id":"a227406.748c3c","type":"comment","z":"b101138b.b75dc","name":"API","info":"enable use authentication, basic\n\nsetting an API up gives you a file with the proper info\n\nusername is\nkey=\n\npassword is\nsecret=","x":1350,"y":340,"wires":[]},{"id":"f6385fe.e2782a","type":"change","z":"b101138b.b75dc","name":"IP","rules":[{"t":"set","p":"ip","pt":"msg","to":"PUT YOUR IP HERE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":280,"wires":[["2eea401.09af5c"]]},{"id":"c2132f8e.e3a67","type":"inject","z":"b101138b.b75dc","name":"restart","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"2","x":170,"y":100,"wires":[["211a0130.cd679e"]]},{"id":"b828a6ea.f8ab78","type":"comment","z":"b101138b.b75dc","name":"toggles","info":"restart just populates the list after node-red restarts\n\n\n\n5AM refreshes the list daily","x":150,"y":140,"wires":[]},{"id":"a5d903c0.1f96d","type":"comment","z":"b101138b.b75dc","name":"reload","info":"this reloads the rules after they are toggled","x":1210,"y":340,"wires":[]},{"id":"8222f740.249678","type":"comment","z":"b101138b.b75dc","name":"toggle","info":"this toggles the alias enable/disable bit","x":1210,"y":260,"wires":[]},{"id":"f02d05af.bd98d8","type":"comment","z":"b101138b.b75dc","name":"on/off","info":"I tried to make one big function, but it didn't work\n","x":970,"y":280,"wires":[]},{"id":"1b406e07.dbe6c2","type":"change","z":"b101138b.b75dc","name":"auto off","rules":[{"t":"set","p":"what","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":560,"wires":[["249c62c8.2aac5e"]]},{"id":"4bc99f77.f420b","type":"delay","z":"b101138b.b75dc","name":"30m","pauseType":"delay","timeout":"30","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1210,"y":520,"wires":[["1b406e07.dbe6c2"]]}]

Flow Info

Created 3 years, 7 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x11)
  • comment (x8)
  • debug (x7)
  • delay (x8)
  • function (x8)
  • http request (x3)
  • inject (x2)
  • link in (x3)
  • link out (x3)
  • switch (x7)
  • template (x4)
Other
  • splitter (x1)
  • tab (x1)

Tags

  • opnsense
  • alias
  • firewall
  • api
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option