generated from bitfocus/companion-module-template-js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
feedbacks.js
133 lines (132 loc) · 3.3 KB
/
feedbacks.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const { combineRgb } = require('@companion-module/base')
module.exports = async function (self) {
self.setFeedbackDefinitions({
PowerState: {
name: 'Tv Power State',
type: 'boolean',
label: 'Tv Power State',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [
{
type: 'dropdown',
label: 'On/Off',
id: 'power',
default: true,
choices: [{ label: 'Power On', id: true }, { label: 'Power Off', id: false }]
}
],
callback: (feedback) => {
// This callback will be called whenever companion wants to check if this feedback is 'active' and should affect the button style
try {
if (self.getVariableValue('power_state') == feedback.options.power) {
return true
} else {
return false
}
} catch (error) {
self.log('error', 'Feedback error: ' + error.message)
return false
}
},
},
MuteState: {
name: 'Tv Mute State',
type: 'boolean',
label: 'Tv Mute State',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [
{
type: 'dropdown',
label: 'On/Off',
id: 'mute',
default: false,
choices: [{ label: 'Mute On', id: true }, { label: 'Mute Off', id: false }]
}
],
callback: (feedback) => {
// This callback will be called whenever companion wants to check if this feedback is 'active' and should affect the button style
try {
if (self.getVariableValue('volume_muted') == feedback.options.mute) {
return true
} else {
return false
}
} catch (error) {
console.log('Feedback Error:', error)
self.log('error', 'Feedback error: ' + error.message)
return false
}
},
},
VolumeState: {
name: 'Tv Volume State',
type: 'boolean',
label: 'Tv Volume State',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [
{
id: 'volumeLevel',
type: 'number',
label: 'Volume Level',
default: 0,
min: 0,
max: 100
}
],
callback: (feedback) => {
// This callback will be called whenever companion wants to check if this feedback is 'active' and should affect the button style
try {
if (self.getVariableValue('volume_level') == feedback.options.volumeLevel) {
return true
} else {
return false
}
} catch (error) {
console.log('Feedback Error:', error)
self.log('error', 'Feedback error: ' + error.message)
return false
}
},
},
CurrentApp: {
name: 'Current App',
type: 'boolean',
label: 'Current App',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [
{
type: 'textinput',
label: 'App ID',
id: 'current_app',
default: '',
tooltip: 'ex. https://www.netflix.com/title/80057281'
}
],
callback: (feedback) => {
// This callback will be called whenever companion wants to check if this feedback is 'active' and should affect the button style
try {
if (self.getVariableValue('current_app_state') == feedback.options.current_app) {
return true
} else {
return false
}
} catch (error) {
self.log('error', 'Feedback error: ' + error.message)
return false
}
},
},
})
}