-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
45 lines (37 loc) · 961 Bytes
/
test.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
const Miakapi = require('./main');
const credentials = require('./miakapiCredentials.json');
const home = Miakapi(
credentials.home,
credentials.coordID,
credentials.coordSecret,
);
console.log('Connecting...');
home.onReady(() => {
console.log('Ready !', home);
home.users.forEach((user) => {
console.log('Sending notification to', user.displayName);
user.sendPush({
title: 'Notification test 1',
body: 'Test user.sendPush',
tag: 'test1',
});
home.sendNotif(user.id, {
title: 'Notification test 2',
body: 'Test home.sendNotif',
tag: 'test2',
});
});
});
home.onUpdate((users) => {
console.log('Home update !', users);
});
home.onUserAction((action) => {
console.log('User action :', action);
});
setInterval(() => {
home.variables.timestamp = Date.now();
home.commit({
'global.timestamp': Date.now(),
'global.invert': !home.variables['global.invert'],
});
}, 5000);