feat: ontime actions in automation

This commit is contained in:
Carlos Valente
2025-02-18 12:00:31 +01:00
committed by Carlos Valente
parent 636f78e21e
commit 5fb30c75c4
13 changed files with 611 additions and 71 deletions
@@ -1,6 +1,8 @@
import {
isHTTPOutput,
isOntimeAction,
isOSCOutput,
LogOrigin,
type AutomationFilter,
type AutomationOutput,
type FilterRule,
@@ -8,6 +10,7 @@ import {
} from 'ontime-types';
import { getPropertyFromPath } from 'ontime-utils';
import { logger } from '../../classes/Logger.js';
import { getState, type RuntimeState } from '../../stores/runtimeState.js';
import { isOntimeCloud } from '../../externals.js';
@@ -15,6 +18,7 @@ import { emitOSC } from './clients/osc.client.js';
import { emitHTTP } from './clients/http.client.js';
import { getAutomationsEnabled, getAutomations, getAutomationTriggers } from './automation.dao.js';
import { isBooleanEquals, isGreaterThan, isLessThan } from './automation.utils.js';
import { toOntimeAction } from './clients/ontime.client.js';
/**
* Exposes a method for triggering actions based on a TimerLifeCycle event
@@ -117,12 +121,14 @@ export function testConditions(
function send(output: AutomationOutput[], state?: RuntimeState) {
const stateSnapshot = state ?? getState();
output.forEach((payload) => {
if (isOSCOutput(payload)) {
if (!isOntimeCloud) {
emitOSC(payload, stateSnapshot);
}
if (isOSCOutput(payload) && !isOntimeCloud) {
emitOSC(payload, stateSnapshot);
} else if (isHTTPOutput(payload)) {
emitHTTP(payload, stateSnapshot);
} else if (isOntimeAction(payload)) {
toOntimeAction(payload);
} else {
logger.warning(LogOrigin.Tx, `Unknown output type: ${payload}`);
}
});
}