Skip to content

Commit

Permalink
Merge pull request #3 from peternewman/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
peternewman authored Aug 27, 2024
2 parents 0583f0b + 3c801bf commit 620eadd
Show file tree
Hide file tree
Showing 9 changed files with 707 additions and 170 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ jobs:
- name: prettier
run: |
yarn prettier --check .
# - name: Test jest
# run: |
# yarn test
# env:
# CI: true
# - name: Test jest
# run: |
# yarn test
# env:
# CI: true
- name: Test package
run: |
yarn companion-module-build
env:
CI: true
- name: Save artifact
uses: actions/upload-artifact@v4
with:
name: module
path: ${{github.workspace}}/pkg.tgz
31 changes: 22 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ class cuezAutomatorInstance extends InstanceBase {
...api,
})

this.INTERVAL = null //used to poll for updates

this.DATA = {
appInfo: [],
appState: [],
project: [],
rundowns: [],
episode: [],
items: [],
buttons: [],
shortcuts: [],
keys: [],
macros: [],
timers: [],
}

this.CHOICES_PROJECTS = []
this.CHOICES_RUNDOWNS = []
this.CHOICES_ITEMS = []
this.CHOICES_DECK_BUTTONS = []
this.CHOICES_DECK_SWITCHES = []
this.CHOICES_SHORTCUTS = []
Expand All @@ -43,11 +50,6 @@ class cuezAutomatorInstance extends InstanceBase {

async destroy() {
let self = this

if (self.INTERVAL) {
clearInterval(self.INTERVAL)
self.INTERVAL = null
}
}

async init(config) {
Expand All @@ -62,14 +64,25 @@ class cuezAutomatorInstance extends InstanceBase {
}

this.initConnection()
this.initWebSocket()

this.initActions()
this.initFeedbacks()
this.initVariables()
this.initPresets()

this.checkFeedbacks()
this.checkVariables()
}

maybeReconnect() {
if (this.isInitialized) {
if (this.reconnect_timer) {
clearTimeout(this.reconnect_timer)
}
this.reconnect_timer = setTimeout(() => {
this.initWebSocket()
}, 5000)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"prettier": "@companion-module/tools/.prettierrc.json",
"dependencies": {
"@companion-module/base": "~1.10.0",
"node-rest-client": "^3.1.1"
"node-rest-client": "^3.1.1",
"ws": "^8.17.1"
},
"devDependencies": {
"@companion-module/tools": "^1.5.1",
Expand Down
93 changes: 80 additions & 13 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ module.exports = {
name: 'Next',
options: [],
callback: async function (action) {
self.sendCommand('trigger', 'next')
self.sendCommand('GET', 'trigger', 'next')
},
}

actions.previous = {
name: 'Previous',
options: [],
callback: async function (action) {
self.sendCommand('trigger', 'previous')
self.sendCommand('GET', 'trigger', 'previous')
},
}

actions.next_trigger = {
name: 'Next Trigger',
options: [],
callback: async function (action) {
self.sendCommand('trigger', 'nextTrigger')
self.sendCommand('GET', 'trigger', 'nextTrigger')
},
}

actions.previous_trigger = {
name: 'Previous Trigger',
options: [],
callback: async function (action) {
self.sendCommand('trigger', 'previous')
self.sendCommand('GET', 'trigger', 'previousTrigger')
},
}

Expand All @@ -48,7 +48,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'button', opt.button)
self.sendCommand('GET', 'trigger', 'button', opt.button)
},
}

Expand All @@ -65,7 +65,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'button', opt.switch, 'on')
self.sendCommand('GET', 'trigger', 'button', opt.switch, 'on')
},
}

Expand All @@ -82,7 +82,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'button', opt.switch, 'off')
self.sendCommand('GET', 'trigger', 'button', opt.switch, 'off')
},
}

Expand All @@ -99,7 +99,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'button', opt.switch, 'click')
self.sendCommand('GET', 'trigger', 'button', opt.switch, 'click')
},
}

Expand All @@ -116,7 +116,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'shortcut', opt.shortcut)
self.sendCommand('GET', 'trigger', 'shortcut', opt.shortcut)
},
}

Expand All @@ -134,7 +134,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('macro', '', opt.macro)
self.sendCommand('GET', 'macro', '', opt.macro)
},
}*/

Expand All @@ -151,7 +151,7 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('timer', 'start', opt.timer)
self.sendCommand('GET', 'timer', 'start', opt.timer)
},
}

Expand All @@ -168,15 +168,82 @@ module.exports = {
],
callback: async function (action) {
let opt = action.options
self.sendCommand('timer', 'stop', opt.timer)
self.sendCommand('GET', 'timer', 'stop', opt.timer)
},
}

actions.stop_all_timers = {
name: 'Stop All Timers',
options: [],
callback: async function (action) {
self.sendCommand('timer', 'stop')
self.sendCommand('GET', 'timer', 'stop')
},
}

actions.select_project = {
name: 'Select Project',
options: [
{
type: 'dropdown',
label: 'Project',
id: 'project',
choices: self.CHOICES_PROJECTS,
default: self.CHOICES_PROJECTS.length > 0 ? self.CHOICES_PROJECTS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('PATCH', 'project', opt.project, 'select')
},
}

actions.unload_episode = {
name: 'Unload Episode',
options: [],
callback: async function (action) {
self.sendCommand('DELETE', 'episode')
},
}

actions.select_episode = {
name: 'Select Episode',
options: [
{
type: 'dropdown',
label: 'Episode',
id: 'episode',
choices: self.CHOICES_RUNDOWNS,
default: self.CHOICES_RUNDOWNS.length > 0 ? self.CHOICES_RUNDOWNS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('PATCH', 'episode', opt.episode, 'select')
},
}

actions.trigger_block = {
name: 'Trigger Item',
options: [
{
type: 'dropdown',
label: 'Item',
id: 'block',
choices: self.CHOICES_ITEMS,
default: self.CHOICES_ITEMS.length > 0 ? self.CHOICES_ITEMS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('GET', 'trigger', 'block', opt.block)
},
}

actions.trigger_first_block = {
name: 'Trigger First Item',
options: [],
callback: async function (action) {
self.sendCommand('GET', 'trigger', 'block', self.CHOICES_ITEMS.length > 0 ? self.CHOICES_ITEMS[0].id : '')
},
}

Expand Down
Loading

0 comments on commit 620eadd

Please sign in to comment.