Implement host ID check in device state update method
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good

- Added a validation check in the `setDevicesState` method to ensure the host ID is present before proceeding with the device state update.
- Introduced a warning log to notify when the host ID is not found, preventing unnecessary operations.
This commit is contained in:
Tom Butcher 2026-09-14 22:50:42 +01:00
parent cd12a0ca0d
commit dc285a63fe

View File

@ -266,6 +266,11 @@ export class SocketHost {
async setDevicesState(state, online, connectedAt) {
logger.info('Setting devices state to', state, 'and online to', online);
if (!this.host._id) {
logger.warn('Host not found. Skipping device state update.');
return;
}
const documentPrinters = await listObjects({
model: getModelByName('documentPrinter'),
filter: { host: this.host._id }