Skip to content

Websocket

RaHoni edited this page Apr 18, 2021 · 3 revisions

Websocket communication (only for interested people)

General information

  • https encrypted
  • must be authenticated
  • JSON encoded with the format: {"Command":"<commandName>","Args":<args>}
  • Answer will be: {"Command":"<commandName>","answer":<answer>} and always {"Command":"<commandName>","answer":<Success/Fail>}

Commands

  • on Args: {"percent": 0...1,id:"id"}
  • off Args: {"id":"id"}
  • getRandomId: get a random free ID
  • getController: get all Controller with their Ids and names
  • getDevices: requesting All devices
  • getDevice Args: {"id":id} requesting all Information for a device
  • addDevice:
    • mqtt Args: {"id":"id", "name":"name", "switchType":"mqtt", "controlType":"button/slider"}
    • 433Mhz Args: {"id":"id", "name":"name", "switchType":"433Mhz", "controlType":"button", "systemCode":"00000-11111", "unitCode":"00000-11111"}
  • updateDevice:
    • mqtt Args: {"oldId":"id", "newId":"id", "name":"name", "switchType":"mqtt", "controlType":"button/slider"}
    • 433Mhz Args: {"oldId":"id", "newId":"id", "name":"name", "switchType":"433Mhz", "controlType":"button", "systemCode":"00000-11111", "unitCode":"00000-11111"}

Answers

  • statusChange Args: {"id":"id",status:0...1}
  • getDevices Args: {devices:[{<same data as addDevice>},...]}
  • getDevice Args: {<same data as addDevice>}
  • newDevice Args: {<same data as addDevice>}
  • getRandomId Args: <id> [a-Z0-9]{5}
  • getController Args: [{"masterId":<masterId>, "name":<name>}]
  • "error":{"error":"msg","exeption":"Stacktrace"}

Authentication

Authflow German

  1. Connect to server
  2. if client has a SessionID sends it to the server else step 4
  3. If SessionID is valid on the server you are authenticated else
  4. Client shows password dialog
  5. sends user credentials if they are correct
  6. Server authentication will send a SessionID along with
  • Message for pass Auth {"auth":"pass", "username":<username>, "pass":<password>}
  • Message for SessionID Auth {"auth":"ID", "sessionID":<sessionID>}

Server answer: {"auth":<authtype>, "authenticated":<true/false>(, "sessionID":<sessionId>)} (if true)

Planned

  • settingsMain Args: {setting:"SettingsName", value:"value"}

Clone this wiki locally