From d51851d058d05b8939344d30d206094a928d1e94 Mon Sep 17 00:00:00 2001 From: bene Date: Sun, 9 Jan 2022 15:25:21 +0100 Subject: [PATCH] add workaround for wrong tilt orientation --- src/devices/technicmediumhubtiltsensor.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/devices/technicmediumhubtiltsensor.ts b/src/devices/technicmediumhubtiltsensor.ts index b421a72..a03266f 100644 --- a/src/devices/technicmediumhubtiltsensor.ts +++ b/src/devices/technicmediumhubtiltsensor.ts @@ -27,9 +27,17 @@ export class TechnicMediumHubTiltSensor extends Device { * @param {number} y * @param {number} z */ - const z = -message.readInt16LE(4); + let z = -message.readInt16LE(4); const y = message.readInt16LE(6); const x = message.readInt16LE(8); + + // workaround for calibration problem or bug in technicMediumHub firmware 1.1.00.0000 + if(y === 90 || y === -90) { + z = Math.sign(y)*(z + 180); + if(z > 180) z -= 360; + if(z < -180) z += 360; + } + this.notify("tilt", { x, y, z }); break; }