generated from bitfocus/companion-module-template-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·84 lines (73 loc) · 1.54 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { InstanceBase, Regex, runEntrypoint, InstanceStatus } from '@companion-module/base'
import { UpgradeScripts } from './upgrades.js'
import { UpdateActions } from './actions.js'
import { UpdateVariableDefinitions } from './variables.js'
import { Presets } from './presets.js'
import fetch from 'node-fetch'
class ModuleInstance extends InstanceBase {
constructor(internal) {
super(internal)
}
async init(config) {
this.config = config
this.updateStatus(InstanceStatus.Ok)
this.updateActions() // export actions
this.updateVariableDefinitions() // export variable definitions
this.initPresets()
}
// 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: 'Camera IP',
width: 8,
regex: Regex.IP,
},
{
type: 'number',
id: 'port',
label: 'Web UI Port',
width: 4,
default: 80,
min: 1,
max: 65535,
},
{
type: 'textinput',
id: 'user',
label: 'Username',
width: 12,
default: 'admin',
},
{
type: 'textinput',
id: 'password',
label: 'Password',
width: 12,
default: 'admin',
},
]
}
updateActions() {
UpdateActions(this)
}
updateFeedbacks() {
UpdateFeedbacks(this)
}
updateVariableDefinitions() {
UpdateVariableDefinitions(this)
}
initPresets() {
this.setPresetDefinitions(Presets())
}
}
runEntrypoint(ModuleInstance, UpgradeScripts)