From 6f8f877fb5563b7f32dad75e2c8660a3e1c0a21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Wed, 25 Dec 2024 19:02:00 +0100 Subject: [PATCH] curaco desk: Be less noisy --- curacao/desk/default.nix | 4 +--- curacao/desk/desk_mqtt.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/curacao/desk/default.nix b/curacao/desk/default.nix index 6423f6e..ae6f224 100644 --- a/curacao/desk/default.nix +++ b/curacao/desk/default.nix @@ -1,7 +1,5 @@ { pkgs, - lib, - config, ... }: let @@ -53,7 +51,7 @@ in SystemCallFilter = [ "@system-service" "~@privileged" - "~@resouces" + "~@resources" ]; UMask = "0077"; }; diff --git a/curacao/desk/desk_mqtt.py b/curacao/desk/desk_mqtt.py index 44c4002..ba123ff 100755 --- a/curacao/desk/desk_mqtt.py +++ b/curacao/desk/desk_mqtt.py @@ -32,8 +32,8 @@ class Desk: # CBD4+5 Configurator # https://www.linak.nl/technische-ondersteuning/#/cbd4-cbd6s-configurator # Connects, and settings can be changed. - # Don't think there's much that would help with our problem. - # Decompiled with Ghidra (hard), didn't go super far + # Don't think there's much that would help with our problem. + # Tried to decompile with Ghidra (hard), didn't go super far VEND = 0x12D3 PROD = 0x0002 @@ -265,7 +265,7 @@ class Desk: if __name__ == "__main__": - logging.basicConfig(level=logging.DEBUG) + logging.basicConfig() log = logging.getLogger(__name__) desk = Desk() @@ -344,10 +344,17 @@ if __name__ == "__main__": ) height_min = ha_mqtt_discoverable.sensors.Sensor(height_min_settings) + last_published_state = None + def fetch_callback(desk: Desk) -> None: - log.debug("Received state, sending") hcur = desk.get_height() hmin, hmax = desk.get_height_bounds() + global last_published_state + + state = hcur, hmin, hmax + if state == last_published_state: + return + last_published_state = state # If none this will set as unknown # Also readings can be a bit outside the boundaries,