Handles communication with Shelly devices, using both CoAP and HTTP.
- Automatically detects Shelly devices (on the same network and subnet).
- Automatically detects when the status of a device changes, such as when a relay is turned on or off.
- Keeps track of devices and if they go offline (because no status update has been received in a given amount of time).
Currently the following Shelly devices are supported:
const shellies = require('shellies')
shellies.on('discover', device => {
// a new device has been discovered
console.log('Discovered device with ID', device.id, 'and type', device.type)
device.on('change', (prop, newValue, oldValue) => {
// a property on the device has changed
console.log(prop, 'changed from', oldValue, 'to', newValue)
})
device.on('offline', () => {
// the device went offline
console.log('Device with ID', device.id, 'went offline')
})
})
// start discovering devices and listening for status updates
shellies.start()