Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/home-assistant: add support for amshan #355055

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nixos/modules/services/home-automation/home-assistant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ in {
"zha"
"zwave"
"zwave_js"

# Custom components, maintained manually.
"amshan"
];
in {
ExecStart = escapeSystemdExecArgs ([
Expand Down
50 changes: 50 additions & 0 deletions pkgs/development/python-modules/amshan/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
setuptools,
construct,
paho-mqtt,
pyserial-asyncio,
pytestCheckHook,
}:

buildPythonPackage rec {
pname = "amshan";
version = "2.1.1";
pyproject = true;

src = fetchFromGitHub {
owner = "toreamun";
repo = "amshan";
rev = version;
hash = "sha256-aw0wTqb2s84STVUN55h6L926pXwaMSppBCfXZVb87w0=";
};

build-system = [
setuptools
];

dependencies = [
construct
paho-mqtt
pyserial-asyncio
];

bjornfor marked this conversation as resolved.
Show resolved Hide resolved
nativeCheckInputs = [
pytestCheckHook
];

pythonImportsCheck = [ "han" ];

meta = {
description = "Decode smart power meter data stream of Cosem HDLC frames used by MBUS";
longDescription = ''
The package has special support of formats for Aidon, Kaifa and Kamstrup
meters used in Norway and Sweden (AMS HAN).
'';
homepage = "https://github.com/toreamun/amshan";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ bjornfor ];
};
}
34 changes: 34 additions & 0 deletions pkgs/servers/home-assistant/custom-components/amshan/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
lib,
fetchFromGitHub,
buildHomeAssistantComponent,
amshan,
}:

buildHomeAssistantComponent rec {
owner = "toreamun";
domain = "amshan";
version = "2024.12.0";

src = fetchFromGitHub {
owner = "toreamun";
repo = "amshan-homeassistant";
tag = version;
hash = "sha256-L7TGdUjDvIRP9dHIkng9GYwilmRzhGbUK6ivx8PVtQ4=";
};

dependencies = [
amshan
];

meta = {
description = "Home Assistant integration for electricity meters (AMS/HAN/P1)";
longDescription = ''
The integration supports both streaming (serial port / TCP/IP) and MQTT
(Tibber Pulse, energyintelligence.se etc.).
'';
homepage = "https://github.com/toreamun/amshan-homeassistant";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ bjornfor ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ self: super: with self; {

amqtt = callPackage ../development/python-modules/amqtt { };

amshan = callPackage ../development/python-modules/amshan { };

anchor-kr = callPackage ../development/python-modules/anchor-kr { };

ancp-bids = callPackage ../development/python-modules/ancp-bids { };
Expand Down