# API EvLamp provides a simple API based on HTTP GET and POST requests containing JSON data. --- ## Contents - [Get firmware information](#get-firmware-information) - [Get current WiFi settings](#get-current-wifi-settings) - [Set WiFi settings](#set-wifi-settings) - [Get current LED settings](#get-current-led-settings) - [Set LED settings](#set-led-settings) - [Reset system settings](#reset-system-settings) - [Reboot device](#reboot-device) - [Get current lamp state](#get-current-lamp-state) - [Set lamp state](#set-lamp-state) - [Get full list of effects and its parameters](#get-full-list-of-effects-and-its-parameters) - [Reset parameters of all effects](#reset-parameters-of-all-effects) - [Get current effect parameters](#get-current-effect-parameters) - [Set effect parameters](#set-effect-parameters) --- ## Get firmware information ### Request **GET** `/api/info` ### Response ```jsonc { "app_name": , "app_version": , "build_date": , "idf_ver": } ``` **Example** ```json { "app_name": "EvLamp", "app_version": "0.6.3", "build_date": "May 2 2022", "idf_ver": "v5.0-dev-1829-ge29e96101d-dirty" } ``` --- ## Get current WiFi settings ### Request **GET** `/api/settings/wifi` ### Response ```jsonc { "mode": , "ip": { /* IP settings for both AP and station modes */ "dhcp": , "ip": , "netmask": , "gateway": , "dns": }, "ap": { /* Access Point settings, only makes sense in AP mode */ "ssid": , "channel": , "password": , }, "sta": { /* Station settings, only makes sense in station mode */ "ssid": , "password": , } } ``` **Example** ```json { "mode": 1, "ip": { "dhcp": true, "ip": "192.168.1.1", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "dns": "192.168.1.1" }, "ap": { "ssid": "EvLamp", "channel": 6, "password": "" }, "sta": { "ssid": "MyHomeWiFi", "password": "SuperSecret" } } ``` --- ## Set WiFi settings ### Request **POST** `/api/settings/wifi` ```jsonc { "mode": , "ip": { /* IP settings for both AP and station modes */ "dhcp": , "ip": , "netmask": , "gateway": , "dns": }, "ap": { /* Access Point settings, only makes sense in AP mode */ "ssid": , "channel": , "password": , }, "sta": { /* Station settings, only makes sense in station mode */ "ssid": , "password": , } } ``` ### Response ```jsonc { "result": , "name": , "message": } ``` --- ## Get current LED settings ### Request **GET** `/api/settings/leds` ### Response ```jsonc { "block_width": , "block_height": , "h_blocks": , "v_blocks": , "type": , "current_limit": , } ``` *Note: The total number of blocks (h_blocks * v_blocks) should not be more than 8* **Example** Single 16x16 WS2812B matrix: ```json { "block_width": 16, "block_height": 16, "h_blocks": 1, "v_blocks": 1, "type": 0, "current_limit": 5000 } ``` --- ## Set LED settings ### Request **POST** `/api/settings/leds` ```jsonc { "block_width": , "block_height": , "h_blocks": , "v_blocks": , "type": , "current_limit": , } ``` ### Response ```jsonc { "result": , "name": , "message": } ``` --- ## Reset system settings Resets all system settings including both WiFi and LED settings to default values. After resetting device must be rebooted. ### Request **GET** `/api/settings/reset` ### Response ```jsonc { "result": , "name": , "message": } ``` --- ## Reboot device ### Request **GET** `/api/reboot` ### Response No response, device just reboots. --- ## Get current lamp state ### Request **GET** `/api/lamp/state` ### Response ```jsonc { "on": , "effect": , "brightness": , "fps": } ``` --- ## Set lamp state With this function you can switch LEDs on and off, change current effect, brightness and FPS. ### Request **POST** `/api/lamp/state` ```jsonc { "on": , "effect": , "brightness": , "fps": } ``` Any item in request can be omitted. For example, you can switch off the lamp with this POST: ```json { "on": false } ``` or change effect to "Fire" (id = 1) and set brightness: ```json { "effect": 1, "brightness": 50 } ``` ### Response ```jsonc { "result": , "name": , "message": } ``` --- ## Get full list of effects and its parameters ### Request **GET** `/api/effects` ### Response ```jsonc [ { "name": , "params": [ { "name": , "min": , "max": , "default": , "value": }, ... ] }, ... ] ``` The effect index in the response array is the effect ID. The parameter's index in the effect's parameter list is the parameter ID. **Example** ```json [{ "name": "Color lamp", "params": [{ "name": "Red", "min": 0, "max": 255, "default": 255, "value": 255 }, { "name": "Green", "min": 0, "max": 255, "default": 159, "value": 159 }, { "name": "Blue", "min": 0, "max": 255, "default": 70, "value": 70 }] }, { "name": "Fire", "params": [{ "name": "Palette", "min": 0, "max": 7, "default": 0, "value": 0 }, { "name": "Scale", "min": 10, "max": 100, "default": 60, "value": 60 }] }, ... { "name": "Fireflies", "params": [{ "name": "Number of fireflies", "min": 4, "max": 48, "default": 16, "value": 16 }, { "name": "Chaotic movements", "min": 0, "max": 1, "default": 1, "value": 1 }, { "name": "Speed", "min": 1, "max": 255, "default": 255, "value": 255 }, { "name": "Update time", "min": 1, "max": 10, "default": 3, "value": 3 }] }] ``` --- ## Reset parameters of all effects ### Request **GET** `/api/effects/reset` ### Response ```jsonc { "result": , "name": , "message": } ``` --- ## Get current effect parameters ### Request **GET** `/api/lamp/effect` ### Response ```jsonc { "effect": , "params": [ { "name": , "min": , "max": , "default": , "value": }, ... ] } ``` **Example** ```json { "effect": 1, "params": [ { "name": "Palette", "min": 0, "max": 7, "default": 0, "value": 0 }, { "name": "Scale", "min": 10, "max": 100, "default": 60, "value": 60 } ] } ``` --- ## Set effect parameters ### Request **POST** `/api/lamp/effect` ```jsonc { "effect": , "params": [ , ... , ] } ``` **Example** Set Palette = 1 and Scale = 60 for the "Fire" effect. ```json { "effect": 1, "params": [ 1, 60 ] } ``` ### Response ```jsonc { "result": , "name": , "message": } ```