0.9.17 • Published 2 years ago

homebridge-websocket-dti v0.9.17

Weekly downloads
52
License
ISC
Repository
github
Last release
2 years ago

homebridge-websocket

NPM version

Homebridge-websocket is a Plugin for Homebridge. The Websocket-API supports the main homebridge functions. This allows you to add and control accessories from a "Bridge" or "Gateway" with a Websocket API. Node-RED is the perfect platform to use with homebridge-websocket.

Note-RED is a visual tool for wiring together hardware devices, APIs and online services.

Please note that you can only get the accessories which are added via this homebridge-websocket plugin. The same applies to the homebridge-mqtt plugin. See comments here

Installation

If you are new to Homebridge, please first read the documentation to install Homebridge.

Install homebridge-websocket:

sudo npm install -g homebridge-websocket

Configuration

Add the websocket-platform in config.json in your home directory inside .homebridge.

{
  "platform" : "websocket",
  "name" : "websocket",
  "port": 4050
}

Websocket Uri

The homebridge-websocket is listen on:

ws://127.0.0.1:4050

Replace 127.0.0.1 with your ip-address. The port 4050 can be changed in config.json. The websocket-client (e.g. Node-RED) has to connect to homebridge-websocket.

Websocket API

The data is sent/received in a JSON format with this structure:

{"topic": <function>, "payload": {<data>}}
functioninput / output
addoutput
removeoutput
getoutput
setValueoutput
setinput
getinput
responseinput
callbackoutput
input:  the websocket-client receives a message from the homebridge-websocket.
output: the websocket-client sends a message to the homebridge-websocket.

Howto examples:

add (output)

{"topic": "add", "payload": {"name": "flex_lamp", "service": "Switch"}}

or with the additional accessory informations

{"topic": "add", "payload": {"name": "flex_lamp", "service": "Switch", "manufacturer": "lamp_manu", "model": "flex_007", "serialnumber": "4711", "firmwarerevision": "1.0.0"}}

After the new accessory is added homebridge-websocket sends an acknowledge message:

{"topic":"response", "payload": {"ack": true, "message": "accessory 'flex_lamp' is added."}}

remove (output)

{"topic": "remove", "payload": {"name": "flex_lamp"}}

After the accessory is removed homebridge sends an acknowledge message:

{"topic":"response", "payload": {"ack": true, "message": "accessory 'flex_lamp' is removed."}}

get (output)

{"topic": "get", "payload": {"name": "all"}}

homebridge sends an accessories list:

{"topic": "accessories", "payload": {
  "node_switch":{"service":"Switch","characteristics":{"On":true}},
  "office_lamp":{"service":"Lightbulb","characteristics":{"On":"blank","Brightness":65}},
  "at_home":{"service":"OccupancySensor","characteristics":{"OccupancyDetected":1}}
  }
}
{"topic": "get", "payload": {"name": "temp_outdoor"}}

homebridge sends the accessory JSON object:

{"topic": "accessories", "payload": {
  "temp_outdoor": {"service": "TemperatureSensor", "characteristics": {"CurrentTemperature": "13.4"}}
  }
}

setValue (output)

{"topic": "setValue", "payload": {"name": "flex_lamp", "characteristic": "On", "value": true}}

set (input)

{"topic": "set", "payload": {"name": "flex_lamp", "characteristic": "On", "value": true}}

get (input)

{"topic": "get", "payload": {"name": "flex_lamp", "characteristic": "On"}}

When homebridge-websocket sends a get topic it expects a callback with the value within 1 second.

callback (output)

{"topic": "callback", "payload": {"name": "flex_lamp", "characteristic": "On", "value": true}}

The required characteristics are added with the default properties. If you need to change the default, define the characteristic-name with the properties. e.g.:

{"topic": "add",
 "payload":
  {
    "name": "temp_living",
    "service": "TemperatureSensor",
    "CurrentTemperature": {"minValue": -20, "maxValue": 60,"minStep": 1}
  }
}

To add an optional charachteristic define the characteristic-name with "default" or with the properties. e.g.:

{"topic": "add", "payload": {"name": "living_lamp", "service": "Lightbulb", "Brightness": "default"}}
{"topic": "add",
  "payload":
    {
      "name": "bathroom_blind",
      "service": "WindowCovering",
      "CurrentPosition": {"minStep": 5},
      "TargetPosition": {"minStep": 5},
      "CurrentHorizontalTiltAngle": {"minValue": 0, "minStep": 5},
      "TargetHorizontalTiltAngle": {"minValue": 0, "minStep": 5}
    }
}

HomeKitTypes.js describes all the predifined Services and Characteristcs.

Websocket client (node-RED)

Here's an example flow. It shows how to add an accessory (office_lamp) and how to set the value on/off. The messages sent from the homebridge-websocket are displayed on the debug tap.

node-RED websocket settings:

Type:     Connect to
URL:      ws://127.0.0.1:4050
option:   Send/Receice intery message

node-RED

Take a look at collection/homebridge-websocket for the example-flow.json which you can import into node-RED.

0.9.16

2 years ago

0.9.17

2 years ago

0.9.13

3 years ago

0.9.14

3 years ago

0.9.15

3 years ago

0.9.10-Beta.2

3 years ago

0.9.10-Beta.1

3 years ago

0.9.9

3 years ago

0.9.8-beta.1

3 years ago

0.9.8-beta.2

3 years ago

0.9.8-beta.3

3 years ago

0.9.8-beta.4

3 years ago

0.9.11

3 years ago

0.9.12-beta1

3 years ago

0.9.10-Beta

3 years ago

0.9.7-beta.10

4 years ago

0.9.7-beta.11

4 years ago

0.9.7-beta.12

4 years ago

0.9.7-beta.13

4 years ago

0.9.7-beta.14

4 years ago

0.9.7-beta.15

4 years ago

0.9.7-beta.16

4 years ago

0.9.7-beta.17

4 years ago

0.9.7-beta.18

4 years ago

0.9.7-beta.19

4 years ago

0.9.7-beta.20

4 years ago

0.9.7-beta.21

4 years ago

0.9.7-beta.22

4 years ago

0.9.7-beta.23

4 years ago

0.9.7-beta.24

4 years ago

0.9.7-beta.25

4 years ago

0.9.7-beta.26

4 years ago

0.9.7-beta.27

4 years ago

0.9.7-beta.28

4 years ago

0.9.7-beta.29

4 years ago

0.9.8

4 years ago

0.9.7

4 years ago

0.9.7-beta.30

4 years ago

0.9.7-beta.31

4 years ago

0.9.7-beta.32

4 years ago

0.9.7-beta.33

4 years ago

0.9.7-beta.34

4 years ago

0.9.6

4 years ago

0.9.7-beta.35

4 years ago

0.9.7-beta.36

4 years ago

0.9.7-beta.37

4 years ago

0.9.7-beta.38

4 years ago

0.9.7-beta.39

4 years ago

0.9.7-beta.40

4 years ago

0.9.7-beta.41

4 years ago

0.9.7-beta.42

4 years ago

0.9.7-beta.43

4 years ago

0.9.7-beta.44

4 years ago

0.9.7-beta.45

4 years ago

0.9.7-beta.46

4 years ago

0.9.7-beta.47

4 years ago

0.9.7-beta.48

4 years ago

0.9.7-beta.49

4 years ago

0.9.7-beta.50

4 years ago

0.9.7-beta.51

4 years ago

0.9.7-beta.52

4 years ago

0.9.7-beta.0

4 years ago

0.9.7-beta.53

4 years ago

0.9.7-beta.54

4 years ago

0.9.7-beta.2

4 years ago

0.9.7-beta.55

4 years ago

0.9.7-beta.1

4 years ago

0.9.7-beta.56

4 years ago

0.9.7-beta.4

4 years ago

0.9.7-beta.57

4 years ago

0.9.7-beta.3

4 years ago

0.9.7-beta.58

4 years ago

0.9.7-beta.59

4 years ago

0.9.7-beta.61

4 years ago

0.9.7-beta.6

4 years ago

0.9.7-beta.5

4 years ago

0.9.7-beta.8

4 years ago

0.9.7-beta.7

4 years ago

0.9.7-beta.9

4 years ago

0.9.7-beta.60

4 years ago

0.8.9

4 years ago

0.8.8

4 years ago

0.8.5

4 years ago

0.6.7

4 years ago

0.8.4

4 years ago

0.6.6

4 years ago

0.8.7

4 years ago

0.6.9

4 years ago

0.8.6

4 years ago

0.6.8

4 years ago

0.9.0

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.9.2

4 years ago

0.7.4

4 years ago

0.5.6

4 years ago

0.9.1

4 years ago

0.7.3

4 years ago

0.7.0

4 years ago

0.7.9

4 years ago

0.9.4

4 years ago

0.7.6

4 years ago

0.5.8

4 years ago

0.9.3

4 years ago

0.7.5

4 years ago

0.5.7

4 years ago

0.7.8

4 years ago

0.9.5

4 years ago

0.7.7

4 years ago

0.5.9

4 years ago

0.8.1

4 years ago

0.6.3

4 years ago

0.8.0

4 years ago

0.6.2

4 years ago

0.8.3

4 years ago

0.6.5

4 years ago

0.8.2

4 years ago

0.6.4

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.4

4 years ago

0.5.5

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.5.3

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.3.9

4 years ago

0.4.0

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago