Skip to content

Commit

Permalink
Initial version of Tinkerlist's Cuez Automator control
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewman committed Jun 16, 2024
1 parent 6c1374e commit 83049b7
Show file tree
Hide file tree
Showing 12 changed files with 2,682 additions and 976 deletions.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
The MIT License

Copyright (c) 2024 Peter Newman
Copyright (c) 2020-2023 Joseph Adams

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# companion-module-sony-bravia
# companion-module-tinkerlist-cuez-automator

See [HELP.md](./companion/HELP.md) and [LICENSE](./LICENSE)

The main code is inherited from companion-module-sony-bravia and then customized for the TinkerList Cuez Automator API.
24 changes: 3 additions & 21 deletions companion/HELP.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
## Sony Bravia
## TinkerList Cuez Automator

This module will allow you to control Sony Bravia TVs such as the FWD-65X950G.
This module will allow you to control TinkerList's Cuez Automator.

### Configuration

- The remote device must be configured to use a PSK.
- The module makes HTTP requests over port 80.
- The module makes HTTP requests over port 7070.

### To use the module

Add an action to a button and choose the action you wish to use.

**Available Actions:**

- Power On
- Power Off
- Volume Up
- Volume Down
- Volume Mute
- Volume Unmute
- Change External Input

**Available Feedbacks:**

- Power State
- Current Input
- Mute State

**Available Variables:**

- Power State
- Current Input
- Mute State
- Volume Level
19 changes: 9 additions & 10 deletions companion/manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"id": "sony-bravia",
"name": "sony-bravia",
"shortname": "sony-bravia",
"id": "tinkerlist-cuez-automator",
"name": "tinkerlist-cuez-automator",
"shortname": "cuez-automator",
"description": "",
"version": "0.0.0",
"license": "MIT",
"repository": "git+https://github.com/bitfocus/companion-module-sony-bravia.git",
"bugs": "https://github.com/bitfocus/companion-module-sony-bravia/issues",
"repository": "git+https://github.com/bitfocus/companion-module-tinkerlist-cuez-automator.git",
"bugs": "https://github.com/bitfocus/companion-module-tinkerlist-cuez-automator/issues",
"maintainers": [
{
"name": "Joseph Adams",
"email": "[email protected]"
"name": "Peter Newman"
}
],
"legacyIds": [],
Expand All @@ -20,7 +19,7 @@
"apiVersion": "0.0.0",
"entrypoint": "../index.js"
},
"manufacturer": "Sony",
"products": ["Bravia"],
"keywords": ["TV"]
"manufacturer": "TinkerList",
"products": ["Cuez - Automator"],
"keywords": ["Running Order"]
}
26 changes: 12 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Sony-Bravia
// TinkerList-Cuez-Automator

const { InstanceBase, InstanceStatus, runEntrypoint } = require('@companion-module/base')
const UpgradeScripts = require('./src/upgrades')
Expand All @@ -11,7 +11,7 @@ const presets = require('./src/presets')

const api = require('./src/api')

class braviaInstance extends InstanceBase {
class cuezAutomatorInstance extends InstanceBase {
constructor(internal) {
super(internal)

Expand All @@ -28,19 +28,17 @@ class braviaInstance extends InstanceBase {
this.INTERVAL = null //used to poll for updates

this.DATA = {
powerState: false,
volumeLevel: 0,
muteState: false,
input: '',
inputs: [],
buttons: [],
shortcuts: [],
macros: [],
timers: [],
}

this.CHOICES_INPUTS = [
{ id: 'extInput:component?port=1', label: 'Component 1' },
{ id: 'extInput:component?port=2', label: 'Component 2' },
{ id: 'extInput:hdmi?port=1', label: 'HDMI 1' },
{ id: 'extInput:hdmi?port=2', label: 'HDMI 2' },
]
this.CHOICES_DECK_BUTTONS = []
this.CHOICES_DECK_SWITCHES = []
this.CHOICES_SHORTCUTS = []
this.CHOICES_MACROS = []
this.CHOICES_TIMERS = []
}

async destroy() {
Expand Down Expand Up @@ -75,4 +73,4 @@ class braviaInstance extends InstanceBase {
}
}

runEntrypoint(braviaInstance, UpgradeScripts)
runEntrypoint(cuezAutomatorInstance, UpgradeScripts)
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "sony-bravia",
"version": "2.0.2",
"name": "tinkerlist-cuez-automator",
"version": "3.0.0",
"main": "index.js",
"scripts": {
"format": "prettier -w .",
"test": "jest --silent=false"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bitfocus/companion-module-sony-bravia.git"
"url": "git+https://github.com/bitfocus/companion-module-tinkerlist-cuez-automator.git"
},
"license": "MIT",
"prettier": "@companion-module/tools/.prettierrc.json",
Expand Down
185 changes: 136 additions & 49 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,93 +3,180 @@ module.exports = {
let self = this
let actions = {}

actions.power_on = {
name: 'Power On',
actions.next = {
name: 'Next',
options: [],
callback: async function (action) {
let params = { status: true }
self.sendCommand('system', 'setPowerStatus', params)
self.sendCommand('trigger', 'next')
},
}

actions.power_off = {
name: 'Power Off',
actions.previous = {
name: 'Previous',
options: [],
callback: async function (action) {
let params = { status: false }
self.sendCommand('system', 'setPowerStatus', params)
self.sendCommand('trigger', 'previous')
},
}

actions.volume_up = {
name: 'Volume Up',
actions.next_trigger = {
name: 'Next Trigger',
options: [],
callback: async function (action) {
let params = { target: 'speaker', volume: '+1' }
self.sendCommand('audio', 'setAudioVolume', params)
self.sendCommand('trigger', 'nextTrigger')
},
}

actions.volume_down = {
name: 'Volume Down',
actions.previous_trigger = {
name: 'Previous Trigger',
options: [],
callback: async function (action) {
let params = { target: 'speaker', volume: '-1' }
self.sendCommand('audio', 'setAudioVolume', params)
self.sendCommand('trigger', 'previous')
},
}

actions.volume_mute = {
name: 'Volume Mute',
options: [],
actions.trigger_deck_button = {
name: 'Trigger Deck Button',
options: [
{
type: 'dropdown',
label: 'Button',
id: 'button',
choices: self.CHOICES_DECK_BUTTONS,
default: self.CHOICES_DECK_BUTTONS.length > 0 ? self.CHOICES_DECK_BUTTONS[0].id : '',
},
],
callback: async function (action) {
let params = { status: true }
self.sendCommand('audio', 'setAudioMute', params)
let opt = action.options
self.sendCommand('trigger', 'button', opt.button)
},
}

actions.volume_unmute = {
name: 'Volume Unmute',
options: [],
actions.trigger_deck_switch_on = {
name: 'Trigger Deck Switch On',
options: [
{
type: 'dropdown',
label: 'Switch',
id: 'switch',
choices: self.CHOICES_DECK_SWITCHES,
default: self.CHOICES_DECK_SWITCHES.length > 0 ? self.CHOICES_DECK_SWITCHES[0].id : '',
},
],
callback: async function (action) {
let params = { status: false }
self.sendCommand('audio', 'setAudioMute', params)
let opt = action.options
self.sendCommand('trigger', 'button', opt.switch, 'on')
},
}

actions.change_external_input = {
name: 'Change External Input',
actions.trigger_deck_switch_off = {
name: 'Trigger Deck Switch Off',
options: [
{
type: 'dropdown',
label: 'Kind',
id: 'kind',
choices: [
{ id: 'hdmi', label: 'HDMI' },
// TODO(Someone): Add CEC, but the URI has a type and port is optional
{ id: 'component', label: 'Component' },
{ id: 'composite', label: 'Composite' },
{ id: 'scart', label: 'SCART' },
{ id: 'widi', label: 'Wi-Fi Display' },
],
label: 'Switch',
id: 'switch',
choices: self.CHOICES_DECK_SWITCHES,
default: self.CHOICES_DECK_SWITCHES.length > 0 ? self.CHOICES_DECK_SWITCHES[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'button', opt.switch, 'off')
},
}

actions.trigger_deck_switch_click = {
name: 'Trigger Deck Switch Click',
options: [
{
type: 'dropdown',
label: 'Switch',
id: 'switch',
choices: self.CHOICES_DECK_SWITCHES,
default: self.CHOICES_DECK_SWITCHES.length > 0 ? self.CHOICES_DECK_SWITCHES[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('trigger', 'button', opt.switch, 'click')
},
}

actions.trigger_shortcut = {
name: 'Trigger Shortcut',
options: [
{
type: 'dropdown',
label: 'Port',
id: 'port',
choices: [
{ id: '1', label: '1' },
{ id: '2', label: '2' },
{ id: '3', label: '3' },
{ id: '4', label: '4' },
],
label: 'Shortcut',
id: 'shortcut',
choices: self.CHOICES_SHORTCUTS,
default: self.CHOICES_SHORTCUTS.length > 0 ? self.CHOICES_SHORTCUTS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
let uri = 'extInput:' + opt.kind + '?port=' + opt.port
let params = { uri: uri }
self.sendCommand('avContent', 'setPlayContent', params)
self.sendCommand('trigger', 'shortcut', opt.shortcut)
},
}

// TODO(Peter): Retest on later automator
/*actions.fire_macro = {
name: 'Fire Macro',
options: [
{
type: 'dropdown',
label: 'Macro',
id: 'macro',
choices: self.CHOICES_MACROS,
default: self.CHOICES_MACROS.length > 0 ? self.CHOICES_MACROS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('macro', '', opt.macro)
},
}*/

actions.start_timer = {
name: 'Start Timer',
options: [
{
type: 'dropdown',
label: 'Timer',
id: 'timer',
choices: self.CHOICES_TIMERS,
default: self.CHOICES_TIMERS.length > 0 ? self.CHOICES_TIMERS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('timer', 'start', opt.timer)
},
}

actions.stop_timer = {
name: 'Stop Timer',
options: [
{
type: 'dropdown',
label: 'Timer',
id: 'timer',
choices: self.CHOICES_TIMERS,
default: self.CHOICES_TIMERS.length > 0 ? self.CHOICES_TIMERS[0].id : '',
},
],
callback: async function (action) {
let opt = action.options
self.sendCommand('timer', 'stop', opt.timer)
},
}

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

Expand Down
Loading

0 comments on commit 83049b7

Please sign in to comment.