mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-14 18:58:49 -05:00
rename old room controls to lights and rename new thing to activity controls
Container image / image (push) Failing after 1m2s
Container image / image (push) Failing after 1m2s
This commit is contained in:
@@ -12,7 +12,7 @@ function createActions({ getConfig, ha, locks }) {
|
||||
async function execute(id, value, actor, idle = false) {
|
||||
if (!idle) assertAccess(actor);
|
||||
const config = getConfig();
|
||||
if (!config.enabled) throw new Error('Home Assistant activities are disabled');
|
||||
if (!config.enabled) throw new Error('Activity Controls are disabled');
|
||||
const item = config.items.find((entry) => entry.id === id);
|
||||
if (!item) throw new Error('Unknown activity item');
|
||||
if (!idle && locks.isLocked(id) && !['admin', 'lockdown'].includes(actor.role)) throw new Error('This item is locked');
|
||||
|
||||
@@ -129,7 +129,8 @@ test('locks are process-local and names resolve without guessing', () => {
|
||||
assert.equal(resolveItem(items.slice(0, 1), 'FAN SPEED').id, 'number.fan');
|
||||
assert.equal(resolveItem(items, 'NUMBER.FAN').id, 'number.fan');
|
||||
assert.throws(() => resolveItem(items, 'Fan speed'), /number.fan, number.other/);
|
||||
assert.throws(() => resolveItem(items, 'Fan'), /No activity/);
|
||||
// Keep the lookup error aligned with the panel name users see when choosing an item.
|
||||
assert.throws(() => resolveItem(items, 'Fan'), /No activity control/);
|
||||
});
|
||||
|
||||
test('command preserves multiword names and exposes lock status', async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Home Assistant activities have their own catalog so room-light bulk actions
|
||||
// Activity Controls have their own catalog so room-light bulk actions
|
||||
// never acquire unrelated devices simply because they share a connection.
|
||||
const { strictObject, string, boolean } = require('../../configuration/schemaHelpers');
|
||||
|
||||
@@ -7,13 +7,13 @@ module.exports = {
|
||||
feature: true,
|
||||
defaultValue: { enabled: false, items: [] },
|
||||
schema: strictObject({
|
||||
enabled: boolean({ description: 'Shows the separate Activities card using the enabled Home Assistant connection.' }),
|
||||
enabled: boolean({ description: 'Shows the Activity Controls card in Activities using the enabled Home Assistant connection.' }),
|
||||
items: {
|
||||
type: 'array',
|
||||
title: 'Activity items',
|
||||
title: 'Activity control items',
|
||||
description: 'Ordered public entities. Control types and limits come from Home Assistant; unsupported domains are read-only.',
|
||||
items: strictObject({
|
||||
id: string({ title: 'Entity id', description: 'Exact Home Assistant entity ID to expose in Activities.', pattern: '^[a-z0-9_]+\\.[a-z0-9_]+$', maxLength: 255, examples: ['input_number.fan_speed'] }),
|
||||
id: string({ title: 'Entity id', description: 'Exact Home Assistant entity ID to expose in Activity Controls.', pattern: '^[a-z0-9_]+\\.[a-z0-9_]+$', maxLength: 255, examples: ['input_number.fan_speed'] }),
|
||||
name: string({ title: 'Display name', description: 'Optional override; otherwise uses the Home Assistant friendly name.', maxLength: 120, examples: ['Fan speed'] }),
|
||||
icon: string({ description: 'Font Awesome name, as used by social links. Blank or invalid names use a fallback.', maxLength: 80, examples: ['FaFan'] }),
|
||||
// Match social-link colors so admins can customize tiles through the existing config form.
|
||||
@@ -21,7 +21,7 @@ module.exports = {
|
||||
readOnly: boolean({ title: 'Read only', default: false, description: 'Display the value without allowing user or idle commands.' }),
|
||||
idleAction: string({ title: 'When idle', enum: ['unchanged', 'set', 'press'], default: 'unchanged', description: 'Leave unchanged, set the idle value, or press a button once. Runs independently of user locks.' }),
|
||||
idleValue: string({ title: 'Idle value', description: 'For set: on/off, a number, exact selection, or text (empty text clears it). Checked against live entity limits when idle runs.', examples: ['0'], maxLength: 255 }),
|
||||
}, { description: 'One independently controlled or read-only activity item.', required: ['id'] }),
|
||||
}, { description: 'One independently controlled or read-only activity control item.', required: ['id'] }),
|
||||
},
|
||||
}, { title: 'Home Assistant activities', description: 'Generic activity controls and idle behavior, separate from room lighting.', required: ['enabled', 'items'] }),
|
||||
}, { title: 'Activity Controls', description: 'Generic activity controls and idle behavior, separate from room lighting.', required: ['enabled', 'items'] }),
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ function resolveItem(items, query) {
|
||||
if (idMatch) return idMatch;
|
||||
const matches = items.filter((item) => item.name.toLowerCase() === normalized);
|
||||
if (matches.length > 1) throw new Error(`Name is ambiguous. Use an entity ID: ${matches.map((item) => item.id).join(', ')}`);
|
||||
if (!matches.length) throw new Error('No activity item matches that name or entity ID');
|
||||
if (!matches.length) throw new Error('No activity control item matches that name or entity ID');
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user