diff --git a/config.schema.json b/config.schema.json index 257554a..ca22c79 100644 --- a/config.schema.json +++ b/config.schema.json @@ -413,7 +413,7 @@ } ] }, - "outputActiveLimits": { + "publish": { "type": "object", "properties": { "mqtt": { @@ -444,7 +444,7 @@ } }, "additionalProperties": false, - "description": "Optionally output active control limits" + "description": "Publish active control limits" } }, "required": [ diff --git a/src/coordinator/helpers/inverterController.ts b/src/coordinator/helpers/inverterController.ts index 1c95ea9..557aca7 100644 --- a/src/coordinator/helpers/inverterController.ts +++ b/src/coordinator/helpers/inverterController.ts @@ -22,7 +22,7 @@ import { CappedArrayStack } from '../../helpers/cappedArrayStack.js'; import { timeWeightedAverage } from '../../helpers/timeWeightedAverage.js'; import { differenceInSeconds } from 'date-fns'; import { type ControlsModel } from '../../connections/sunspec/models/controls.js'; -import { ActiveLimitOutput } from './activeLimitOutput.js'; +import { Publish } from './publish.js'; export type SupportedControlTypes = Extract< ControlType, @@ -70,7 +70,7 @@ const defaultValues = { } as const satisfies Record; export class InverterController { - private activeLimitOutput: ActiveLimitOutput; + private activeLimitOutput: Publish; private cachedDerSample = new CappedArrayStack({ limit: 100 }); private cachedSiteSample = new CappedArrayStack({ limit: 100 }); private logger: Logger; @@ -107,7 +107,7 @@ export class InverterController { inverterConfiguration: InverterConfiguration, ) => Promise; }) { - this.activeLimitOutput = new ActiveLimitOutput({ config }); + this.activeLimitOutput = new Publish({ config }); this.secondsToSample = config.inverterControl.sampleSeconds; this.controlFrequencyMinimumSeconds = config.inverterControl.controlFrequencyMinimumSeconds; diff --git a/src/coordinator/helpers/activeLimitOutput.ts b/src/coordinator/helpers/publish.ts similarity index 60% rename from src/coordinator/helpers/activeLimitOutput.ts rename to src/coordinator/helpers/publish.ts index a48f624..08a7893 100644 --- a/src/coordinator/helpers/activeLimitOutput.ts +++ b/src/coordinator/helpers/publish.ts @@ -2,18 +2,15 @@ import mqtt from 'mqtt'; import { type Config } from '../../helpers/config.js'; import { type ActiveInverterControlLimit } from './inverterController.js'; -export class ActiveLimitOutput { +export class Publish { private mqttClient: mqtt.MqttClient | undefined; constructor({ config }: { config: Config }) { - if (config.outputActiveLimits?.mqtt) { - this.mqttClient = mqtt.connect( - config.outputActiveLimits.mqtt.host, - { - username: config.outputActiveLimits.mqtt.username, - password: config.outputActiveLimits.mqtt.password, - }, - ); + if (config.publish?.mqtt) { + this.mqttClient = mqtt.connect(config.publish.mqtt.host, { + username: config.publish.mqtt.username, + password: config.publish.mqtt.password, + }); } } diff --git a/src/helpers/config.ts b/src/helpers/config.ts index f0124ed..fd80655 100644 --- a/src/helpers/config.ts +++ b/src/helpers/config.ts @@ -237,7 +237,7 @@ A longer time will smooth out load changes but may result in overshoot.`, }) .describe('MQTT meter configuration'), ]), - outputActiveLimits: z + publish: z .object({ mqtt: z .object({ @@ -258,7 +258,7 @@ A longer time will smooth out load changes but may result in overshoot.`, }) .optional(), }) - .describe('Optionally output active control limits') + .describe('Publish active control limits') .optional(), });