-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (48 loc) · 1.6 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
'use strict';
//Include required packages and controller
const neeoapi = require('neeo-sdk');
const controller = require('./controller');
//Name for lock state label
const lockLabel = {
name: 'lockstate',
label: 'Locked',
isLabelVisible: true,
};
//Name for fuel label
const fuelLabel = {
name: 'fuel',
label: 'Fuel',
isLabelVisible: true,
};
//Name for battery label
const batteryLabel = {
name: 'battery',
label: 'Battery',
isLabelVisible: true,
};
//Name for heater label
const heaterLabel = {
name: 'heaterstate',
label: 'Heater',
isLabelVisible: true,
};
//Definitions for NEEO SDK
const VolcoVOC = neeoapi.buildDevice('On Call')
.setManufacturer('Volvo')
.addAdditionalSearchToken('car')
.setType('ACCESSORY')
// Components and capabilities for NEEO SDK
.addButton({ name: 'lock', label: 'Lock' })
.addButton({ name: 'unlock', label: 'Unlock' })
.addButton({ name: 'climaon', label: 'Clima ON' })
.addButton({ name: 'climaoff', label: 'Clima OFF' })
.addButtonHandler(controller.onButtonPressed)
.addTextLabel(lockLabel, (deviceId) => controller.getLockSensor(deviceId))
.addTextLabel(fuelLabel, (deviceId) => controller.getFuelSensor(deviceId))
.addTextLabel(batteryLabel, (deviceId) => controller.getBatterySensor(deviceId))
.addTextLabel(heaterLabel, (deviceId) => controller.getHeaterSensor(deviceId))
//Register suscription which is required for notifications to NEEO Brain (auto update of sensor values)
.registerSubscriptionFunction((...args) =>
controller.setNotificationCallbacks(...args)
)
module.exports = VolcoVOC;