Skip to content
Robert Stanley Judka edited this page Mar 6, 2021 · 17 revisions

Accepts WebSocket connections on port 54545 (thats 0xD511 [DSH] in decimal)

This service is disabled by default. It can be toggled on the Main tab of the Settings Page

Endpoints

/state

API

  • mode : string ⇒ string, <color>
    • valid values: "Light", "Dark"
  • color : string ⇒ string
    • valid values: RGB (e.g "#112233"), ARGB (e.g "#ff112233"), color name (e.g "blue")
  • page : int ⇒ int
    • index of active page
  • brightness : int ⇒ int
    • plz only set between 76 and 255 🙂
  • volume : int ⇒ int
    • plz only set between 0 and 100 🙂
  • pageX [X is the page's index] : bool ⇒ object(bool, string)
    • page availability and name
    • only availability is settable
  • pages : array of bool ⇒ array of object(bool, string, string)
    • availability, key, and name of all pages
    • only availability is settable

It is possible for a state update to affect multiple properties (e.g. changing mode also changes color), thus any cascaded state updates are denoted with <>

Messaging

  1. Send an array of keys, get an object of each key:value
  2. Send an object of each key:value to update, get an object of each updated key:value

/action

API

  • cycle_page : int? ⇒ <page>
  • decrease_brightness : int? ⇒ <brightness>
  • increase_brightness : int? ⇒ <brightness>
  • decrease_volume : int? ⇒ <volume>
  • increase_volume : int? ⇒ <volume>

? denotes an optional parameter to be used (if the action supports it) when sending a key:value

To simplify response handling by the clients, an action may return state keyed updates (where the key matches some state) as denoted by <>

Messaging

  1. Send an array of keys, get an object of any updated key:value
  2. Send an object of each key:value, get an object of any updated key:value

Examples

JavaScript

> state = new WebSocket("ws://localhost:54545/state");
> state.onmessage = function (event){ console.log(event.data); };

> action = new WebSocket("ws://localhost:54545/action");
> action.onmessage = function (event){ console.log(event.data); };
> state.send(JSON.stringify(["mode", "color", "page", "volume"]));

{
    "color": "#85a7cf",
    "mode": "Dark",
    "page": 0,
    "volume": 50
}
> state.send(JSON.stringify({"mode": "Light"}));

{
    "color": "#2b6cb5",
    "mode": "Light"
}
> action.send(JSON.stringify(["cycle_page", "increase_volume"]));

{
    "page": 1,
    "volume": 52
}
> action.send(JSON.stringify({"increase_volume": 10}));

{
    "volume": 62
}
Clone this wiki locally