1.0.5 • Published 2 months ago

shellies-ds9 v1.0.5

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 months ago

node-shellies-ds9

npm-version

Handles communication with the next generation of Shelly devices. This Package is only to pimp up the existing package https://badgen.net/npm/v/shellies-ng. Because I'm lost if my Minis don't run in the Homebridge. If Alex creates a new version of his package that supports the Mini devices, I will delete this package again. thx@sw-koenig...

For the first generation, see node-shellies.

Supported devices

1 Support for outbound websockets is a work in progress.

Basic usage example

import {
  Device,
  DeviceId,
  MdnsDeviceDiscoverer,
  Shellies,
  ShellyPlus1,
} from 'shellies-ds9';

const shellies = new Shellies();

// handle discovered devices
shellies.on('add', async (device: Device) => {
  console.log(`${device.modelName} discovered`);
  console.log(`ID: ${device.id}`);

  // use instanceof to determine the device model
  if (device instanceof ShellyPlus1) {
    const plus1 = device as ShellyPlus1;

    // toggle the switch
    await plus1.switch0.toggle();
  }
});

// handle asynchronous errors
shellies.on('error', (deviceId: DeviceId, error: Error) => {
  console.error('An error occured:', error.message);
});

// create an mDNS device discoverer
const discoverer = new MdnsDeviceDiscoverer();
// register it
shellies.registerDiscoverer(discoverer);
// start discovering devices
discoverer.start();

See homebridge-shelly-ng for a real-world example.

1.0.5

2 months ago

1.0.4

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.3

5 months ago

1.0.0

5 months ago

0.9.9

5 months ago

0.9.8

5 months ago

0.9.7

5 months ago

0.9.6

5 months ago

0.9.5

5 months ago

0.9.4

6 months ago

0.9.3

6 months ago

0.9.2

6 months ago

0.9.1

6 months ago

0.9.0

6 months ago