forked from bitfocus/companion-module-template-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (47 loc) · 1.03 KB
/
main.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
const { InstanceBase, Regex, runEntrypoint, InstanceStatus } = require('@companion-module/base')
const UpgradeScripts = require('./upgrades')
const UpdateActions = require('./actions')
const _ = require('lodash');
const superagent = require('superagent');
class ModuleInstance extends InstanceBase {
constructor(internal) {
super(internal)
}
async init(config) {
this.config = config
//todo connect to the API first
this.updateStatus(InstanceStatus.Ok)
this.updateActions() // export actions
}
// When module gets deleted
async destroy() {
this.log('debug', 'destroy')
}
async configUpdated(config) {
this.config = config
}
// Return config fields for web config
getConfigFields() {
return [
{
type: 'textinput',
id: 'host',
label: 'IP',
width: 8,
regex: Regex.IP,
},
{
type: 'textinput',
id: 'port',
label: 'Port',
width: 4,
regex: Regex.PORT,
default : '8001'
},
]
}
updateActions() {
UpdateActions(this)
}
}
runEntrypoint(ModuleInstance, UpgradeScripts)