mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
IR controls
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
File diff suppressed because one or more lines are too long
@@ -78,7 +78,7 @@
|
||||
<script defer src="https://analytics.otter.land/script.js" data-website-id="82dd56a5-db44-4279-bd1e-a4d9fee39af7" data-domains="rover.otter.land"></script>
|
||||
<script defer src="https://analytics.otter.land/recorder.js" data-website-id="82dd56a5-db44-4279-bd1e-a4d9fee39af7" data-domains="rover.otter.land" data-sample-rate="0.15" data-mask-level="moderate" data-max-duration="300000"></script>
|
||||
<title>Roomba Rover</title>
|
||||
<script type="module" crossorigin src="/assets/index-CWTcRRlU.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DC_FLGBQ.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DwpUkSbG.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -125,6 +125,18 @@ function normalizeSpotlightPayloadState(rawState) {
|
||||
return Boolean(Number(rawState));
|
||||
}
|
||||
|
||||
function normalizeIrState(rawState) {
|
||||
/*
|
||||
Reolink accepts exactly Auto, On, and Off for this camera's IR LED control.
|
||||
Normalize UI payloads at the server boundary so keyboard, mobile, and any
|
||||
future direct socket callers all hit the same camera API contract.
|
||||
*/
|
||||
const normalized = String(rawState || '').trim().toLowerCase();
|
||||
if (normalized === 'on' || normalized === '1' || normalized === 'true') return 'On';
|
||||
if (normalized === 'off' || normalized === '0' || normalized === 'false') return 'Off';
|
||||
return 'Auto';
|
||||
}
|
||||
|
||||
function passesMode(socket) {
|
||||
const mode = getMode();
|
||||
if (mode === MODES.LOCKDOWN) return isLockdownAdmin(socket);
|
||||
@@ -650,11 +662,17 @@ async function setSpotlight(socket, payload = {}) {
|
||||
async function setIr(socket, payload = {}) {
|
||||
requireOperator(socket);
|
||||
return serializeVendorState(async () => {
|
||||
const nextState = String(payload.state || '').toLowerCase() === 'off' ? 'Off' : 'Auto';
|
||||
const nextState = normalizeIrState(payload.state);
|
||||
const client = await ensureReolinkClient();
|
||||
state.ir = { ...(state.ir || {}), state: nextState };
|
||||
/*
|
||||
The camera requires channel inside IrLights. Without it, SetIrLights
|
||||
returns param error (-4), while the optimistic local state makes the UI
|
||||
look like the command worked. Keep the optimistic state, but send the
|
||||
minimal payload the camera actually accepts.
|
||||
*/
|
||||
state.ir = { ...(state.ir || {}), channel: 0, state: nextState };
|
||||
emitChange('ir-pending');
|
||||
await client.api('SetIrLights', { IrLights: { state: nextState } });
|
||||
await client.api('SetIrLights', { IrLights: { channel: 0, state: nextState } });
|
||||
await refreshVendorState();
|
||||
emitChange('ir');
|
||||
return state.ir;
|
||||
|
||||
Reference in New Issue
Block a user