1.2.5 • Published 4 years ago
@haum/device v1.2.5
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)
})