Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions workers/lib/dcs.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ function extractSiteMainMeterPowerW (dcsThing) {
function getSensorReading (sensors, sensorId, defaultConfig = null) {
if (!sensorId) return defaultConfig
const sensor = sensors?.find(s => s.equipment === sensorId)
if (sensor?.value != null) {
return { value: sensor.value, unit: sensor.unit }
}
return defaultConfig
if (!sensor) return defaultConfig
// A configured sensor is present in the snap even when the DCS is offline;
// keep its unit and surface value: null rather than dropping the reading.
return { value: sensor.value ?? null, unit: sensor.unit ?? null }
}

// Like getSensorReading, but always surfaces the configured sensor id even when
Expand Down
18 changes: 11 additions & 7 deletions workers/lib/server/handlers/cooling.system.handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ function getSensorWithTag (sensors, sensorId, defaultConfig) {
return {
tag: sensorId,
type: sensor?.type || null,
reading: sensor?.value != null
? { value: sensor.value, unit: sensor.unit }
// Keep the unit and surface value: null when a configured sensor is
// present but its tag isn't readable; fall back only when absent entirely.
reading: sensor
? { value: sensor.value ?? null, unit: sensor.unit ?? null }
: (defaultConfig || null)
}
}
Expand Down Expand Up @@ -421,12 +423,14 @@ function buildMinersCircuit2View (equipment, config) {
level: getSensorReading(levels, makeupConfig.level_sensor),
level_sensor: makeupConfig.level_sensor
},
pump: makeupPump
pump: makeupPumpId
? {
id: makeupPump.equipment,
name: makeupPump.equipment,
status: makeupPump.status,
is_running: makeupPump.fbk_run_out || false,
id: makeupPumpId,
name: makeupPumpId,
status: makeupPump?.status ?? null,
is_running: makeupPump?.fbk_run_out || false,
speed: makeupPump?.speed ?? null,
current: makeupPump?.current ?? null,
rated_head: makeupGlobalConfig.defaults?.pump_head || null,
rated_flow: makeupGlobalConfig.defaults?.pump_flow || null
}
Expand Down
Loading