Some code around the incoming event
This commit is contained in:
80
flows.json
80
flows.json
@ -13830,7 +13830,7 @@
|
|||||||
"y": 280,
|
"y": 280,
|
||||||
"wires": [
|
"wires": [
|
||||||
[
|
[
|
||||||
"70925e3cac1396e1"
|
"9932b8210843f84e"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -13847,8 +13847,8 @@
|
|||||||
"targetType": "full",
|
"targetType": "full",
|
||||||
"statusVal": "",
|
"statusVal": "",
|
||||||
"statusType": "auto",
|
"statusType": "auto",
|
||||||
"x": 660,
|
"x": 440,
|
||||||
"y": 280,
|
"y": 220,
|
||||||
"wires": []
|
"wires": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -13856,23 +13856,85 @@
|
|||||||
"type": "function",
|
"type": "function",
|
||||||
"z": "ce9c810396e540b6",
|
"z": "ce9c810396e540b6",
|
||||||
"name": "Processing",
|
"name": "Processing",
|
||||||
"func": "const states = global.get('homeassistant.homeAssistant.states')\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\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)",
|
"func": "const states = global.get('homeassistant.homeAssistant.states')\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 where = msg.payload.event.where\nconst type = msg.payload.event.type\nconst duration = msg.payload.event.duration\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\n// let segLivingRoom = [].concat(segLivingRoom1, segLivingRoom2)\n",
|
||||||
"outputs": 2,
|
"outputs": 4,
|
||||||
"timeout": 0,
|
"timeout": 0,
|
||||||
"noerr": 0,
|
"noerr": 0,
|
||||||
"initialize": "",
|
"initialize": "// Set some constants for all of the lights\n\n// Half and half for living room LED strip\nconst halfLivingRoom1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]\nconst halfLivingRoom2 = [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]\n\n// Individual strip segments for living room LED strip\nconst segLivingRoom1 = [0,1,2,3,4,5,6,7]\nconst segLivingRoom2 = [8,9,10,11,12,13,14,15]\nconst segLivingRoom3 = [16,17,18,19,20,21,22,23]\nconst segLivingRoom4 = [24,25,26,27,28,29,30,31]\nconst segLivingRoom5 = [32,33,34,35,36,37,38,39]\n\n// Half and half for basement LED strip\nconst halfBasement1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]\nconst halfBasement2 = [16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]\n\n// Individual strip segments for basement LED strip\nconst segBasement1 = [0,1,2,3,4,5,6,7]\nconst segBasement2 = [8,9,10,11,12,13,14,15]\nconst segBasement3 = [16,17,18,19,20,21,22,23]\nconst segBasement4 = [24,25,26,27,28,29,30,31]\n\nflow.set(\"halfLivingRoom1\", halfLivingRoom1, \"diskCon\")\nflow.set(\"halfLivingRoom2\", halfLivingRoom1, \"diskCon\")\n\nflow.set(\"segLivingRoom1\", segLivingRoom1, \"diskCon\")\nflow.set(\"segLivingRoom2\", segLivingRoom2, \"diskCon\")\nflow.set(\"segLivingRoom3\", segLivingRoom3, \"diskCon\")\nflow.set(\"segLivingRoom4\", segLivingRoom4, \"diskCon\")\nflow.set(\"segLivingRoom5\", segLivingRoom5, \"diskCon\")\n\nflow.set(\"halfBasement1\", halfBasement1, \"diskCon\")\nflow.set(\"halfBasement2\", halfBasement1, \"diskCon\")\n\nflow.set(\"segBasement1\", segBasement1, \"diskCon\")\nflow.set(\"segBasement2\", segBasement2, \"diskCon\")\nflow.set(\"segBasement3\", segBasement3, \"diskCon\")\nflow.set(\"segBasement4\", segBasement4, \"diskCon\")\n",
|
||||||
"finalize": "",
|
"finalize": "",
|
||||||
"libs": [],
|
"libs": [],
|
||||||
"x": 430,
|
"x": 430,
|
||||||
"y": 280,
|
"y": 280,
|
||||||
"wires": [
|
"wires": [
|
||||||
[
|
[],
|
||||||
"9932b8210843f84e"
|
[],
|
||||||
],
|
[],
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
|
"outputLabels": [
|
||||||
|
"First Floor",
|
||||||
|
"Tina Desk",
|
||||||
|
"Dining Room",
|
||||||
|
"Basement"
|
||||||
|
],
|
||||||
"icon": "font-awesome/fa-bolt"
|
"icon": "font-awesome/fa-bolt"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "523ee0d4f375eb6b",
|
||||||
|
"type": "inject",
|
||||||
|
"z": "ce9c810396e540b6",
|
||||||
|
"name": "",
|
||||||
|
"props": [
|
||||||
|
{
|
||||||
|
"p": "payload"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"p": "topic",
|
||||||
|
"vt": "str"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repeat": "",
|
||||||
|
"crontab": "",
|
||||||
|
"once": false,
|
||||||
|
"onceDelay": 0.1,
|
||||||
|
"topic": "",
|
||||||
|
"payload": "",
|
||||||
|
"payloadType": "date",
|
||||||
|
"x": 240,
|
||||||
|
"y": 340,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"70925e3cac1396e1"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b38f12483048e1ac",
|
||||||
|
"type": "api-call-service",
|
||||||
|
"z": "ce9c810396e540b6",
|
||||||
|
"name": "Living Room Strip",
|
||||||
|
"server": "9e87348d.9c1c48",
|
||||||
|
"version": 5,
|
||||||
|
"debugenabled": false,
|
||||||
|
"domain": "lifx",
|
||||||
|
"service": "effect_move",
|
||||||
|
"areaId": [],
|
||||||
|
"deviceId": [],
|
||||||
|
"entityId": [
|
||||||
|
"light.living_room_led_strip"
|
||||||
|
],
|
||||||
|
"data": "{\t \"speed\": 0.5,\t \"direction\": \"right\",\t \"power_on\": \"false\"\t}",
|
||||||
|
"dataType": "jsonata",
|
||||||
|
"mergeContext": "",
|
||||||
|
"mustacheAltTags": false,
|
||||||
|
"outputProperties": [],
|
||||||
|
"queue": "none",
|
||||||
|
"x": 750,
|
||||||
|
"y": 200,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "7611921cadb91b1e",
|
"id": "7611921cadb91b1e",
|
||||||
"type": "api-call-service",
|
"type": "api-call-service",
|
||||||
|
Reference in New Issue
Block a user