-
Notifications
You must be signed in to change notification settings - Fork 6
/
client.js
48 lines (38 loc) · 1014 Bytes
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
require('colors')
var iKettle = require('./index')
var ikettle = new iKettle()
ikettle.on('boiling', function() {
console.log('Kettle is boiling'.green)
ikettle.setTemperature(100, function(error) {
if (error) {
console.log(error.red)
process.exit(1)
}
ikettle.off()
})
})
ikettle.on('off', function() {
console.log('Kettle is off'.red)
})
ikettle.on('boiled', function() {
console.log('Kettle has boiled'.rainbow)
})
ikettle.on('removed', function() {
console.log('Kettle removed from base'.red)
})
ikettle.on('overheat', function() {
console.log('Kettle has overheated'.red)
})
ikettle.on('keep-warm-expired', function() {
console.log('Keep warm period has expired'.red)
})
ikettle.discover(function(error, success) {
if (error) {
console.log('Could not get kettle connection'.red, error.red)
process.exit(1)
}
ikettle.getStatus(function(error, status) {
ikettle.boil()
})
})