mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
puh
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>webui</title>
|
||||
<script type="module" crossorigin src="/assets/index-Bgtbi1T2.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-ChuD7eTF.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CCqAmxiE.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -25,7 +25,8 @@ function clampServoAngle(config, value) {
|
||||
export function ControlSystemProvider({ children }) {
|
||||
const pipeline = useCommandPipeline();
|
||||
const [state, dispatch] = useReducer(controlReducer, initialControlState);
|
||||
const prevModeRef = useRef(initialControlState.mode);
|
||||
const prevModeRef = useRef(null);
|
||||
const pendingLightsRef = useRef(false);
|
||||
const servoAngleRef = useRef(initialControlState.camera.angle);
|
||||
const {
|
||||
value: controlSettings,
|
||||
@@ -38,10 +39,16 @@ export function ControlSystemProvider({ children }) {
|
||||
const targets = entities.filter(
|
||||
(ent) => ent.type === 'light' && ent.available !== false && ent.state !== 'on',
|
||||
);
|
||||
if (targets.length === 0) return;
|
||||
if (targets.length === 0) {
|
||||
pendingLightsRef.current = false;
|
||||
return;
|
||||
}
|
||||
pendingLightsRef.current = true;
|
||||
targets.forEach((ent) => {
|
||||
homeAssistantSetState(ent.id, 'on').catch(() => {});
|
||||
});
|
||||
// Give the loop a chance; clear pending after issuing commands.
|
||||
pendingLightsRef.current = false;
|
||||
}, [session?.homeAssistant?.entities, homeAssistantSetState]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -53,9 +60,17 @@ export function ControlSystemProvider({ children }) {
|
||||
prevModeRef.current = state.mode;
|
||||
if (prevMode !== 'drive' && state.mode === 'drive' && session?.homeAssistant?.entities) {
|
||||
turnOnAllLights();
|
||||
} else if (prevMode !== 'drive' && state.mode === 'drive') {
|
||||
pendingLightsRef.current = true;
|
||||
}
|
||||
}, [state.mode, session?.homeAssistant?.entities, turnOnAllLights]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pendingLightsRef.current && session?.homeAssistant?.entities) {
|
||||
turnOnAllLights();
|
||||
}
|
||||
}, [session?.homeAssistant?.entities, turnOnAllLights]);
|
||||
|
||||
useEffect(() => {
|
||||
const mergedKeymap = { ...DEFAULT_KEYMAP, ...(controlSettings?.keymap || {}) };
|
||||
dispatch({ type: 'control/set-keymap', payload: mergedKeymap });
|
||||
@@ -196,10 +211,13 @@ export function ControlSystemProvider({ children }) {
|
||||
if (!macro) return;
|
||||
if (macroId === 'drive-sequence') {
|
||||
turnOnAllLights();
|
||||
if (!session?.homeAssistant?.entities) {
|
||||
pendingLightsRef.current = true;
|
||||
}
|
||||
}
|
||||
await pipeline.runMacroSteps(macro);
|
||||
},
|
||||
[pipeline, state.macros, turnOnAllLights],
|
||||
[pipeline, state.macros, session?.homeAssistant?.entities, turnOnAllLights],
|
||||
);
|
||||
|
||||
const stopAllMotion = useCallback(() => {
|
||||
|
||||
Reference in New Issue
Block a user