feat(iot): repackaged Odoo iot modules + Fusion Plating sensor wrapper
Phase A of the IoT initiative — gets the server-side infrastructure
in place before the Raspberry Pi hardware arrives, so the iot admin
UI + /fp/iot/ingest endpoint are ready to accept the first real
temperature reading as soon as the Pi is wired up.
New top-level folder: fusion_iot/
1. **iot_base/** — Odoo S.A. iot_base module, copied from
RePackaged-Odoo verbatim. LGPL-3 upstream, no changes needed.
2. **iot/** — Odoo S.A. iot module, repackaged:
- `models/update.py` neutralised (removed the publisher_warranty
IoT-Box-counting report that phones home to odoo.com for
enterprise licence enforcement)
- `iot_handlers/lib/load_worldline_library.sh` deleted (proprietary
Worldline payment lib fetch from download.odoo.com, not needed)
- `wizard/add_iot_box.py._connect_iot_box_with_pairing_code` —
upstream called odoo.com's iot-proxy to resolve pairing codes;
replaced with a no-op. Pi-side iot_drivers proxy registers
directly with this Odoo server instead.
- Manifest rebranded with an explicit changelog preamble.
3. **fusion_plating_iot/** — new plating-specific wrapper:
- `fp.tank.sensor` — maps an iot.device (or a direct-HTTP-ingest
sensor) to a fusion.plating.tank + fusion.plating.bath.parameter.
Supports DS18B20, PT100/1000, pH, conductivity, level. Per-sensor
alert_min/max overrides.
- `fp.tank.reading` — append-only time-series. On create, evaluates
against sensor's alert range. On in-spec → out-of-spec TRANSITION,
auto-raises a fusion.plating.quality.hold (once per excursion,
no spam during sustained out-of-spec).
- `POST /fp/iot/ingest` — shared-secret HTTP endpoint for sensors
bypassing the Pi proxy. Token via X-FP-IOT-Token header OR body.
Accepts single-reading or batch payloads.
- Menu under Plating → Operations → Sensors & Readings.
- Tank form inherits get a Sensors tab inline.
Deployed to entech. Verified end-to-end:
- Install: iot_base + iot + fusion_plating_iot all 'installed'
- Smoke test: in-spec → out-of-spec → hold raised (HOLD-0010);
continued excursion → NO duplicate hold; back-in-spec → NEW
excursion → NEW hold (HOLD-0011) ✓
- HTTP endpoint: correct token → 200 accepted; wrong token → 401;
unknown device_serial → 404; batch payload → 200 accepted=N ✓
Phase B (when Raspberry Pi hardware arrives): DS18B20 iot_handler
driver for the Pi-side iot_drivers proxy + systemd service on
vanilla Raspberry Pi OS + first live reading from physical probe.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,47 @@
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { IoTLongpolling } from "@iot_base/network_utils/longpolling";
|
||||
import { uuid } from "@web/core/utils/strings";
|
||||
|
||||
patch(IoTLongpolling.prototype, {
|
||||
/**
|
||||
* Send a message to the IoT Box (action route)
|
||||
* @param iotBoxIp IP Address of the IoT Box
|
||||
* @param message Data to send to the device
|
||||
* @param messageId Unique identifier for the message
|
||||
* @param fallback If longpolling has a fallback option (e.g. websocket), do not display errors to the user
|
||||
* @returns {Promise<*>} response of the request (response.result tells if the device is connected or not)
|
||||
*/
|
||||
async sendMessage(iotBoxIp, message, messageId = null, fallback = false) {
|
||||
messageId ??= uuid();
|
||||
return this._rpcIoT(iotBoxIp, '/iot_drivers/action', { session_id: messageId, ...message }, undefined, fallback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Listen for messages from the IoT Box (polling the IoT Box)
|
||||
* @param iotBoxIp IP Address of the IoT Box
|
||||
* @param iotDeviceIdentifier Identifier of the device connected to the IoT Box
|
||||
* @param onSuccess Callback to run when a successful response is received (can return ``message``, ``deviceIdentifier``, and ``messageId``)
|
||||
* @param onFailure Callback to run when the request fails (can return ``deviceIdentifier`` and ``messageId``)
|
||||
* @param requestId The request ID to listen for (optional)
|
||||
*/
|
||||
onMessage(
|
||||
iotBoxIp,
|
||||
iotDeviceIdentifier,
|
||||
onSuccess = (_message, _deviceIdentifier, _messageId) => {},
|
||||
onFailure = (_message, _deviceIdentifier, _messageId) => {},
|
||||
requestId = null
|
||||
) {
|
||||
const listenerCallback = (message) => {
|
||||
if (requestId && message.owner !== requestId) {
|
||||
return;
|
||||
}
|
||||
this.removeListener(iotBoxIp, iotDeviceIdentifier, requestId);
|
||||
if (message.status === "success" || message.status?.status === "connected") { // 'connected' is the serial driver success status
|
||||
onSuccess(message, iotDeviceIdentifier, requestId);
|
||||
} else {
|
||||
onFailure(message, iotDeviceIdentifier, requestId);
|
||||
}
|
||||
}
|
||||
return this.addListener(iotBoxIp, [ iotDeviceIdentifier ], requestId, listenerCallback, true);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user