Skip to content

WebSocket API (V3.1)

bpohvoodoo edited this page Feb 2, 2020 · 3 revisions

WebSocket connection

The WebSocket server runs at ws://ESP_IP_ADDRESS_OR_HOSTNAME:81/

Payload: #<hexrgb>

Set main color of the strip.

Where <hexrgb> is the color as a WRGB hex value, e.g. 0004d2ff.

Result: OK

Payload: ##<hexrgb>

Set background color of the strip.

Where <hexrgb> is the color as a WRGB hex value, e.g. 0004d2ff.

Result: OK

Payload: ###<hexrgb>

Set extra color of the strip.

Where <hexrgb> is the color as a WRGB hex value, e.g. 0004d2ff.

Result: OK

Payload: *<hexrgb>

Set main color of the strip and light all LEDs in that color. This is equal to WS2812FX mode "Static".

Where <hexrgb> is the color as a WRGB hex value, e.g. 0004d2ff.

Result: OK

Payload: !<numled><hexrgb>

Where <numled> is the number of the led (start index is 0000), e.g. 0004 would be the 5th LED. Where <hexrgb> is the color as a WRGB hex value, e.g. 0004d2ff.

Light single LEDs in the given color.

Result: OK

Payload: +[numled][hexrgb]+[numled][hexrgb]+[numled][hexrgb] [...]

Where <numled> is the number of the led (start index is 0000), e.g. 0004 would be the 5th LED. Where <hexrgb> is the color as a WRGB hex value, e.g. 0004d2ff.

Light multiple LEDs in the given colors.

Result: OK

Payload: R[r_start][r_end][hexrgb] [...]

Light multiple LED ranges in the given colors.

Where <r_start> is the first index of the range (start index is 0000). Where <r_end> is the last index of the range. Where is the color as a WRGB hex value, e.g. 0004d2ff.

This command can be daisy chained!

Example: R0000000900ffffffR0010001900ff0000 lights the first 10 LEDs white and the next 10 red Result: OK

Payload: ?<speed>

Set speed.

Where <speed> is the speed from 0 to 255.

Result: OK

Payload: %<brightness>

Set brightness.

Where <brightness> is the brightness as value 0-255.

Result: OK

Payload: ~

Gets the list of available animation modes as JSON.

Result:

[
  {
    "mode":"off",
    "name":"OFF"
  },
  {
    "mode": 0,
    "name": "Static"
  },
  {
    "mode": 1,
    "name": "Blink"
  },
  {
    "mode": 2,
    "name": "Breath"
  },
  ...
]

Payload: /<animation_mode_id>

Only available in version 2.0 and later

Set animation mode.

Where <animation_mode_id> is on from the list you get with "~" or

  • off (Turn all LEDs off.)
  • on (Turn all LEDs on to last state.) This does not work for Custom WS Mode

Result: OK

Payload: $

Get status info as JSON.

Result:

{
  "mode":5,
  "ws2812fx_mode":0,
  "ws2812fx_mode_name":"Static",
  "speed":255,
  "brightness":43,
  "color":[0,255,57,0,0,0,0,0,0,0,0,0]
}

Payload: C

Get config info as JSON.

Result:

{
  "hostname":"McLightingRGBW",
  "mqtt_host":"192.168.0.10",
  "mqtt_port":1883,
  "mqtt_user":"mqtt_user",
  "mqtt_pass":"mqtt-passw0rd",
  "ws_cnt":194,
  "ws_rgbo":"GRBW",
  "ws_pin":3,
  "ws_fxopt":48
}

Payload: Ch<hostname>

Set Hostname.

Where <hostname> is a hostname or IP with a length from 0-64 chars.

Result: Will be same as C

Payload: Cmh<mqtt_hostname>

Set MQTT Server Hostname.

Where <mqtt_hostname> is a hostname or IP with a length from 0-64 chars.

Result: Will be same as C

Payload: Cmp<mqtt_port>

Set MQTT Server Port.

Where <mqtt_port> is an integer from 0-65535.

Result: Will be same as C

Payload: Cmu<mqtt_user>

Set MQTT Server username.

Where <mqtt_user> is a username length from 0-32 chars.

Result: Will be same as C

Payload: Cmw<mqtt_pass>

Set MQTT Server password.

Where <mqtt_pass> is a password length from 0-32 chars.

Result: Will be same as C

Payload: Csc<strip_led_count>

Set the strips led count.

Where <strip_led_count> is an integer between 1-9999.

Result: Will be same as C

Payload: Csp<strip_gpio_pin>

Set the strips ws2812fx options.

It is only available, if USE_WS2812FX_DMA is not defined in definitions.h

Where <strip_gpio_pin> is an integer between 0-99. Allowed values for NodeMCU or Wemos are values from 0-5 and 12-16.

Result: Will be same as C

Payload: Csr<strip_rgborder>

Set the strips led order. Where <strip_rgborder> is any combination of the chars r, g, b and w.

Rules:

Every char is only allowed once,

<strip_rgborder> must contain r, g, b,

and can contain w.

Result: Will be same as C

Payload: Ce<transitionEffect>

Set the transition effect option. Where <transitionEffect> is a boolean 0 or 1.

Result: Will be same as C

Payload: S

Get segment state info as JSON.

Result:

{
  "start":72,
  "stop":143,
  "fx_mode":61,
  "speed":0,
  "color":[0,0,11,255,0,255,0,13,0,0,0,0],
  "ws_fxopt":48
}

Payload: Ss<segment>

Set the active strip segment. Where <segment> is an integer between 0-9.

Result: Will be same as S

Payload: S[<start>

Set the first LED of the active strip segment, starting with 0 for first LED. Where <start> is an integer between 0-.

Result: Will be same as S

Payload: S]<stop>

Set the last LED of the active strip segment. Where <stop> is an integer between -.

Result: Will be same as S

Payload: So<segment_fx_options>

Set the strips ws2812fx options. Where <segment_fx_options> is an integer between 0-255.

See WS2812FX documentation for more infos.

Result: Will be same as S