OzWrapper.OzCal.OzCal.OzCal¶
- class OzWrapper.OzCal.OzCal.OzCal¶
On-device sensor calculation module. Port of the gateway’s shadow.js. Processes raw electrode readings into calibrated gas concentrations, PM humidity correction, wet-bulb temperature, and temp/hum adjustments.
- _resolve_temp_nullish(d: dict, key: str, cfg_key: dict) float¶
Mirrors JS ?? (nullish coalescing): falls back only on None/missing, not on 0 — so a valid 0°C reading is preserved.
- adjust_values_final(config: dict, key: str, data: dict, pure_no2: float, no2_working: str, hum_corrected_v21: bool = False) float | None¶
- apply_dynamic_weights(config: dict, key: str, data: dict, pure_no2: float, no2_working: str, hum_corrected_v21: bool = False) float¶
- apply_humidity_compensation(data: dict, config: dict) float | None¶
Divide v21 by a humidity-indexed scale factor from config[‘v2’].hum_delta. Falls back to the original v21 when the table is absent or on error.
- calculate_gas(data: dict, key: str, config: dict, pure_no2: float, hum_corrected_v21: bool = False) float¶
- correct_concentrations(config: dict, key: str, data: dict, pure_no2: float, no2_working: str, hum_corrected_v21: bool = False) float | None¶
- generate_shadow_data(data: dict, config: dict, device_id: str = '', is_light: bool = False, fallback_hum: float | None = None, fallback_temp: float | None = None) None¶
Mutates data[“payload”][“d”] in place — mirrors the original JS contract. Caller should pass a copy of data if the original must be preserved.