E-Stop IP

This commit is contained in:
chk
2026-06-12 18:59:56 +02:00
parent 3e3023fa63
commit bfb84fab50
8 changed files with 78 additions and 12 deletions

View File

@@ -182,6 +182,8 @@ describe('RobotConfig.load — emergencyStop (Shelly)', () => {
test('DEFAULTS.controllers.emergencyStop hat protocol=shelly und url=null', () => {
expect(DEFAULTS.controllers.emergencyStop.protocol).toBe('shelly');
expect(DEFAULTS.controllers.emergencyStop.url).toBeNull();
expect(DEFAULTS.controllers.emergencyStop.urlOn).toBeNull();
expect(DEFAULTS.controllers.emergencyStop.urlStatus).toBeNull();
});
test('emergencyStop.url aus robot.json wird übernommen', () => {
@@ -198,11 +200,39 @@ describe('RobotConfig.load — emergencyStop (Shelly)', () => {
expect(cfg.controllers.emergencyStop.url).toBe(shellyUrl);
});
test('emergencyStop.urlOn + urlStatus aus robot.json werden übernommen (IP statt .local)', () => {
const base = 'http://192.168.0.99';
const json = {
...FULL_ROBOT_JSON,
controllers: {
...FULL_ROBOT_JSON.controllers,
emergencyStop: {
protocol: 'shelly',
url: `${base}/rpc/Switch.Set?id=0&on=false`,
urlOn: `${base}/rpc/Switch.Set?id=0&on=true`,
urlStatus: `${base}/rpc/Switch.GetStatus?id=0`,
}
}
};
const cfg = load(makeFs(JSON.stringify(json)), {}, log);
expect(cfg.controllers.emergencyStop.url).toBe(`${base}/rpc/Switch.Set?id=0&on=false`);
expect(cfg.controllers.emergencyStop.urlOn).toBe(`${base}/rpc/Switch.Set?id=0&on=true`);
expect(cfg.controllers.emergencyStop.urlStatus).toBe(`${base}/rpc/Switch.GetStatus?id=0`);
});
test('SHELLY_URL Env-Variable überschreibt url aus robot.json', () => {
const envUrl = 'http://192.168.0.99/rpc/Switch.Set?id=0&on=false';
const cfg = load(makeFs(JSON.stringify(FULL_ROBOT_JSON)), { SHELLY_URL: envUrl }, log);
expect(cfg.controllers.emergencyStop.url).toBe(envUrl);
});
test('fehlendes emergencyStop in robot.json → url=null (Default)', () => {
// FULL_ROBOT_JSON hat kein emergencyStop → fällt auf Default zurück
const cfg = load(makeFs(JSON.stringify(FULL_ROBOT_JSON)), {}, log);
expect(cfg.controllers.emergencyStop.protocol).toBe('shelly');
expect(cfg.controllers.emergencyStop.url).toBeNull();
expect(cfg.controllers.emergencyStop.urlOn).toBeNull();
expect(cfg.controllers.emergencyStop.urlStatus).toBeNull();
});
test('emergencyStop hat keine ip/port/axes/heartbeatInterval Felder', () => {