# Hub - Documentation

# Hub

#### new Hub()

The Hub is emitted if the discovered device is a Hub.

Source:
  - hubs/hub.js, line 31

### Extends

- LPF2Hub
- BaseHub

### Members

#### (readonly) batteryLevel

##### Properties:

Name | Type | Description
--- | --- | ---
`batteryLevel` | number | Battery level of the hub (Percentage between 0-100)

Inherited From:
  - BaseHub#batteryLevel
Source:
  - hubs/basehub.js, line 141

#### (readonly) firmwareVersion

##### Properties:

Name | Type | Description
--- | --- | ---
`firmwareVersion` | string | Firmware version of the hub

Inherited From:
  - BaseHub#firmwareVersion
Source:
  - hubs/basehub.js, line 113

#### (readonly) hardwareVersion

##### Properties:

Name | Type | Description
--- | --- | ---
`hardwareVersion` | string | Hardware version of the hub

Inherited From:
  - BaseHub#hardwareVersion
Source:
  - hubs/basehub.js, line 120

#### (readonly) name

##### Properties:

Name | Type | Description
--- | --- | ---
`name` | string | Name of the hub

Inherited From:
  - BaseHub#name
Source:
  - hubs/basehub.js, line 92

#### (readonly) ports

##### Properties:

Name | Type | Description
--- | --- | ---
`ports` | Array.<string> | Array of port names

Inherited From:
  - BaseHub#ports
Source:
  - hubs/basehub.js, line 106

#### (readonly) primaryMACAddress

##### Properties:

Name | Type | Description
--- | --- | ---
`primaryMACAddress` | string | Primary MAC address of the hub

Inherited From:
  - BaseHub#primaryMACAddress
Source:
  - hubs/basehub.js, line 127

#### (readonly) rssi

##### Properties:

Name | Type | Description
--- | --- | ---
`rssi` | number | Signal strength of the hub

Inherited From:
  - BaseHub#rssi
Source:
  - hubs/basehub.js, line 148

#### (readonly) type

##### Properties:

Name | Type | Description
--- | --- | ---
`type` | string | Hub type

Inherited From:
  - BaseHub#type
Source:
  - hubs/basehub.js, line 99

#### (readonly) uuid

##### Properties:

Name | Type | Description
--- | --- | ---
`uuid` | string | UUID of the hub

Inherited From:
  - BaseHub#uuid
Source:
  - hubs/basehub.js, line 134

### Methods

#### connect() → {Promise}

Connect to the Hub.

Source:
  - hubs/basehub.js, line 151

#### createVirtualPort(firstPortName, secondPortName) → {Promise}

Combines two ports with into a single virtual port.

Note: The devices attached to the ports must be of the same device type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`firstPortName` | string | First port name
`secondPortName` | string | Second port name

Inherited From:
  - LPF2Hub#createVirtualPort
Source:
  - hubs/lpf2hub.js, line 90

#### disconnect() → {Promise}

Disconnect the Hub.

Source:
  - hubs/basehub.js, line 165

#### getDeviceAtPort(portName) → {Device|undefined}

Retrieves the device attached to a given port.

##### Parameters:

Name | Type | Description
--- | --- | ---
`portName` | string | The name of the port to retrieve the device from.

Source:
  - hubs/basehub.js, line 173

#### getDevices() → {Array.<Device>}

Retrieves all attached devices.

Source:
  - hubs/basehub.js, line 213

#### getDevicesByType(deviceType) → {Array.<Device>}

Retrieves an array of devices of the specified type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceType` | number | The device type to lookup.

Source:
  - hubs/basehub.js, line 221

#### setName(name) → {Promise}

Set the name of the Hub.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | New name of the hub (14 characters or less, ASCII only).

Inherited From:
  - LPF2Hub#setName
Source:
  - hubs/lpf2hub.js, line 61

#### shutdown() → {Promise}

Shutdown the Hub.

Inherited From:
  - LPF2Hub#shutdown
Source:
  - hubs/lpf2hub.js, line 53

#### sleep(delay) → {Promise}

Sleep a given amount of time.

Note: This is a helper method to make it easier to add delays into a chain of commands.

##### Parameters:

Name | Type | Description
--- | --- | ---
`delay` | number | How long to sleep (in milliseconds).

Source:
  - hubs/basehub.js, line 266

#### wait(commands) → {Promise}

Wait until a given list of concurrently running commands are complete.

Note: This is a helper method to make it easier to wait for concurrent commands to complete.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commands` | Array.<Promise.<any>> | Array of executing commands.

Source:
  - hubs/basehub.js, line 279

#### waitForDeviceAtPort(portName) → {Promise}

Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

Note: If a device is never attached, the returned promise may never resolve.

##### Parameters:

Name | Type | Description
--- | --- | ---
`portName` | string | The name of the port to retrieve the device from.

Source:
  - hubs/basehub.js, line 188

#### waitForDeviceByType(deviceType) → {Promise}

Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

Note: If a device is never attached, the returned promise may never resolve.

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceType` | number | The device type to lookup.

Source:
  - hubs/basehub.js, line 230

### Events

#### attach

Emits when a device is attached to the Hub.

##### Parameters:

Name | Type | Description
--- | --- | ---
`device` | Device |

Source:
  - hubs/basehub.js, line 321

#### button

Emits when a button is pressed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`button` | string |
`state` | ButtonState |

Inherited From:
  - LPF2Hub#event:button
Source:
  - hubs/lpf2hub.js, line 182

#### detach

Emits when a device is detached from the Hub.

##### Parameters:

Name | Type | Description
--- | --- | ---
`device` | Device |

Source:
  - hubs/basehub.js, line 338

#### disconnect

Emits when the hub is disconnected.

Source:
  - hubs/basehub.js, line 81