Skip to content

Renaming limiters to setpoints #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config": {
"type": "object",
"properties": {
"limiters": {
"setpoints": {
"type": "object",
"properties": {
"csipAus": {
Expand Down Expand Up @@ -154,7 +154,7 @@
}
},
"additionalProperties": false,
"description": "Limiters configuration"
"description": "Setpoints configuration"
},
"inverters": {
"type": "array",
Expand Down Expand Up @@ -509,7 +509,7 @@
}
},
"required": [
"limiters",
"setpoints",
"inverters",
"inverterControl",
"meter"
Expand Down
4 changes: 2 additions & 2 deletions config/config.example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"limiters": {
"setpoints": {
},
"inverters": [
{
Expand All @@ -25,4 +25,4 @@
"unitId": 240,
"location": "feedin"
}
}
}
36 changes: 19 additions & 17 deletions docs/configuration/limiters.md → docs/configuration/setpoints.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Limiters
# Setpoints

One or more limiters can be configured to set the operating envelope of the site.
One or more setpoints can be configured to set the operating envelope of the site.

All limiters are restrictive, that is a combination of multiple limiters will evaluate all limiters and enforce the most prohibitive value of each control type at any one time.
All setpoints are restrictive, that is a combination of multiple setpoints will evaluate all setpoints and enforce the most prohibitive value of each control type at any one time.

[[toc]]

Expand All @@ -23,16 +23,16 @@ The software supports 6 control modes mapped to the CSIP-AUS Dynamic Operating E

## CSIP-AUS dynamic connection

Apply dynamic limits from an Australian energy utility CSIP-AUS server.
Apply dynamic limits from an Australian energy utility CSIP-AUS server using a setpoint.

> [!IMPORTANT]
> This CSIP-AUS client cannot run without device certificates (and manufacturer certificates). See the [CSIP-AUS section](/csip-aus) for more information.

To use the CSIP-AUS limiter, add following property to `config.json`
To use the CSIP-AUS provided limits as a setpoint, add following property to `config.json`

```js
{
"limiters": {
"setpoints": {
"csipAus": {
"host": "https://sep2-test.energyq.com.au", // (string) required: the CSIP-AUS server host
"dcapUri": "/api/v2/dcap", // (string) required: the device capability discovery URI
Expand All @@ -43,13 +43,15 @@ To use the CSIP-AUS limiter, add following property to `config.json`
}
```

The `nmi` is not required for Energex/Ergon Energy/Energy Queensland.

## Fixed limit

To set fixed limits (such as for fixed export limits), add the following property to `config.json`
To use a setpoint to specify fixed limits (such as for fixed export limits), add the following property to `config.json`

```js
{
"limiters": {
"setpoints": {
"fixed": {
"connect": true, // (true/false) optional: whether the inverters should be connected to the grid
"exportLimitWatts": 5000, // (number) optional: the maximum export limit in watts
Expand All @@ -64,14 +66,14 @@ To set fixed limits (such as for fixed export limits), add the following propert

## MQTT

To set limits based on a MQTT topic, add the following property to `config.json`
To specify setpoint limits based on a MQTT topic, add the following property to `config.json`

```js
{
"limiters": {
"setpoints": {
"mqtt": {
"host": "mqtt://192.168.1.123",
"topic": "limits"
"topic": "setpoints"
}
}
...
Expand Down Expand Up @@ -103,12 +105,12 @@ For example

## Negative feed-in

To set a zero export limit based on negative feed-in, add the following property to `config.json`
To set a zero export limit setpoint based on negative feed-in, add the following property to `config.json`

For Amber Electric:
```js
{
"limiters": {
"setpoints": {
"negativeFeedIn": {
"type": "amber", // (string) required: the source of the negative feed-in data
"apiKey": "asdf", // (string) required: the Amber API key
Expand All @@ -121,12 +123,12 @@ For Amber Electric:

## Two-way tariffs

To set a zero export limit based on two-way tariffs, add the following property to `config.json`
To set a zero export limit setpoint based on two-way tariffs, add the following property to `config.json`

For [Ausgrid solar tariff](https://www.ausgrid.com.au/Connections/Solar-and-batteries/Solar-tariffs) EA029:
```js
{
"limiters": {
"setpoints": {
"twoWayTariff": {
"type": "ausgridEA029"
}
Expand All @@ -138,11 +140,11 @@ For [Ausgrid solar tariff](https://www.ausgrid.com.au/Connections/Solar-and-batt
For [SAPN RELE2W](https://www.sapowernetworks.com.au/public/download.jsp?id=328119) tariff:
```js
{
"limiters": {
"setpoints": {
"twoWayTariff": {
"type": "sapnRELE2W"
}
}
...
}
```
```
6 changes: 3 additions & 3 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ flowchart LR
ODE <--> SunSpec & Modbus & HTTP & Proprietary & MQTT
Protocols <--> I & M

subgraph Limiters
subgraph Setpoints
DC["Dynamic exports"]
F["Fixed/zero export"]
T["Two-way tariffs"]
Expand All @@ -41,8 +41,8 @@ flowchart LR
end
```

### Limiters
The system uses one or more "limiters" to set the operating envelope of the site. All limiters are restrictive, that is a combination of multiple limiters will evaluate all limiters and enforce the most prohibitive value of each control type at any one time. [Learn more about configuring limiters](/configuration/limiters).
### Setpoints
The system uses one or more "setpoints" to set the operating envelope of the site. All setpoints are restrictive, that is a combination of multiple setpoints will evaluate all setpoints and enforce the most prohibitive value of each control type at any one time. [Learn more about configuring setpoints](/configuration/setpoints).

### Inverters
The system supports one or more inverters to measure the site's generation metrics and control the power output. [Learn more about configuring inverters](/configuration/inverters).
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default tseslint.config(
ignores: [
'dist/',
'logs/',
'src/limiters/negativeFeedIn/amber/api.d.ts',
'src/setpoints/negativeFeedIn/amber/api.d.ts',
'src/ui/gen/',
'docs/.vitepress/cache',
'docs/.vitepress/dist',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"cert:device-generate": "tsx scripts/certDeviceGenerate.ts",
"cert:lfdi": "tsx scripts/certLfdi.ts",
"generate:config-json-schema": "tsx scripts/generateConfigJsonSchema.ts",
"generate:amber-api": "openapi-typescript https://raw.githubusercontent.com/amberelectric/public-api/main/swagger.json -o ./src/limiters/negativeFeedIn/amber/api.d.ts",
"generate:amber-api": "openapi-typescript https://raw.githubusercontent.com/amberelectric/public-api/main/swagger.json -o ./src/setpoints/negativeFeedIn/amber/api.d.ts",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
Expand Down Expand Up @@ -122,4 +122,4 @@
"xml2js": "^0.6.2",
"zod": "^3.24.2"
}
}
}
26 changes: 13 additions & 13 deletions src/coordinator/helpers/inverterController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
writeLoadWatts,
} from '../../helpers/influxdb.js';
import { type SiteSample } from '../../meters/siteSample.js';
import { type Limiters } from '../../limiters/index.js';
import { type Setpoints } from '../../setpoints/index.js';
import {
objectEntriesWithType,
objectFromEntriesWithType,
} from '../../helpers/object.js';
import { type Config, type LimiterKeys } from '../../helpers/config.js';
import { type Config, type SetpointKeys } from '../../helpers/config.js';
import { cappedChange } from '../../helpers/math.js';
import { type DerSample } from './derSample.js';
import { CappedArrayStack } from '../../helpers/cappedArrayStack.js';
Expand Down Expand Up @@ -74,11 +74,11 @@ export class InverterController {
private cachedDerSample = new CappedArrayStack<DerSample>({ limit: 100 });
private cachedSiteSample = new CappedArrayStack<SiteSample>({ limit: 100 });
private logger: Logger;
private limiters: Limiters;
private setpoints: Setpoints;
private loadWattsCache: number | null = null;
private controlLimitsCache: {
controlLimitsByLimiter: Record<
LimiterKeys,
controlLimitsBySetpoint: Record<
SetpointKeys,
InverterControlLimit | null
>;
activeInverterControlLimit: ActiveInverterControlLimit;
Expand All @@ -101,19 +101,19 @@ export class InverterController {

constructor({
config,
limiters,
setpoints,
onControl,
}: {
config: Config;
limiters: Limiters;
setpoints: Setpoints;
onControl: (
inverterConfiguration: InverterConfiguration,
) => Promise<void>;
}) {
this.publish = new Publish({ config });
this.secondsToSample = config.inverterControl.sampleSeconds;
this.intervalSeconds = config.inverterControl.intervalSeconds;
this.limiters = limiters;
this.setpoints = setpoints;
this.logger = pinoLogger.child({ module: 'InverterController' });
this.abortController = new AbortController();
this.onControl = onControl;
Expand Down Expand Up @@ -165,15 +165,15 @@ export class InverterController {
private updateControlLimitsLoop() {
const start = performance.now();

const controlLimitsByLimiter = objectFromEntriesWithType(
objectEntriesWithType(this.limiters).map(([key, limiter]) => [
const controlLimitsBySetpoint = objectFromEntriesWithType(
objectEntriesWithType(this.setpoints).map(([key, setpoint]) => [
key,
limiter?.getInverterControlLimit() ?? null,
setpoint?.getInverterControlLimit() ?? null,
]),
);

const activeInverterControlLimit = getActiveInverterControlLimit(
Object.values(controlLimitsByLimiter),
Object.values(controlLimitsBySetpoint),
);

writeActiveControlLimit({ limit: activeInverterControlLimit });
Expand All @@ -183,7 +183,7 @@ export class InverterController {
});

this.controlLimitsCache = {
controlLimitsByLimiter,
controlLimitsBySetpoint,
activeInverterControlLimit,
};

Expand Down
14 changes: 7 additions & 7 deletions src/coordinator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import { getSep2Instance } from '../sep2/index.js';
import { getSiteSamplePollerInstance } from './helpers/siteSample.js';
import { type SiteSamplePollerBase } from '../meters/siteSamplePollerBase.js';
import { InvertersPoller } from './helpers/inverterSample.js';
import { destroyLimiters, type Limiters } from '../limiters/index.js';
import { getLimiters } from '../limiters/index.js';
import { destroySetpoints, type Setpoints } from '../setpoints/index.js';
import { getSetpoints } from '../setpoints/index.js';

const logger = pinoLogger.child({ module: 'coordinator' });

export type Coordinator = {
inverterController: InverterController;
invertersPoller: InvertersPoller;
siteSamplePoller: SiteSamplePollerBase;
limiters: Limiters;
setpoints: Setpoints;
destroy: () => void;
};

Expand All @@ -41,14 +41,14 @@ export function createCoordinator(): Coordinator {
rampRateHelper,
});

const limiters = getLimiters({
const setpoints = getSetpoints({
config,
sep2Instance,
});

const inverterController = new InverterController({
config,
limiters,
setpoints,
onControl: (InverterController) =>
invertersPoller.onControl(InverterController),
});
Expand Down Expand Up @@ -76,14 +76,14 @@ export function createCoordinator(): Coordinator {
inverterController,
invertersPoller,
siteSamplePoller,
limiters,
setpoints,
destroy: () => {
logger.info('Destroying coordinator');
sep2Instance?.destroy();
siteSamplePoller.destroy();
invertersPoller.destroy();
inverterController.destroy();
destroyLimiters(limiters);
destroySetpoints(setpoints);
},
};
}
6 changes: 3 additions & 3 deletions src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const modbusSchema = z.object({
export type ModbusSchema = z.infer<typeof modbusSchema>;

export const configSchema = z.object({
limiters: z
setpoints: z
.object({
csipAus: z
.object({
Expand Down Expand Up @@ -146,7 +146,7 @@ export const configSchema = z.object({
.optional()
.describe('If defined, limit by MQTT'),
})
.describe('Limiters configuration'),
.describe('Setpoints configuration'),
inverters: z
.array(
z.union([
Expand Down Expand Up @@ -317,7 +317,7 @@ A longer time will smooth out load changes but may result in overshoot.`,

export type Config = z.infer<typeof configSchema>;

export type LimiterKeys = keyof Config['limiters'];
export type SetpointKeys = keyof Config['setpoints'];

export function getConfigPath() {
return `${env.CONFIG_DIR}/config.json`;
Expand Down
Loading