-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (32 loc) · 932 Bytes
/
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
import {Plugin} from 'lisa-plugin'
import {createRequire} from 'module';
import config from './config/index.js';
import drivers from './drivers/index.js';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
export default class IRPlugin extends Plugin {
interact(action, infos) {
const device = infos.fields.device
if (device && device.pluginName !== this.fullName) {
return Promise.resolve()
}
switch (action) {
case 'DEVICE_TURN_ON':
return this.drivers['ir'].setDeviceValue(device)
case 'SEND_IR_COMMAND':
if (device) {
return this.drivers['ir'].setDeviceValue(device)
}
return this.drivers['ir'].setDeviceValue(null, infos.fields.remote, infos.fields.action)
default:
return Promise.resolve()
}
}
constructor(app) {
super(app, {
drivers: drivers,
pkg: pkg,
config: config,
})
}
}