ArtiLED Control API v1.0 ======================== The Control device has two TCP daemons for device and activity management. Both require token authentication before accepting commands. ArtiDEVICE — TCP Port 1100 ========================== Authentication: Send: Token Receive: 1 (success) or 0 (failure) Device Command: Send: Example: 5 command_on Example: 5 volume_up Example: 5 input_2 Receive: device response or error string Raw Command: Send: raw Example: 5 raw VOL SET 50 Receive: device response or error string Wake-on-LAN: Send: wol Example: wol AA:BB:CC:DD:EE:FF Receive: wol sent Button Functions: power, command_on, command_off volume, volume_up, volume_down, mute, unmute, mute_toggle up, down, left, right, select, back, home, menu context_menu, guide, info, options, settings, exit play, pause, play_pause, stop, forward, rewind next, previous, eject, record channel_up, channel_down digit_0 - digit_9 input, input_1 - input_9 red, green, yellow, blue subtitle, audio, sound_mode, picture_mode, aspect_ratio, display app_1 - app_4, output_1 - output_4, custom_1 - custom_4 Protocols: 0 = None 1 = Telnet (raw TCP with prefix + command + suffix) 2 = HTTP GET (url_prefix + command, and replaced) 3 = HTTP POST (url_prefix as URL, command as body) 4 = RS-232 (serial port with baud rate and format) 5 = IR (not yet implemented) 6 = HTTPS GET 7 = HTTPS POST ArtiACTIVITY — TCP Port 1101 ============================= Authentication: Send: Token Receive: 1 (success) or 0 (failure) Start Activity: Send: start activity Example: start activity 5 Receive: 1 (success) or error string Action: Stops current activity (runs stop steps), executes new activity's start steps in order, builds button routing in Memcached, updates zone_active_activity in DB. Stop Activity (by zone): Send: stop activity Example: stop activity 3 Receive: 1 (success) or error string Action: Executes current activity's stop steps, clears routing, sets zone_active_activity to 0. Stop Room: Send: stop room Example: stop room 1 Receive: 1 (success) or error string Action: Stops all active activities in all zones of the room. Stop All: Send: stop all Receive: 1 (success) or error string Action: Stops all active activities in all zones. Button Press: Send: button Example: button 3 volume_up Receive: device response or 'no routing' Action: Looks up device_id from Memcached routing for this zone + button, sends command to artiled_device.py. Get Active Activity: Send: get activity Example: get activity 3 Receive: () or (0) Get Routing: Send: get routing Example: get routing 3 Receive: (button=device_id,button=device_id,...) or (no activity) Reload Routing: Send: reload routing Example: reload routing 3 Receive: 1 (success) or 'no activity' Action: Rebuilds Memcached routing from activity steps. Reload All: Send: reload all Receive: 1 Action: Reloads routing for all zones with active activities. Get Version: Send: get version Receive: () Send: get version date Receive: () Ping: Send: ping Receive: 1 Activity Step Types =================== Steps are stored in activity_steps table. Executed sequentially per phase. Phase 1 = On Start (when activity starts) Phase 2 = On Stop (when activity stops) Type 1 — Device Command: config: {"device_id": "5", "command": "device_volume_up", "param": "50"} Action: Sends button command to device via ArtiDEVICE daemon. If param present, replaces ? in command value. Type 2 — Delay: config: {"seconds": "3"} Action: Sleeps for N seconds. Type 3 — Tool: config: {"tool_id": "2", "command": "Route In1→Out A"} Action: Looks up tool → equipment → command value, sends via protocol. Type 4 — Flow: config: {"flow_id": "3"} Action: Starts flow via UDP to artiled_flow.py (port 50094). Type 6 — Device: config: {"device_id": "5", "power": "1", "input": "2", "roles": ["volume", "navigation"]} Action: Power on/off/leave + input switch via ArtiDEVICE daemon. Roles used for button routing (not executed as commands). Power: 1=On, 0=Off, 2=Leave (don't change) Type 7 — Video Processor: config: {"integration_id": "1", "action": "hdmi_input", "value": "2"} Action: Sends HTTP to Video Processor API. Actions: video_input, hdmi_input, hdr_profile, osd, audio, autosw, mute_tx0, mute_tx1, oled Type 8 — Hub: config: {"integration_id": "3", "action": "scene", "selection": "room", "target": "5", "value": "12"} Action: Sends HTTP to Hub API. Actions: scene, mode, flow Selection: house, room, zone, light Type 9 — All Off: config: {} Action: Powers off all enabled devices in the activity's room/zone. Button Routing ============== Routing maps button function → device_id per zone via Memcached. Memcached keys: activity:zone::routing: = activity:zone::active = Built from Device steps (type 6) with roles: power → power, command_on, command_off volume → volume_up, volume_down, mute, unmute, mute_toggle navigation → up, down, left, right, select, back, home, menu, ... playback → play, pause, play_pause, stop, forward, rewind, ... inputs → input, input_1-9, channel_up, channel_down, digit_0-9 Error Codes =========== device not found — device_id not in devices table device disabled — device_enable = 0 device type not found — device_type_id not in device_types table no command — button function column is empty in device_type no ip address — device has no IP and protocol needs one no mac address — WOL requested but no MAC no protocol — protocol = 0 no routing — no routing entry for this button in this zone activity not found — activity_id not found or disabled zone not found — zone_id not in zones table already active — activity already active in zone no activity — no active activity in zone auth failed — token authentication failed error — general exception (details in daemon log)