-
Example node
11/20/2021 at 00:34 • 0 commentsAn example for a node red implementation:
in Home assistant I've added a dropdown under "helpers":
with that in place, I can select between "manual" which simply does only what is selected on the air purifier or on HA (on/off, fan speed), "automatic" which uses air quality measurement as a criteria for on/off and fan speed or "time" which turns the AP on and off at a specific time at a specific fan speed.
here is the node:
[ { "id": "0bdc4f11ed52dc5d", "type": "tab", "label": "Air Purifier 3", "disabled": false, "info": "", "env": [] }, { "id": "5e0fa840110275e8", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "on/off", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_on_off", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 970, "y": 820, "wires": [ [ "ba87b75e6fefc6fe" ] ] }, { "id": "d08272d7bfb1789e", "type": "inject", "z": "0bdc4f11ed52dc5d", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "10", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 190, "y": 120, "wires": [ [ "7ce007c55044a93b" ] ] }, { "id": "32d95505345eeb3c", "type": "switch", "z": "0bdc4f11ed52dc5d", "name": "switch on: \\n <10, <=20, <=50, >=100", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lt", "v": "10", "vt": "num" }, { "t": "lte", "v": "20", "vt": "num" }, { "t": "lte", "v": "50", "vt": "num" }, { "t": "gte", "v": "100", "vt": "num" } ], "checkall": "false", "repair": false, "outputs": 4, "x": 170, "y": 960, "wires": [ [ "69d3c175ae98a9a6" ], [ "228bd948a665d7bc" ], [ "d630f8370ece3b7e" ], [ "805c6911af7286e6" ] ] }, { "id": "8758ba24542abccb", "type": "api-current-state", "z": "0bdc4f11ed52dc5d", "name": "get measurement \\n 10pm sensor", "server": "1bb0d825.3e7398", "version": 2, "outputs": 2, "halt_if": "0", "halt_if_type": "num", "halt_if_compare": "gte", "entity_id": "sensor.particulate_matter_10_0um_concentration", "state_type": "num", "blockInputOverrides": false, "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "entityState" }, { "property": "data", "propertyType": "msg", "value": "", "valueType": "entity" } ], "x": 210, "y": 580, "wires": [ [ "32d95505345eeb3c" ], [] ] }, { "id": "69d3c175ae98a9a6", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "change to 1", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "1", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 900, "wires": [ [ "6d0cd96036706e97" ] ] }, { "id": "228bd948a665d7bc", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "change to 2", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "2", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 940, "wires": [ [ "6d0cd96036706e97" ] ] }, { "id": "d630f8370ece3b7e", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "change to 3", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "3", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 980, "wires": [ [ "6d0cd96036706e97" ] ] }, { "id": "6d0cd96036706e97", "type": "rbe", "z": "0bdc4f11ed52dc5d", "name": "", "func": "rbe", "gap": "", "start": "", "inout": "out", "septopics": true, "property": "payload", "x": 570, "y": 960, "wires": [ [ "6f75c4d6d13132f8" ] ] }, { "id": "6f75c4d6d13132f8", "type": "switch", "z": "0bdc4f11ed52dc5d", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "1", "vt": "num" }, { "t": "eq", "v": "2", "vt": "num" }, { "t": "eq", "v": "3", "vt": "num" }, { "t": "eq", "v": "4", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 4, "x": 670, "y": 840, "wires": [ [ "93457cb56bc2ea42" ], [ "51960ae7dc52dc95" ], [ "2c3c05e44a952fd5" ], [ "29d971730bab8ff5" ] ] }, { "id": "7e23ab4e672858d1", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "on/off", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_on_off", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 970, "y": 760, "wires": [ [ "43a9eb74610ec9d1" ] ] }, { "id": "93457cb56bc2ea42", "type": "api-current-state", "z": "0bdc4f11ed52dc5d", "name": "if off", "server": "1bb0d825.3e7398", "version": 2, "outputs": 2, "halt_if": "off", "halt_if_type": "str", "halt_if_compare": "is", "entity_id": "binary_sensor.airpurifier3", "state_type": "str", "blockInputOverrides": false, "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "entityState" }, { "property": "data", "propertyType": "msg", "value": "", "valueType": "entity" } ], "x": 830, "y": 760, "wires": [ [], [ "7e23ab4e672858d1" ] ] }, { "id": "dfeaa6d4edd5423e", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "on/off", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_on_off", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 970, "y": 900, "wires": [ [ "2946f6aada43ac55" ] ] }, { "id": "cc9c66af89230026", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "fan", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_fan", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 1310, "y": 900, "wires": [ [ "ee962ecd5962b9b5" ] ] }, { "id": "7ce007c55044a93b", "type": "api-current-state", "z": "0bdc4f11ed52dc5d", "name": "operation mode", "server": "1bb0d825.3e7398", "version": 2, "outputs": 2, "halt_if": "manual", "halt_if_type": "str", "halt_if_compare": "is_not", "entity_id": "input_select.master_bedroom_air_purifier", "state_type": "str", "blockInputOverrides": false, "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "entityState" }, { "property": "data", "propertyType": "msg", "value": "", "valueType": "entity" } ], "x": 200, "y": 300, "wires": [ [ "d4cd761f8f6de816" ], [] ] }, { "id": "805c6911af7286e6", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "change to 4", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "4", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 1020, "wires": [ [ "6d0cd96036706e97" ] ] }, { "id": "7e3cfd2c33c74f5c", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "on/off", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_on_off", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 970, "y": 1120, "wires": [ [ "327d0dc8de88dfd4" ] ] }, { "id": "faa5957d77558406", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "fan", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_fan", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 1270, "y": 1120, "wires": [ [ "509d7e93e7c0b6a4" ] ] }, { "id": "ffd89851cdcfb19e", "type": "api-call-service", "z": "0bdc4f11ed52dc5d", "name": "fan", "server": "1bb0d825.3e7398", "version": 3, "debugenabled": false, "service_domain": "switch", "service": "toggle", "entityId": "switch.air_3_fan", "data": "", "dataType": "jsonata", "mergecontext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", "x": 1550, "y": 1120, "wires": [ [ "f88e5d8d8eeed8d7" ] ] }, { "id": "509d7e93e7c0b6a4", "type": "delay", "z": "0bdc4f11ed52dc5d", "name": "", "pauseType": "delay", "timeout": "1", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "outputs": 1, "x": 1400, "y": 1120, "wires": [ [ "ffd89851cdcfb19e" ] ] }, { "id": "2946f6aada43ac55", "type": "delay", "z": "0bdc4f11ed52dc5d", "name": "", "pauseType": "delay", "timeout": "1", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "outputs": 1, "x": 1140, "y": 900, "wires": [ [ "cc9c66af89230026" ] ] }, { "id": "327d0dc8de88dfd4", "type": "delay", "z": "0bdc4f11ed52dc5d", "name": "", "pauseType": "delay", "timeout": "1", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "outputs": 1, "x": 1120, "y": 1120, "wires": [ [ "faa5957d77558406" ] ] }, { "id": "43a9eb74610ec9d1", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "set fan speed 0", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "0", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1160, "y": 720, "wires": [ [ "325bf80ad4b65dda", "2e255df180ef5c58" ] ] }, { "id": "ba87b75e6fefc6fe", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "set fan speed 1", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "1", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1160, "y": 820, "wires": [ [ "325bf80ad4b65dda", "2e255df180ef5c58" ] ] }, { "id": "ee962ecd5962b9b5", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "set fan speed 2", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "2", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1500, "y": 900, "wires": [ [ "325bf80ad4b65dda", "2e255df180ef5c58" ] ] }, { "id": "f88e5d8d8eeed8d7", "type": "change", "z": "0bdc4f11ed52dc5d", "name": "set fan speed", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "3", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1740, "y": 1120, "wires": [ [ "325bf80ad4b65dda", "2e255df180ef5c58" ] ] }, { "id": "40680816722e3848", "type": "api-current-state", "z": "0bdc4f11ed52dc5d", "name": "fan <2", "server": "1bb0d825.3e7398", "version": 2, "outputs": 2, "halt_if": "2", "halt_if_type": "num", "halt_if_compare": "lt", "entity_id": "LR/Airpuri3/Fanspeed", "state_type": "str", "blockInputOverrides": false, "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "entityState" }, { "property": "data", "propertyType": "msg", "value": "", "valueType": "entity" } ], "x": 970, "y": 1000, "wires": [ [ "2946f6aada43ac55" ], [ "53c8d37d0f904999" ] ] }, { "id": "53c8d37d0f904999", "type": "switch", "z": "0bdc4f11ed52dc5d", "name": ">2", "property": "payload", "propertyType": "msg", "rules": [ { "t": "gt", "v": "2", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 1140, "y": 1040, "wires": [ [ "b1f30937037c77cd" ] ] }, { "id": "b1f30937037c77cd", "type": "delay", "z": "0bdc4f11ed52dc5d", "name": "", "pauseType": "delay", "timeout": "1", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "outputs": 1, "x": 1320, "y": 1040, "wires": [ [