From 81199facf2048b430e97064c7b0224ea55de0a0b Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Sun, 24 Dec 2023 14:14:02 -0700 Subject: [PATCH] box: switch to a different openevse component for ha --- flake.nix | 2 ++ hosts/box/default.nix | 29 +++------------------------- pkgs/openevse.nix | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 pkgs/openevse.nix diff --git a/flake.nix b/flake.nix index 5813743..ceaf166 100644 --- a/flake.nix +++ b/flake.nix @@ -325,6 +325,8 @@ }; hpi = upkgs.python3Packages.callPackage ./pkgs/hpi.nix { inherit upkgs; }; + openevse = + upkgs.python3Packages.callPackage ./pkgs/openevse.nix { inherit upkgs; }; promnesia = upkgs.python3Packages.callPackage ./pkgs/promnesia.nix { inherit upkgs; }; diff --git a/hosts/box/default.nix b/hosts/box/default.nix index a34d30a..353c2bc 100644 --- a/hosts/box/default.nix +++ b/hosts/box/default.nix @@ -297,6 +297,9 @@ in pymetno ical ]; + customComponents = [ + (pkgs.python3Packages.callPackage ../../pkgs/openevse.nix { inherit (pkgs.home-assistant) pkgs; }) + ]; extraComponents = [ "airthings" "airthings_ble" @@ -317,7 +320,6 @@ in "mqtt" "nextdns" "octoprint" - "openevse" "prometheus" "pushover" "rest" @@ -326,19 +328,6 @@ in ]; config = { sensor = [ - { - platform = "openevse"; - host = "10.6.0.166"; - monitored_variables = [ - "status" - "charge_time" - "rtc_temp" - "ir_temp" - "ambient_temp" - "usage_session" - "usage_total" - ]; - } ]; mqtt.sensor = [ { @@ -353,23 +342,11 @@ in state_topic = "greenhouse/humidity"; unit_of_measurement = "%"; } - { - name = "OpenEVSE Temperature"; - unique_id = "c55719a7-3e16-4249-9f9f-d93e8f0b10f1"; - icon = "mdi:thermometer"; - state_topic = "openevse/temp"; - device_class = "temperature"; - state_class = "measurement"; - unit_of_measurement = "°C"; - value_template = "{{ value|float / 10.0 }}"; - expire_after = 40; - } ]; logger = { default = "warning"; logs = { #"homeassistant.components.aprs" = "debug"; - "homeassistant.components.openevse" = "debug"; }; }; "automation manual" = [ diff --git a/pkgs/openevse.nix b/pkgs/openevse.nix new file mode 100644 index 0000000..c97e551 --- /dev/null +++ b/pkgs/openevse.nix @@ -0,0 +1,45 @@ +{ buildPythonPackage +, buildHomeAssistantComponent +, setuptools-scm +, setuptools +, fetchFromGitHub +, fetchPypi +, ... +}: +let + python-openevse-http = buildPythonPackage rec { + pname = "python-openevse-http"; + version = "0.1.57"; + + pyproject = true; + + nativeBuildInputs = [ setuptools ]; + + src = fetchPypi { + inherit pname version; + hash = "sha256-fyoXjOwsublB8K4MSaOirTH1r1g3ZxokQdMmglP51Fw="; + }; + }; +in +buildHomeAssistantComponent rec { + owner = "firstof9"; + domain = "openevse"; + version = "2.1.32"; + + nativeBuildInputs = [ + setuptools-scm + ]; + + propagatedBuildInputs = [ + python-openevse-http + ]; + + buildInputs = [ setuptools-scm ]; + + src = fetchFromGitHub { + inherit owner; + repo = domain; + rev = version; + hash = "sha256-7DsctUJKYR81DgJCDskCO79C8wHp0cpZP32vfjnxSHY="; + }; +}