mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
switch auto lights on to drive macro
This commit is contained in:
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" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>webui</title>
|
<title>webui</title>
|
||||||
<script type="module" crossorigin src="/assets/index-BXPUoQFz.js"></script>
|
<script type="module" crossorigin src="/assets/index-Bgtbi1T2.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-CCqAmxiE.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-CCqAmxiE.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -33,6 +33,17 @@ export function ControlSystemProvider({ children }) {
|
|||||||
} = useSettingsNamespace('controls', { keymap: DEFAULT_KEYMAP, macros: DEFAULT_MACROS });
|
} = useSettingsNamespace('controls', { keymap: DEFAULT_KEYMAP, macros: DEFAULT_MACROS });
|
||||||
const { session, homeAssistantSetState } = useSession();
|
const { session, homeAssistantSetState } = useSession();
|
||||||
|
|
||||||
|
const turnOnAllLights = useCallback(() => {
|
||||||
|
const entities = session?.homeAssistant?.entities || [];
|
||||||
|
const targets = entities.filter(
|
||||||
|
(ent) => ent.type === 'light' && ent.available !== false && ent.state !== 'on',
|
||||||
|
);
|
||||||
|
if (targets.length === 0) return;
|
||||||
|
targets.forEach((ent) => {
|
||||||
|
homeAssistantSetState(ent.id, 'on').catch(() => {});
|
||||||
|
});
|
||||||
|
}, [session?.homeAssistant?.entities, homeAssistantSetState]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch({ type: 'control/set-rover', payload: pipeline.roverId });
|
dispatch({ type: 'control/set-rover', payload: pipeline.roverId });
|
||||||
}, [pipeline.roverId]);
|
}, [pipeline.roverId]);
|
||||||
@@ -41,16 +52,9 @@ export function ControlSystemProvider({ children }) {
|
|||||||
const prevMode = prevModeRef.current;
|
const prevMode = prevModeRef.current;
|
||||||
prevModeRef.current = state.mode;
|
prevModeRef.current = state.mode;
|
||||||
if (prevMode !== 'drive' && state.mode === 'drive' && session?.homeAssistant?.entities) {
|
if (prevMode !== 'drive' && state.mode === 'drive' && session?.homeAssistant?.entities) {
|
||||||
const targets = session.homeAssistant.entities.filter(
|
turnOnAllLights();
|
||||||
(ent) => ent.type === 'light' && ent.available !== false && ent.state !== 'on',
|
|
||||||
);
|
|
||||||
if (targets.length > 0) {
|
|
||||||
targets.forEach((ent) => {
|
|
||||||
homeAssistantSetState(ent.id, 'on').catch(() => {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [state.mode, session?.homeAssistant?.entities, homeAssistantSetState]);
|
}, [state.mode, session?.homeAssistant?.entities, turnOnAllLights]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const mergedKeymap = { ...DEFAULT_KEYMAP, ...(controlSettings?.keymap || {}) };
|
const mergedKeymap = { ...DEFAULT_KEYMAP, ...(controlSettings?.keymap || {}) };
|
||||||
@@ -190,9 +194,12 @@ export function ControlSystemProvider({ children }) {
|
|||||||
async (macroId) => {
|
async (macroId) => {
|
||||||
const macro = state.macros.find((item) => item.id === macroId) || null;
|
const macro = state.macros.find((item) => item.id === macroId) || null;
|
||||||
if (!macro) return;
|
if (!macro) return;
|
||||||
|
if (macroId === 'drive-sequence') {
|
||||||
|
turnOnAllLights();
|
||||||
|
}
|
||||||
await pipeline.runMacroSteps(macro);
|
await pipeline.runMacroSteps(macro);
|
||||||
},
|
},
|
||||||
[pipeline, state.macros],
|
[pipeline, state.macros, turnOnAllLights],
|
||||||
);
|
);
|
||||||
|
|
||||||
const stopAllMotion = useCallback(() => {
|
const stopAllMotion = useCallback(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user