diff --git a/flows.json b/flows.json index 8233185..3fe6f4d 100644 --- a/flows.json +++ b/flows.json @@ -1583,7 +1583,9 @@ "6b5d3e550ad76528" ], "x": 34, - "y": 39 + "y": 39, + "w": 692, + "h": 82 }, { "id": "4329e464360d0afa", @@ -1622,10 +1624,13 @@ "33fcb96a4c2c2541", "a4d27381bd614fd1", "8a84615173fd7e97", - "f260e2410571356a" + "f260e2410571356a", + "b497fe229c8f2eea" ], "x": 34, - "y": 139 + "y": 139, + "w": 1592, + "h": 422 }, { "id": "395da9d5d5f7e232", @@ -24431,7 +24436,7 @@ "b2c0d6629b2603b7" ], [ - "1180e4c40c3ec0fa" + "b497fe229c8f2eea" ] ] }, @@ -24623,7 +24628,7 @@ "areaId": [], "deviceId": [], "entityId": [], - "data": "{\t \"who\":\"common\",\t \"type\":\"weather\",\t \"call_interruption\": 1,\t \"call_lightning_alert\": 1\t}", + "data": "{\t \"who\": who,\t \"type\":\"weather\",\t \"call_interruption\": 1,\t \"call_lightning_alert\": 1\t}", "dataType": "jsonata", "mergeContext": "", "mustacheAltTags": false, @@ -24683,7 +24688,7 @@ "mustacheAltTags": false, "outputProperties": [], "queue": "none", - "x": 370, + "x": 550, "y": 440, "wires": [ [ @@ -24752,13 +24757,13 @@ "areaId": [], "deviceId": [], "entityId": [], - "data": "{\t \"who\":\"common\",\t \"type\":\"weather\",\t \"call_interruption\": 1,\t \"call_lightning_clear\": 1\t}", + "data": "{\t \"who\": who,\t \"type\":\"weather\",\t \"call_interruption\": 1,\t \"call_lightning_clear\": 1\t}", "dataType": "jsonata", "mergeContext": "", "mustacheAltTags": false, "outputProperties": [], "queue": "none", - "x": 580, + "x": 740, "y": 440, "wires": [ [ @@ -24786,7 +24791,7 @@ "mustacheAltTags": false, "outputProperties": [], "queue": "none", - "x": 750, + "x": 910, "y": 440, "wires": [ [] @@ -24809,7 +24814,7 @@ "z": "ebd5561c4f077718", "g": "4329e464360d0afa", "name": "Processing", - "func": "var states = global.get('homeassistant.homeAssistant.states')\nvar allowed = states[\"binary_sensor.audible_weather_alerts_allowed\"].state\nvar occupied = states[\"binary_sensor.basement_occupied\"].state\nvar quiet = states[\"input_boolean.studio_quiet\"].state\nvar deskState = states[\"light.tina_desk_lights\"].state\nvar livingRoomState = states[\"light.living_room_lights\"].state\nvar diningRoomState = states[\"light.dining_room_lamp\"].state\nvar basementState = states[\"light.basement_studio_lights\"].state\nvar duration = duration\nvar payload = payload\n\nvar firstFloorLights = []\nvar basementLights = []\n\nif (deskState === 'on') {\n firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')\n}\n\nif (livingRoomState === 'on') {\n firstFloorLights.push('light.living_room_color_1','light.living_room_color_2','light.living_room_color_3','light.living_room_led_strip')\n}\n\nif (diningRoomState === 'on') {\n firstFloorLights.push('light.dining_room_lamp')\n}\n\nif (basementState === 'on') {\n basementLights.push('light.basement_tall_lamp','light.basement_short_lamp','light.basement_stairwell','light.basement_led_strip_1')\n}\n\nflow.set(\"deskState\", deskState)\nflow.set(\"livingRoomState\", livingRoomState)\nflow.set(\"diningRoomState\", diningRoomState)\nflow.set(\"basementState\", basementState)\n\nvar firstFloorMsg = {\n \"payload\": payload,\n \"duration\": duration,\n \"backup\": firstFloorLights\n}\n\nvar basementMsg = {\n \"payload\": payload,\n \"duration\": duration,\n \"backup\": basementLights\n}\n\nif (allowed === 'on') {\n if (occupied === 'on' && quiet === 'off') {\n flow.set(\"basementTrigger\",\"true\")\n node.status({fill:\"green\",shape:\"dot\",text:\"Both\"})\n return[firstFloorMsg,basementMsg]\n } else {\n flow.set(\"basementTrigger\",\"false\")\n node.status({fill:\"green\",shape:\"dot\",text:\"Living Room\"})\n return[firstFloorMsg,null]\n }\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Blocked\"})\n return null\n}", + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst allowed = states[\"binary_sensor.audible_weather_alerts_allowed\"].state\nconst occupied = states[\"binary_sensor.basement_occupied\"].state\nconst quiet = states[\"input_boolean.studio_quiet\"].state\nconst deskState = states[\"light.tina_desk_lights\"].state\nconst livingRoomState = states[\"light.living_room_lights\"].state\nconst diningRoomState = states[\"light.dining_room_lamp\"].state\nconst basementState = states[\"light.basement_studio_lights\"].state\nconst who = states[\"binary_sensor.audible_weather_alerts_allowed\"].attributes.location\nconst duration = msg.duration\nconst payload = msg.payload\n\nlet firstFloorLights = []\nlet basementLights = []\n\nif (deskState === 'on') {\n firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')\n}\n\nif (livingRoomState === 'on') {\n firstFloorLights.push('light.living_room_color_1','light.living_room_color_2','light.living_room_color_3','light.living_room_led_strip')\n}\n\nif (diningRoomState === 'on') {\n firstFloorLights.push('light.dining_room_lamp')\n}\n\nif (basementState === 'on') {\n basementLights.push('light.basement_tall_lamp','light.basement_short_lamp','light.basement_stairwell','light.basement_led_strip_1')\n}\n\nflow.set(\"deskState\", deskState)\nflow.set(\"livingRoomState\", livingRoomState)\nflow.set(\"diningRoomState\", diningRoomState)\nflow.set(\"basementState\", basementState)\n\nlet firstFloorMsg = {\n \"payload\": payload,\n \"duration\": duration,\n \"backup\": firstFloorLights,\n \"who\": who\n}\n\nlet basementMsg = {\n \"payload\": payload,\n \"duration\": duration,\n \"backup\": basementLights\n}\n\nif (allowed === 'on') {\n if (occupied === 'on' && quiet === 'off') {\n flow.set(\"basementTrigger\",\"true\")\n node.status({fill:\"green\",shape:\"dot\",text:\"Both\"})\n return[firstFloorMsg,basementMsg]\n } else {\n flow.set(\"basementTrigger\",\"false\")\n node.status({fill:\"green\",shape:\"dot\",text:\"Living Room\"})\n return[firstFloorMsg,null]\n }\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Blocked\"})\n return null\n}", "outputs": 2, "noerr": 0, "initialize": "", @@ -25110,6 +25115,26 @@ "Lights Off" ] }, + { + "id": "b497fe229c8f2eea", + "type": "function", + "z": "ebd5561c4f077718", + "g": "4329e464360d0afa", + "name": "Routing", + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst who = states[\"binary_sensor.audible_weather_alerts_allowed\"].attributes.location\nconst payload = msg.payload\n\nlet newMsg = {\n \"payload\": payload,\n \"who\": who\n}\n\nnode.send(newMsg)\nnode.status({fill:\"green\",shape:\"dot\",text: payload + \", \" + who})", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 380, + "y": 440, + "wires": [ + [ + "1180e4c40c3ec0fa" + ] + ] + }, { "id": "1f7af146c06b8b85", "type": "ha-select",