[ { "id": "controller1", "type": "alexa-home-controller", "controllername": "Smart Home Hub", "port": "80", "useHttps": false, "useNode": false, "maxItems": -1, "x": 150, "y": 80, "wires": [] }, { "id": "light1", "type": "alexa-home", "devicename": "Living Room Light", "devicetype": "Extended color light", "x": 150, "y": 160, "wires": [["debug1", "dimmer1"]] }, { "id": "light2", "type": "alexa-home", "devicename": "Kitchen Light", "devicetype": "Dimmable light", "x": 150, "y": 220, "wires": [["debug2", "switch1"]] }, { "id": "light3", "type": "alexa-home", "devicename": "Bedroom Light", "devicetype": "Color light", "x": 150, "y": 280, "wires": [["debug3", "colorlight1"]] }, { "id": "dimmer1", "type": "function", "name": "Control Dimmer", "func": "// Control a physical dimmer based on Alexa commands\n// msg.payload contains: on, bri, command, bri_normalized\n\nif (msg.payload.command === 'switch') {\n // Handle on/off commands\n msg.topic = 'dimmer/power';\n msg.payload = msg.payload.on ? 'ON' : 'OFF';\n} else if (msg.payload.command === 'dim') {\n // Handle brightness commands\n msg.topic = 'dimmer/brightness';\n // Convert 0-254 to 0-100 percentage\n msg.payload = msg.payload.bri_normalized;\n} else if (msg.payload.command === 'color') {\n // Handle color commands for RGB dimmer\n msg.topic = 'dimmer/color';\n // XY coordinates can be converted to RGB if needed\n msg.payload = {\n x: msg.payload.xy[0],\n y: msg.payload.xy[1],\n brightness: msg.payload.bri_normalized\n };\n}\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 400, "y": 160, "wires": [["mqtt1"]] }, { "id": "switch1", "type": "function", "name": "Control Switch", "func": "// Control a simple on/off switch\n// msg.payload contains: on, bri, command\n\nif (msg.payload.command === 'switch' || msg.payload.command === 'dim') {\n msg.topic = 'switch/power';\n msg.payload = msg.payload.on ? 'ON' : 'OFF';\n}\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 400, "y": 220, "wires": [["mqtt2"]] }, { "id": "colorlight1", "type": "function", "name": "Control RGB Light", "func": "// Control an RGB light with full color support\n// msg.payload contains: on, bri, xy, command, bri_normalized\n\nlet output = {\n power: msg.payload.on ? 'ON' : 'OFF',\n brightness: msg.payload.bri_normalized\n};\n\nif (msg.payload.command === 'color' && msg.payload.xy) {\n // Convert XY to RGB (simplified conversion)\n // In practice, you'd use a proper CIE XY to RGB conversion\n const x = msg.payload.xy[0];\n const y = msg.payload.xy[1];\n \n // Simplified RGB approximation\n output.color = {\n r: Math.round(x * 255),\n g: Math.round(y * 255),\n b: Math.round((1 - x - y) * 255)\n };\n}\n\nmsg.topic = 'rgblight/control';\nmsg.payload = output;\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 400, "y": 280, "wires": [["mqtt3"]] }, { "id": "mqtt1", "type": "mqtt out", "name": "Living Room Dimmer", "topic": "", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 620, "y": 160, "wires": [] }, { "id": "mqtt2", "type": "mqtt out", "name": "Kitchen Switch", "topic": "", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 600, "y": 220, "wires": [] }, { "id": "mqtt3", "type": "mqtt out", "name": "Bedroom RGB Light", "topic": "", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 620, "y": 280, "wires": [] }, { "id": "debug1", "type": "debug", "name": "Living Room Debug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 420, "y": 120, "wires": [] }, { "id": "debug2", "type": "debug", "name": "Kitchen Debug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 400, "y": 180, "wires": [] }, { "id": "debug3", "type": "debug", "name": "Bedroom Debug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 400, "y": 340, "wires": [] }, { "id": "inject1", "type": "inject", "name": "Turn On Living Room", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{\"on\":true}", "payloadType": "json", "x": 150, "y": 380, "wires": [["light1"]] }, { "id": "inject2", "type": "inject", "name": "Dim to 50%", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{\"bri\":127}", "payloadType": "json", "x": 130, "y": 420, "wires": [["light1"]] }, { "id": "inject3", "type": "inject", "name": "Set Color Red", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{\"xy\":[0.675,0.322]}", "payloadType": "json", "x": 130, "y": 460, "wires": [["light3"]] }, { "id": "comment1", "type": "comment", "name": "Basic Smart Lighting Control Example", "info": "This example demonstrates basic smart lighting control using Alexa Home nodes.\n\n**Features:**\n- Alexa Home Controller for device management\n- Three different light types: Extended color, Dimmable, Color\n- MQTT integration for controlling physical devices\n- Debug outputs for monitoring commands\n- Manual injection nodes for testing\n\n**Voice Commands:**\n- \"Alexa, turn on the living room light\"\n- \"Alexa, set the kitchen light to 50 percent\"\n- \"Alexa, turn the bedroom light red\"\n- \"Alexa, turn off all lights\"\n\n**Setup:**\n1. Configure MQTT broker connections\n2. Update device names as needed\n3. Adjust topic names for your devices\n4. Deploy the flow\n5. Ask Alexa to discover devices\n\n**Message Format:**\n- on: boolean (true/false)\n- bri: number (0-254)\n- bri_normalized: number (0-100)\n- xy: array [x, y] for color\n- command: string ('switch', 'dim', 'color')", "x": 200, "y": 40, "wires": [] } ]