# Class: Hub

## Hub

#### new Hub()

  Source:
    - hub.js, line 14

### Extends

- EventEmitter

### Members

#### <readonly> batteryLevel

  ##### Properties:

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

  Source:
    - hub.js, line 72

#### <readonly> current

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `current` | number | Current usage of the hub (Milliamps)

  Source:
    - hub.js, line 86

#### <readonly> firmwareVersion

  ##### Properties:

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

  Source:
    - hub.js, line 51

#### <readonly> name

  ##### Properties:

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

  Source:
    - hub.js, line 44

#### <readonly> rssi

  ##### Properties:

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

  Source:
    - hub.js, line 65

#### <readonly> uuid

  ##### Properties:

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

  Source:
    - hub.js, line 58

#### <readonly> voltage

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `voltage` | number | Voltage of the hub (Volts)

  Source:
    - hub.js, line 79

### Methods

#### connect()

  Connect to the Hub.

  Source:
    - hub.js, line 89

  ##### Returns:

  Resolved upon successful connect.

  Type
    Promise

#### disconnect()

  Disconnect the Hub.

  Source:
    - hub.js, line 107

  ##### Returns:

  Resolved upon successful disconnect.

  Type
    Promise

#### getHubType()

  Get the hub type.

  Source:
    - hub.js, line 172

  ##### Returns:

  Type
    HubType

#### getPortDeviceType(port)

  Get the device type for a given port.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Source:
    - hub.js, line 180

  ##### Returns:

  Type
    DeviceType

#### sleep(delay)

  Sleep a given amount of time.

  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:
    - hub.js, line 148

  ##### Returns:

  Resolved after the delay is finished.

  Type
    Promise

#### subscribe(port [, mode])

  Subscribe to sensor notifications on a given port.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `port` | string |  |
  `mode` | number | <optional> | The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.

  Source:
    - hub.js, line 116

  ##### Returns:

  Resolved upon successful issuance of command.

  Type
    Promise

#### unsubscribe(port)

  Unsubscribe to sensor notifications on a given port.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Source:
    - hub.js, line 134

  ##### Returns:

  Resolved upon successful issuance of command.

  Type
    Promise

#### wait(commands)

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

  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:
    - hub.js, line 161

  ##### Returns:

  Resolved after the commands are finished.

  Type
    Promise

### Events

#### attach

  Emits when a motor or sensor is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |
  `type` | DeviceType |

  Source:
    - hub.js, line 217

#### detach

  Emits when an attached motor or sensor is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Source:
    - hub.js, line 229

#### Search results