npm.io
1.2.5 • Published 6 years ago

@haum/device

Licence
MIT
Version
1.2.5
Deps
1
Size
3 kB
Vulns
0
Weekly
0

Haum Device

Example

const device = require('@haum/device')

// Create a new device
const myDevice = device('myDevice')

// Let others discover the device
myDevice.discovery({
  items: {
    myItem: {
      type: 'string'
    }
  }
})

// Listen for change requests and emit new state
myDevice.item('myItem').on('change', value => {
  console.log('CHANGE:', value)
  myDevice.item('myItem').emit('state', msg)
})

// Does the same as above
myDevice.on('myItem', 'change', value => {
  console.log('CHANGE:', value)
  myDevice.emit('myItem', 'state', msg)
})