From 91db9d4399c3da66a565f6b87f8b2e611d8a43fb Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Sun, 25 May 2025 16:46:40 +0200 Subject: [PATCH] odin: HASS climate configuration --- flake.nix | 77 ++++++++++++++++++++++++++------ instances/odin/configuration.nix | 12 ++--- 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index eb82362..bf17388 100644 --- a/flake.nix +++ b/flake.nix @@ -226,20 +226,69 @@ google-chrome = super.google-chrome.override { commandLineArgs = [ "--password-store=gnome" "--force-dark-mode" ]; }; brave = super.brave.override { commandLineArgs = "--ozone-platform=wayland --enable-features=UseOzonePlatform,WebRTCPipeWireCapturer"; }; sddm-theme-clairvoyance = super.sddm-theme-clairvoyance.override { wallpaper = ./wallpapers/background.jpg; }; - home-assistant-custom-components.smartir = super.home-assistant-custom-components.smartir.overrideAttrs - (_attr: rec { - version = "1.17.13"; - src = super.fetchFromGitHub { - owner = "smartHomeHub"; - repo = "SmartIR"; - rev = version; - hash = "sha256-fOd2MTBi0q+lBl6JYV1yGp9A42+BOD6/2SxYSBKy8fE="; - }; - patches = [ ]; - postPatch = '' - sed 's/Broadlink/ZHA/' codes/climate/1946.json > codes/climate/50.json - ''; - }); + + # smartir-zha = super.buildHomeAssistantComponent rec { + # owner = "smartHomeHub"; + # domain = "smartir"; + # version = "04ac27e"; + + # src = super.fetchFromGitHub { + # owner = "bertof"; + # repo = "SmartIR"; + # rev = "6f8cac1"; + # hash = "sha256-Xb6tL33vdevT2cRI80cNf744lKBHJDhFYiG2NsOlzaQ="; + # }; + + # patcher = super.fetchurl { + # url = "https://gist.githubusercontent.com/svyatogor/7839d00303998a9fa37eb48494dd680f/raw/66cba20e653f84aab0b9a31ea5b9ca497d038d8a/broadlink_to_tuya.py"; + # sha256 = "0m5fbfvsq8sxm0ghs8al8b6z4vfycqkr90qb10w9c4ryag2flnsh"; + # }; + + # postPatch = '' + # # ${super.python312}/bin/python3 ${patcher} codes/climate/1946.json > codes/climate/50.json + # cp codes/climate/1946.json codes/climate/50.json + # sed -i 's/MQTT/ZHA/' codes/climate/50.json + # ''; + + # dependencies = [ + # super.python313Packages.aiofiles + # super.python313Packages.distutils + # ]; + + # postInstall = '' + # cp -r codes $out/custom_components/smartir/ + # ''; + + # passthru.updateScript = super.nix-update-script { }; + + # meta = with super.lib; { + # changelog = "https://github.com/smartHomeHub/SmartIR/releases/tag/v${version}"; + # description = "Integration for Home Assistant to control climate, TV and fan devices via IR/RF controllers (Broadlink, Xiaomi, MQTT, LOOKin, ESPHome)"; + # homepage = "https://github.com/smartHomeHub/SmartIR"; + # maintainers = with maintainers; [ azuwis ]; + # license = licenses.mit; + # }; + # }; + + smartir-zha = super.home-assistant-custom-components.smartir.overrideAttrs (_attr: rec { + version = "04ac27e"; + src = super.fetchFromGitHub { + owner = "bertof"; + repo = "SmartIR"; + rev = "6f8cac1"; + hash = "sha256-5Ulb3z46bfIzztHTMNg/Vc26ru9K40242AsW37TLE18="; + }; + + patcher = super.fetchurl { + url = "https://gist.githubusercontent.com/svyatogor/7839d00303998a9fa37eb48494dd680f/raw/66cba20e653f84aab0b9a31ea5b9ca497d038d8a/broadlink_to_tuya.py"; + sha256 = "0m5fbfvsq8sxm0ghs8al8b6z4vfycqkr90qb10w9c4ryag2flnsh"; + }; + + postPatch = '' + # ${super.python312}/bin/python3 ${patcher} codes/climate/1946.json | sed 's/MQTT/ZHA' > codes/climate/50.json + sed 's/Broadlink/ZHA/' codes/climate/1946.json > codes/climate/50.json + ''; + }); # can be removed when https://github.com/NixOS/nixpkgs/pull/389711 is merged libfprint = super.libfprint.overrideAttrs (oldAttrs: { diff --git a/instances/odin/configuration.nix b/instances/odin/configuration.nix index c4565da..1dd9213 100644 --- a/instances/odin/configuration.nix +++ b/instances/odin/configuration.nix @@ -281,6 +281,7 @@ in logbook = { }; # logger.default = "debug"; logger.default = "info"; + logger.logs.zhaquirks = "debug"; # "map" = { }; mobile_app = { }; notify = [ @@ -320,18 +321,17 @@ in name = "Climatizzatore"; unique_id = "climatizzatore"; device_code = 50; - controller_data = "switch.tz3290_gnl5a6a5xvql7c2a_ts1201_interruttore"; + controller_data = "a4:9e:69:ff:fe:01:2c:03"; temperature_sensor = "sensor.tz3000_fllyghyj_ts0201_temperature"; humidity_sensor = "sensor.tz3000_fllyghyj_ts0201_humidity"; power_sensor = "binary_sensor.climatizzatore_acceso"; + power_sensor_restore_state = true; }]; }; configDir = "/var/lib/hass"; configWritable = true; extraPackages = ps: with ps; [ securetar ]; - customComponents = [ - pkgs.home-assistant-custom-components.smartir - ]; + customComponents = [ pkgs.smartir-zha ]; extraComponents = [ "default_config" @@ -375,6 +375,7 @@ in "media_player" "met" "meteoalarm" + "mqtt" "network" # "nextcloud" "nmap_tracker" @@ -409,7 +410,8 @@ in "zoneminder" ]; }; - logind.lidSwitch = "ignore"; + logind.lidSwitch = + "ignore"; pipewire = { enable = true; pulse.enable = true;