Homey Apps SDK
📖 Apps SDK Reference🌍 Web API🛠 Developer Tools
  • Welcome to the Apps SDK documentation 👋
  • The Basics
    • Getting Started
      • Homey CLI
    • App
      • Manifest
      • Internationalization
      • Permissions
      • Persistent Storage
    • Drivers & Devices
      • Pairing
        • System Views
          • Devices List
          • Add Devices
          • OAuth2 Login
          • Credentials Login
          • Pincode
          • Loading
          • Done
        • Custom Views
      • Capabilities
      • Energy
      • Settings
      • Best practices
        • Lights
        • Window coverings
        • Battery status
    • Flow
      • Arguments
      • Tokens
    • Widgets
      • Settings
      • Styling
      • Debugging
  • Wireless
    • Wi-Fi
      • Discovery
    • Bluetooth LE
    • Z-Wave
    • Zigbee
    • 433 MHz
    • Infrared
    • Matter
  • Cloud
    • OAuth2
    • Webhooks
  • App Store
    • Publishing
    • Guidelines
    • Verified Developer
    • Updating
  • Advanced
    • Custom Views
      • App Settings
      • Custom Pairing Views
      • HTML & CSS Styling
    • Web API
    • Images
    • LED Ring
    • Homey Compose
  • Guides
    • Homey Cloud
    • Breaking Changes
    • Tools
      • Bluetooth LE
      • Zigbee
      • TypeScript
    • Using ESM in Homey Apps
  • Upgrade Guides
    • Homey v6.0.0
    • Upgrading to SDK v3
      • Zigbee Apps
    • Device Capabilities
Powered by GitBook
On this page
  • BLE Notifications
  • Disconnect event
  • Addressed BLE caching issues
  • (Deprecation) 128bit UUID convention

Was this helpful?

  1. Upgrade Guides

Homey v6.0.0

How to upgrade to Homey v6.0.0

Homey v6.0.0 adds several updates to the Bluetooth Low Energy (BLE) SDK. Besides adding support for BLE notifications, also several bug fixes have been applied. With the changes in this update it will be much easier to create BLE apps for Homey.

No breaking changes are present in this update - BLE apps that worked on Homey v5.0.0 will keep working on Homey v6.0.0

BLE Notifications

The code snippet below shows an example of how to use Bluetooth Notifications in your app:

// Subscribe to notifications
await characteristic.subscribeToNotifications((data) => {
  this.log("I received a notification: ", data);
});

// Wait for 5 seconds
await wait(5000);

// Unsubscribe from the notifications
await characteristic.unsubscribeFromNotifications();

Disconnect event

Homey v6.0.0 reintroduces the 'disconnect' event. This method can be especially useful when used together with BLE notifications. The disconnect event is not always emitted when a device is disconnected, for example by turning it off, it is emitted whenever Homey knows that it is disconnected. This behaviour occurs from the fact that BLE devices may turn off their radio's while maintaining an active connection.

// Register a callback for when the peripheral disconnects
peripheral.on("disconnect", () => {
  this.log("Disconnected from peripheral: ", peripheral.uuid);
});

The disconnect event is not guaranteed to trigger on each disconnect. But if it does trigger then it is guaranteed that the peripheral is disconnected.

Addressed BLE caching issues

The previous versions of the Bluetooth Low Energy SDK contained some caching issues which have been resolved. Discovery results will be kept in cache for at least 30 seconds.

A peripheral will not automatically disconnect anymore after 60 seconds. It will stay connected until the app it is used by closes, or when the corresponding device is removed by the user, or until peripheral.disconnect() is explicitly called.

The connection status of a peripheral is assumed to stay the same until the SDK receives an indication that suggests otherwise - therefore the peripheral.state may be incorrectly indicating a connected state when a device silently disconnects.

(Deprecation) 128bit UUID convention

A common practice in BLE is to use shortened UUID's for common services and characteristics. Generally, a UUID used in BLE has 128 bits. However, if the UUID is formatted like the base UUID it can be shortened to a 16bit uuid by using the 4th to the 8th hexadecimal only. For example:

// 128bit UUID
'0000ABCD-0000-1000-8000-00805F9B34FB'

// 16bit UUID (Deprecated)
'ABCD'

Starting from Homey v6.0.0 it has been decided that Homey will use long UUID's for all BLE device by default. The reason for this is to prevent confusion - and also to ensure that the SDK can give consistent results when used for different devices on different Homey models.

Short UUIDs are still supported and your current apps will keep working.

PreviousUsing ESM in Homey AppsNextUpgrading to SDK v3

Last updated 4 years ago

Was this helpful?