mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
fix
This commit is contained in:
@@ -19,7 +19,7 @@ async function setEnabled(nextValue, options = {}) {
|
|||||||
const next = Boolean(nextValue);
|
const next = Boolean(nextValue);
|
||||||
if (enabled === next) return enabled;
|
if (enabled === next) return enabled;
|
||||||
|
|
||||||
if (next) {
|
if (next && homeAssistantService.enabled) {
|
||||||
/*
|
/*
|
||||||
Lock first because the existing locked-on transition sets lights white.
|
Lock first because the existing locked-on transition sets lights white.
|
||||||
Recoloring RGB lights afterward leaves them green while retaining the
|
Recoloring RGB lights afterward leaves them green while retaining the
|
||||||
@@ -54,7 +54,7 @@ async function setEnabled(nextValue, options = {}) {
|
|||||||
if (failures.length) {
|
if (failures.length) {
|
||||||
logger.warn('Some room controls failed to enter green mode', { failures });
|
logger.warn('Some room controls failed to enter green mode', { failures });
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!next && homeAssistantService.enabled) {
|
||||||
// Disabling the visual mode simply releases the lock it created. Bulb
|
// Disabling the visual mode simply releases the lock it created. Bulb
|
||||||
// colors remain untouched, matching the existing one-shot light behavior.
|
// colors remain untouched, matching the existing one-shot light behavior.
|
||||||
await homeAssistantService.setLightsLockedOn(false, {
|
await homeAssistantService.setLightsLockedOn(false, {
|
||||||
@@ -62,6 +62,14 @@ async function setEnabled(nextValue, options = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Home Assistant is deliberately optional here. When it is not configured,
|
||||||
|
skipping the physical-room operations still allows the session theme,
|
||||||
|
CardFrame styling, alerts, commands, and timed reward to work normally.
|
||||||
|
The integration's generic lock state is also left untouched because there
|
||||||
|
are no server-managed room controls to lock.
|
||||||
|
*/
|
||||||
|
|
||||||
enabled = next;
|
enabled = next;
|
||||||
logger.info('Green mode changed', {
|
logger.info('Green mode changed', {
|
||||||
enabled,
|
enabled,
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ test('a disabled required feature is reported before any permission check', asyn
|
|||||||
assert.match(await run('rs lights on', nonAdmin), /Home Assistant feature is not configured/);
|
assert.match(await run('rs lights on', nonAdmin), /Home Assistant feature is not configured/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('green mode remains available without optional Home Assistant features', async () => {
|
||||||
|
const run = createRouter({ featureEnabled: false });
|
||||||
|
assert.match(await run('rs green on', admin), /Green mode enabled/);
|
||||||
|
});
|
||||||
|
|
||||||
test('ordinary words that merely start with the prefix are not commands', async () => {
|
test('ordinary words that merely start with the prefix are not commands', async () => {
|
||||||
const run = createRouter();
|
const run = createRouter();
|
||||||
assert.equal(await run('rsvp', nonAdmin), '');
|
assert.equal(await run('rsvp', nonAdmin), '');
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ function buildCommandRegistry(prefix, timeCommand) {
|
|||||||
mode: { category: 'admin', summary: 'Change the server mode.', usage: [`${prefix} mode <open|turns|admin|lockdown>`], access: 'Admin', permission: 'admin' },
|
mode: { category: 'admin', summary: 'Change the server mode.', usage: [`${prefix} mode <open|turns|admin|lockdown>`], access: 'Admin', permission: 'admin' },
|
||||||
reason: { category: 'admin', summary: 'Show, set, or clear the admin-mode reason.', usage: [`${prefix} reason [text|clear]`], access: 'Admin to change' },
|
reason: { category: 'admin', summary: 'Show, set, or clear the admin-mode reason.', usage: [`${prefix} reason [text|clear]`], access: 'Admin to change' },
|
||||||
goal: { category: 'admin', summary: 'Show, set, or clear the global objective.', usage: [`${prefix} goal [text|clear]`], access: 'Admin to change' },
|
goal: { category: 'admin', summary: 'Show, set, or clear the global objective.', usage: [`${prefix} goal [text|clear]`], access: 'Admin to change' },
|
||||||
green: { category: 'admin', summary: 'Toggle green room and page mode.', usage: [`${prefix} green <on|off>`], access: 'Admin', permission: 'admin', requiredFeature: 'homeAssistant', unavailableLabel: 'Home Assistant' },
|
// Green mode is fundamentally a server theme. Home Assistant lighting is
|
||||||
|
// an optional enhancement, so the command must remain available when that
|
||||||
|
// integration is absent.
|
||||||
|
green: { category: 'admin', summary: 'Toggle green room and page mode.', usage: [`${prefix} green <on|off>`], access: 'Admin', permission: 'admin' },
|
||||||
lights: {
|
lights: {
|
||||||
category: 'features',
|
category: 'features',
|
||||||
summary: 'Control room lights or manage the admin light lock.',
|
summary: 'Control room lights or manage the admin light lock.',
|
||||||
|
|||||||
Reference in New Issue
Block a user