Skip to content

Commit

Permalink
Feat/bring up to date (#35)
Browse files Browse the repository at this point in the history
* default v2

* handle case where there is no current or next event

* fix: speaker msg -> timer msg same as ontime label

* add: *MessageVisible variables

* add: blink and blackout variable

* feat: Toggle/On/Off on all relevant actions

* update help

* feat: Load and start Cue action

* feat: Cue Now and Next variable

* feat: Better Add / remove action

* feat: feedback Time added or removed

* fix: rename delay to added

* update presets

* fix: case where message is undefined

* fix: speaker message -> timer message in feedback

* this timer message feedback

* fix SetTimerBlink action name

* drop v1 support

* use new addtime endpoint

* bump version
  • Loading branch information
alex-Arc authored Dec 8, 2023
1 parent 6161859 commit aa1b158
Show file tree
Hide file tree
Showing 18 changed files with 431 additions and 1,521 deletions.
95 changes: 53 additions & 42 deletions companion/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,36 @@ Actions related to time control
| Preset | Action |
| :----: | -------------------------------------------------------------------- |
|| Start selected event |
|| Start next event |
|| Start event with given ID |
|| Start event at given position |
|| Load event with given ID |
|| Load event at given position |
|| Start next event |
|| Start event with given ID |
|| Start event at given position |
|| Start event with cue |
|| Load event with given ID |
|| Load event at given position |
|| Load event with cue |
|| Pause running timer |
|| Stop running timer |
|| Reload selected event |
|| Select previous event |
|| Select next event |
|| Start [Roll Mode](https://cpvalente.gitbook.io/ontime/features/roll) |
|| Add / remove time (min) to running timer |
|| Toggle On Air |
|| Toggle Timer Blinking |
|| Toggle Timer Blackout |
|| Add / remove time to running timer |
|| Toggle/On/Off On Air |
|| Toggle/On/Off Timer Blinking |
|| Toggle/On/Off Timer Blackout |

### Messages Control

Actions related to realtime messages

| Preset | Action |
| :----: | :-------------------------------------------------------- |
| | Set message for Stage Timer view |
|| Toggle visibility of message for Speaker view (above) |
| | Set message for Public view |
|| Toggle visibility of message for Public view (above) |
| | Set message for Lower Third view |
|| Toggle visibility of message for Lower Third view (above) |
| Preset | Action |
| :----: | :--------------------------------------------------------------- |
| | Set message for Timer view |
|| Toggle/On/Off visibility of message for Timer view (above) |
| | Set message for Public view |
|| Toggle/On/Off visibility of message for Public view (above) |
| | Set message for Lower Third view |
|| Toggle/On/Off visibility of message for Lower Third view (above) |

### Ontime Feedback

Expand All @@ -64,38 +66,47 @@ Currently, feedbacks are configured to change colours of banks on the given cond
|| Timer is paused |
|| Timer is in Roll Mode |
|| Timer is in overtime |
|| Time added or removed |
|| Ontime is On Air |
|| Public Message Visibility |
|| Lower Thirds Message Visibility |
|| Speaker Message Visibility |
|| Timer Message Visibility |
|| This Timer Message Visibility |
|| Timer Blinking |
|| Timer Blackout |

### Variables

The following variables are made available in the module

| Variable Id | Description |
| :------------: | :---------------------------------------------- |
| time | Value of current timer (hh:mm:ss) |
| time_hm | Value of current timer (hh:mm) |
| time_h | Value of current timer (Hours) |
| time_m | Value of current timer (Minutes) |
| time_s | Value of current timer (Seconds) |
| clock | Clock (hh:mm:ss) |
| timer_start | Start of timer (hh:mm:ss) |
| timer_finish | Expected finish of timer (hh:mm:ss) |
| timer_delay | Current delay of timer |
| playstate | State of timer (Running, Paused, Stopped, Roll) |
| onair | If onAir is toggled on or off |
| titleNow | Title of current event |
| subtitleNow | Subitle of current event |
| speakerNow | Speaker of current event |
| noteNow | Note of current event |
| titleNext | Title of next timer |
| subtitleNext | Subitle of next event |
| speakerNext | Speaker of next event |
| noteNext | Note of next event |
| speakerMessage | Current speaker Message |
| publicMessage | Current public Message |
| lowerMessage | Current lower Thirds Message |
| Variable Id | Description |
| :------------------: | :---------------------------------------------- |
| time | Value of current timer (hh:mm:ss) |
| time_hm | Value of current timer (hh:mm) |
| time_h | Value of current timer (Hours) |
| time_m | Value of current timer (Minutes) |
| time_s | Value of current timer (Seconds) |
| clock | Clock (hh:mm:ss) |
| timer_start | Start of timer (hh:mm:ss) |
| timer_finish | Expected finish of timer (hh:mm:ss) |
| timer_added | Current added of timer |
| playstate | State of timer (Running, Paused, Stopped, Roll) |
| onair | If onAir is toggled on or off |
| titleNow | Title of current event |
| subtitleNow | Subitle of current event |
| speakerNow | Speaker of current event |
| noteNow | Note of current event |
| cueNow | Cue of current event |
| titleNext | Title of next timer |
| subtitleNext | Subitle of next event |
| speakerNext | Speaker of next event |
| noteNext | Note of next event |
| cueNext | Cue of next event |
| timerMessage | Current Timer Message |
| publicMessage | Current public Message |
| lowerMessage | Current lower Thirds Message |
| timerMessageVisible | Timer Message Visible |
| publicMessageVisible | Public Message Visible |
| lowerMessageVisible | Lower thirds Message Visible |
| timerBlink | Timer Blackout |
| timerBlackout | Timer Blinking |
2 changes: 1 addition & 1 deletion companion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "getontime-ontime",
"shortname": "ontime",
"description": "Companion module for ontime",
"version": "2.1.2",
"version": "3.0.0",
"license": "MIT",
"repository": "git+https://github.com/bitfocus/companion-module-getontime-ontime.git",
"bugs": "https://github.com/bitfocus/companion-module-getontime-ontime/issues",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "getontime-ontime",
"version": "2.3.0",
"version": "3.0.0",
"main": "/dist/index.js",
"license": "MIT",
"prettier": "@companion-module/tools/.prettierrc.json",
Expand Down
9 changes: 3 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function GetConfigFields(): SomeCompanionConfigField[] {
label: 'Information',
id: 'info',
type: 'static-text',
value: 'This module will establish a connection to the ontime server Version 1 and Version 2.8 upwards.',
value: 'This module will establish a connection to the ontime server Version 2.13 upwards.',
width: 12,
},
{
Expand All @@ -41,11 +41,8 @@ export function GetConfigFields(): SomeCompanionConfigField[] {
label: 'Ontime Version',
id: 'version',
type: 'dropdown',
default: 'v1',
choices: [
{ id: 'v1', label: 'Ontime V1' },
{ id: 'v2', label: 'Ontime V2' },
],
default: 'v2',
choices: [{ id: 'v2', label: 'Ontime V2' }],
width: 12,
tooltip: 'Choose wich version of Ontime you are connecting to.',
},
Expand Down
23 changes: 17 additions & 6 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ export enum ActionId {
StartSelect = 'startSelect',
StartIndex = 'startIndex',
StartNext = 'startNext',
StartCue = 'startCue',
LoadId = 'loadId',
LoadSelect = 'loadSelect',
LoadIndex = 'loadIndex',
LoadCue = 'loadCue',
Pause = 'pause',
Stop = 'stop',
Reload = 'reload',
Next = 'next',
Previous = 'previous',
Roll = 'roll',
Delay = 'delay',
Add = 'add',
SetOnAir = 'setOnAir',
SetSpeakerMessageVisibility = 'setSpeakerMessageVisibility',
SetSpeakerMessage = 'setSpeakerMessage',
SetTimerMessageVisibility = 'setTimerMessageVisibility',
SetTimerMessage = 'setTimerMessage',
SetPublicMessageVisibility = 'setPublicMessageVisibility',
SetPublicMessage = 'setPublicMessage',
SetLowerMessageVisibility = 'setLowerMessageVisibility',
Expand All @@ -31,8 +33,10 @@ export enum feedbackId {
ColorStopped = 'state_color_stopped',
ColorRoll = 'state_color_roll',
ColorNegative = 'timer_negative',
ColorAddRemove = 'state_color_add_remove',
OnAir = 'onAir',
SpeakerMessageVisible = 'speakerMessageVisible',
TimerMessageVisible = 'timerMessageVisible',
ThisTimerMessageVisible = 'thisTimerMessageVisible',
PublicMessageVisible = 'publicMessageVisible',
LowerMessageVisible = 'lowerMessageVisible',
TimerBlink = 'timerBlink',
Expand All @@ -44,7 +48,7 @@ export enum variableId {
Clock = 'clock',
TimerStart = 'timer_start',
TimerFinish = 'timer_finish',
TimerDelay = 'timer_delay',
TimerAdded = 'timer_added',
Time = 'time',
TimeHM = 'time_hm',
TimeH = 'time_h',
Expand All @@ -54,12 +58,19 @@ export enum variableId {
SubtitleNow = 'subtitleNow',
SpeakerNow = 'speakerNow',
NoteNow = 'noteNow',
CueNow = 'cueNow',
TitleNext = 'titleNext',
SubtitleNext = 'subtitleNext',
SpeakerNext = 'speakerNext',
NoteNext = 'noteNext',
CueNext = 'cueNext',
OnAir = 'onAir',
SpeakerMessage = 'speakerMessage',
TimerMessage = 'timerMessage',
PublicMessage = 'publicMessage',
LowerMessage = 'lowerMessage',
TimerMessageVisible = 'timerMessageVisible',
PublicMessageVisible = 'publicMessageVisible',
LowerMessageVisible = 'lowerMessageVisible',
TimerBlink = 'timerBlink',
TimerBlackout = 'timerBlackout',
}
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
CompanionFeedbackDefinitions,
} from '@companion-module/base'
import { OntimeConfig, GetConfigFields } from './config'
import { OntimeV1 } from './v1/ontimev1'
import { OntimeV2 } from './v2/ontimev2'
import { UpgradeScripts } from './upgrades'
export interface OntimeClient {
instance: OnTimeInstance

Expand All @@ -36,17 +36,20 @@ export class OnTimeInstance extends InstanceBase<OntimeConfig> {
this.states = {}

if (this.config.version !== 'v1' && this.config.version !== 'v2') {
this.config.version = 'v1'
this.config.version = 'v2'
this.config.refetchEvents = true
this.config.reconnect = true
this.config.reconnectInterval = 5
this.saveConfig(this.config)
}

if (this.config.version === 'v1') {
this.ontime = new OntimeV1(this)
this.updateStatus(InstanceStatus.BadConfig, 'V1 is no longer suported')
return
} else if (this.config.version === 'v2') {
this.ontime = new OntimeV2(this)
} else {
this.updateStatus(InstanceStatus.BadConfig, 'unknown version')
}

this.initConnection()
Expand All @@ -73,9 +76,12 @@ export class OnTimeInstance extends InstanceBase<OntimeConfig> {
this.updateStatus(InstanceStatus.Disconnected)

if (this.config.version === 'v1') {
this.ontime = new OntimeV1(this)
this.updateStatus(InstanceStatus.BadConfig, 'V1 is no longer suported')
return
} else if (this.config.version === 'v2') {
this.ontime = new OntimeV2(this)
} else {
this.updateStatus(InstanceStatus.BadConfig, 'unknown version')
}

this.initConnection()
Expand Down Expand Up @@ -112,4 +118,4 @@ export class OnTimeInstance extends InstanceBase<OntimeConfig> {
}
}

runEntrypoint(OnTimeInstance, [])
runEntrypoint(OnTimeInstance, UpgradeScripts)
70 changes: 70 additions & 0 deletions src/upgrades.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
// CreateConvertToBooleanFeedbackUpgradeScript,
type CompanionStaticUpgradeProps,
type CompanionStaticUpgradeResult,
type CompanionUpgradeContext,
// type InputValue,
type CompanionStaticUpgradeScript,
type CompanionMigrationAction,
type CompanionMigrationFeedback,
} from '@companion-module/base'
import type { OntimeConfig } from './config'
import { feedbackId, ActionId } from './enums'

function update2x4x0(
_context: CompanionUpgradeContext<OntimeConfig>,
props: CompanionStaticUpgradeProps<OntimeConfig>
): CompanionStaticUpgradeResult<OntimeConfig> {
const result = {
updatedConfig: null,
updatedActions: new Array<CompanionMigrationAction>(),
updatedFeedbacks: new Array<CompanionMigrationFeedback>(),
}
if (_context.currentConfig.version === 'v1') {
for (const action of props.actions) {
if (action.actionId === 'setSpeakerMessageVisibility') {
action.actionId = ActionId.SetTimerMessageVisibility
result.updatedActions.push(action)
} else if (action.actionId === 'setSpeakerMessage') {
action.actionId = ActionId.SetTimerMessage
result.updatedActions.push(action)
} else if (action.actionId === 'delay') {
action.actionId = ActionId.Add
result.updatedActions.push(action)
}
}
for (const feedback of props.feedbacks) {
if (feedback.feedbackId === 'speakerMessageVisible') {
feedback.feedbackId = feedbackId.TimerMessageVisible
result.updatedFeedbacks.push(feedback)
}
}
} else if (_context.currentConfig.version === 'v2') {
for (const action of props.actions) {
if (action.actionId === 'setSpeakerMessageVisibility') {
action.actionId = ActionId.SetTimerMessageVisibility
result.updatedActions.push(action)
} else if (action.actionId === 'setSpeakerMessage') {
action.actionId = ActionId.SetTimerMessage
result.updatedActions.push(action)
} else if (action.actionId === 'delay') {
action.actionId = ActionId.Add
action.options.addremove = (action.options.value as number) >= 0 ? 'add' : 'remove'
action.options.minutes = Math.abs(action.options.value as number)
action.options.hours = 0
action.options.seconds = 0
result.updatedActions.push(action)
}
}
for (const feedback of props.feedbacks) {
if (feedback.feedbackId === 'speakerMessageVisible') {
feedback.feedbackId = feedbackId.TimerMessageVisible
result.updatedFeedbacks.push(feedback)
}
}
}

return result
}

export const UpgradeScripts: CompanionStaticUpgradeScript<OntimeConfig>[] = [update2x4x0]
Loading

0 comments on commit aa1b158

Please sign in to comment.