jfhdskljh

This commit is contained in:
legop3
2026-04-29 19:48:22 -04:00
parent 40e625793e
commit da56086b21
3 changed files with 31 additions and 2 deletions
@@ -38,7 +38,14 @@ function createRuntimeEngine(deps) {
}
}
});
logger.info('Loaded Home Assistant entities', { count: entityConfig.size });
logger.info('Loaded Home Assistant entities', {
count: entityConfig.size,
entities: Array.from(entityConfig.values()).map((entry) => ({
id: entry.id,
type: entry.type,
domain: entry.domain,
})),
});
}
function loadTriggerConfig() {
@@ -81,7 +88,19 @@ function createRuntimeEngine(deps) {
async function setAllControllableEntitiesState(desiredState, options = {}) {
const source = String(options?.source || 'unknown');
const ids = getControllableEntityIds();
if (!ids.length) return;
if (!ids.length) {
logger.warn('Home Assistant bulk state update skipped; no controllable entities configured', {
desiredState: desiredState === 'on' ? 'on' : 'off',
source,
});
return {
desiredState: desiredState === 'on' ? 'on' : 'off',
source,
total: 0,
succeeded: [],
failures: [],
};
}
logger.info('Issuing Home Assistant bulk state update', {
desiredState: desiredState === 'on' ? 'on' : 'off',
source,
@@ -92,9 +92,13 @@ const idleActions = [
async function runIdleActions() {
const results = [];
logger.info('Idle action pipeline starting', {
actions: idleActions.map((action) => action.name),
});
for (const action of idleActions) {
try {
const result = await action();
logger.info('Idle action completed', { action: action.name, result });
results.push({ ok: true, result });
} catch (err) {
logger.warn('Idle action failed', { action: action.name, error: err.message });
+6
View File
@@ -36,6 +36,7 @@ function clearIdleTimer() {
if (runtime.timer) {
clearTimeout(runtime.timer);
runtime.timer = null;
logger.info('Idle timer cleared');
}
runtime.deadlineAt = null;
}
@@ -43,6 +44,10 @@ function clearIdleTimer() {
function scheduleIdleTimer() {
if (runtime.timer) return;
runtime.deadlineAt = Date.now() + IDLE_TIMEOUT_MS;
logger.info('Idle timer scheduled', {
timeoutMs: IDLE_TIMEOUT_MS,
deadlineAt: runtime.deadlineAt,
});
runtime.timer = setTimeout(async () => {
runtime.timer = null;
runtime.deadlineAt = null;
@@ -64,6 +69,7 @@ function scheduleIdleTimer() {
function refreshIdleState() {
const activity = getActivitySnapshot();
logger.info('Idle state refresh', activity);
if (activity.totalActive > 0) {
clearIdleTimer();
return;