-
Notifications
You must be signed in to change notification settings - Fork 8
/
upgrades.js
117 lines (109 loc) · 2.45 KB
/
upgrades.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
import { CreateConvertToBooleanFeedbackUpgradeScript } from '@companion-module/base'
export const UpgradeScripts = [
function(context, props) {
const result = {
updatedConfig: null,
updatedActions: [],
updatedFeedbacks: [],
}
if (props.config) {
if (props.config.pollTime == undefined || '' == props.config.pollTime) {
props.config.pollTime = 10
result.updatedConfig = props.config
}
}
for (let action of props.actions) {
let changed = false
switch (action.actionId) {
case 'powerOn':
{
action.actionId = 'powerState'
action.options.opt = '1'
changed = true
}
break
case 'powerOff':
{
action.actionId = 'powerState'
action.options.opt = '0'
changed = true
}
break
case 'shutterOpen':
{
action.actionId = 'muteState'
action.options.opt = '30'
changed = true
}
break
case 'shutterClose':
{
action.actionId = 'muteState'
action.options.opt = '31'
changed = true
}
break
case 'freeze':
{
action.actionId = 'freezeState'
action.options.opt = '1'
changed = true
}
break
case 'unfreeze':
{
action.actionId = 'freezeState'
action.options.opt = '0'
changed = true
}
break
}
if (changed) {
result.updatedActions.push(action)
}
}
return result
},
function (context,props) { // was broken in original upgradescipts
const result = {
updatedConfig: null,
updatedActions: [],
updatedFeedbacks: [],
}
return result
},
function (context, props) {
const result = {
updatedConfig: null,
updatedActions: [],
updatedFeedbacks: [],
}
for (let action of props.actions) {
let changed = false
if ('muteState' == action.actionId) {
if (action.options.opt.length == 2) {
action.options.opt = action.options.opt.slice(1, 2)
action.options.item = action.options.opt.slice(0, 1)
changed = true
} else if (action.options.item == undefined) {
action.options.item = '3'
changed = true
}
}
if (changed) {
result.updatedActions.push(action)
}
}
for (let fb of props.feedbacks) {
if ('muteState' == fb.feedbackId) {
if (fb.options.muteState) {
fb.options.item = fb.options.muteState.slice(0, 1)
fb.options.opt = fb.options.muteState.slice(1, 2)
}
delete fb.options.muteState
result.updatedFeedbacks.push(fb)
}
}
return result
}
]