Compare commits

...

4 commits

Author SHA1 Message Date
Patrick d999cb30aa
chore: remove varta packages 2025-01-10 16:36:53 +01:00
Patrick f961ee9b17
fix: hostapd broke again 2025-01-10 16:36:41 +01:00
Patrick 7d6e959d90
fix: varta via modbus 2025-01-10 16:36:07 +01:00
Patrick b4c68efe53
fix: allow vaultwarden access for leaking vpn 2025-01-10 16:35:52 +01:00
8 changed files with 240 additions and 84 deletions

View file

@ -45,6 +45,7 @@
"||testberry.internal^$dnsrewrite=${lib.net.cidr.host 31 globals.net.vlans.devices.cidrv4}"
"||smb.internal^$dnsrewrite=${lib.net.cidr.host globals.services.samba.ip globals.net.vlans.home.cidrv4}"
"||${globals.domains.web}^$dnsrewrite=${lib.net.cidr.host 1 globals.net.vlans.services.cidrv4}"
"@@||${globals.services.vaultwarden.domain}"
"||fritz.box^$dnsrewrite=${lib.net.cidr.host 1 "10.99.2.0/24"}"
];
dhcp.enabled = false;

View file

@ -54,7 +54,6 @@
];
customComponents = with pkgs.home-assistant-custom-components; [
homematicip_local
pkgs.havartastorage
];
config = {
http = {
@ -96,6 +95,223 @@
# organization = "home";
# bucket = "home_assistant";
# };
# Modbus Varta element backup
modbus = {
name = "mb_varta";
type = "tcp";
host = "10.99.30.20"; # replace with your ip of the your varta;
port = 502;
delay = 1;
timeout = 3;
message_wait_milliseconds = 250;
sensors =
### EMS Software Version { not for Varta link;
[
{
name = "mb_varta_EMS";
slave = 1;
address = 1000;
count = 17;
data_type = "string";
precision = 0;
scale = 1;
}
### ENS Software Version { not for Varta link;
{
name = "mb_varta_ENS";
slave = 1;
address = 1017;
count = 17;
data_type = "string";
precision = 0;
scale = 1;
}
### Software Version { not for Varta link;
{
name = "mb_varta_software";
slave = 1;
address = 1034;
count = 17;
data_type = "string";
precision = 0;
scale = 1;
}
### Table version;
{
name = "mb_varta_table_version";
slave = 1;
address = 1051;
data_type = "uint16";
precision = "0";
scale = 1;
### timestamp {- not working;
}
{
name = "mb_varta_timestamp";
slave = 1;
address = 1052;
data_type = "uint32";
swap = "word";
precision = 0;
scale = 1;
}
### Serial Number;
{
name = "mb_varta_serial";
slave = 1;
address = 1054;
count = 10;
data_type = "string";
precision = 0;
scale = 1;
}
### Number of Battery Modules installed;
{
name = "mb_varta_installed_batteries";
slave = 1;
address = 1064;
data_type = "uint16";
precision = 0;
scale = 1;
}
### State;
{
name = "mb_varta_state";
slave = 1;
address = 1065;
data_type = "uint16";
precision = 0;
scale = 1;
unit_of_measurement = "State";
}
### Active Power { positive=charge / negative: discharge;
{
name = "mb_varta_active_power";
slave = 1;
address = 1066;
data_type = "int16";
precision = 0;
scale = 1;
device_class = "power";
unit_of_measurement = "W";
}
### Apparent Power { positive=charge / negative: discharge;
{
name = "mb_varta_apparent_power";
slave = 1;
address = 1067;
data_type = "int16";
precision = 0;
scale = 1;
device_class = "apparent_power";
unit_of_measurement = "VA";
}
### State of Charge;
{
name = "mb_varta_SOC";
slave = 1;
address = 1068;
data_type = "uint16";
precision = 0;
scale = 1;
device_class = "battery";
unit_of_measurement = "%";
}
### energy counter AC{>DC - not sure if correct;
{
name = "mb_varta_ACDC";
slave = 1;
address = 1069;
data_type = "uint32";
swap = "word";
precision = 0;
scale = 1;
device_class = "energy";
unit_of_measurement = "Wh";
state_class = "total_increasing";
}
### Installed capacity;
{
name = "mb_varta_capacity";
slave = 1;
address = 1071;
data_type = "uint16";
precision = 0;
scale = 10;
device_class = "energy";
unit_of_measurement = "Wh";
}
### Grid Power;
{
name = "mb_varta_grid_power";
slave = 1;
address = 1078;
data_type = "int16";
precision = 0;
scale = 1;
device_class = "power";
unit_of_measurement = "W";
}
];
};
# Varta input/output
template.sensor = [
{
name = "Varta Input Power";
unit_of_measurement = "W";
state_class = "measurement";
device_class = "power";
state = ''
{% if states('sensor.mb_varta_active_power') | float(0) >= 0 %}
{% set varta_in = states('sensor.mb_varta_active_power') | float(0) %}
{% else %}
{% set varta_in = 0 %}
{% endif %}
{{ varta_in }}
'';
}
{
name = "Varta Output Power";
unit_of_measurement = "W";
state_class = "measurement";
device_class = "power";
state = ''
{% if states('sensor.mb_varta_active_power') | float(0) <= 0 %}
{% set varta_out = states('sensor.mb_varta_active_power') | float(0) *-1 %}
{% else %}
{% set varta_out = 0 %}
{% endif %}
{{ varta_out }}
'';
}
];
##Grid
sensor = {
platform = "template";
sensors = {
mb_varta_status = {
friendly_name = "Varta Status";
value_template = ''
{% set mapper = {
'0' : 'Busy',
'1' : 'Run',
'2' : 'Charge',
'3' : 'Discharge',
'4' : 'Standby',
'5' : 'Error',
'6' : 'Service',
'7' : 'Islanding' } %}
{% set state = states.sensor.mb_varta_state.state %}
{{ mapper[state] if state in mapper else 'Unknown' }}
'';
};
};
};
};
extraPackages =
python3Packages: with python3Packages; [

View file

@ -2,6 +2,7 @@
globals,
config,
pkgs,
lib,
...
}:
{
@ -17,15 +18,21 @@
guestWlan = {
generator.script = "alnum";
};
iotWlan = {
generator.script = "alnum";
};
};
systemd.services.hostapd.stopIfChanged = false;
systemd.services.hostapd.restartIfChanged = false;
systemd.services.hostapd.reloadTriggers = lib.mkForce [ ];
networking.nftables.firewall.zones.wlan.interfaces = [ "wlan1" ];
networking.nftables.firewall.zones.home.interfaces = [ "br-home" ];
networking.nftables.firewall.rules.wifi-forward = {
from = [ "wlan" ];
to = [ "home" ];
verdict = "accept";
};
# networking.nftables.firewall.zones.wlan.interfaces = [ "wlan1" ];
# networking.nftables.firewall.zones.home.interfaces = [ "br-home" ];
# networking.nftables.firewall.rules.wifi-forward = {
# from = [ "wlan" ];
# to = [ "home" ];
# verdict = "accept";
# };
services.hostapd = {
enable = true;
radios.wlan01 = {
@ -57,10 +64,10 @@
apIsolate = true;
# not supporte by laptop :(
# settings.ieee80211w = 0;
settings.bridge = "br-home";
settings.vlan_file = "${pkgs.writeText "hostaps.vlans" ''
10 wifi-home br-home
50 wifi-guest br-guest
40 wifi-iot br-iot
50 wifi-guests br-guests
''}";
authentication = {
saePasswords = [
@ -68,6 +75,10 @@
passwordFile = config.age.secrets.homeWlan.path;
vlanid = 10;
}
{
passwordFile = config.age.secrets.iotWlan.path;
vlanid = 40;
}
{
passwordFile = config.age.secrets.guestWlan.path;
vlanid = 50;

Binary file not shown.

View file

@ -1,5 +1,5 @@
diff --git a/nixos/modules/services/networking/hostapd.nix b/nixos/modules/services/networking/hostapd.nix
index 8635dea738ce2..12821fc9f07c1 100644
index 8635dea738ce2..28dd6db874bc4 100644
--- a/nixos/modules/services/networking/hostapd.nix
+++ b/nixos/modules/services/networking/hostapd.nix
@@ -1,4 +1,10 @@
@ -2000,7 +2000,7 @@ index 8635dea738ce2..12821fc9f07c1 100644
+ (
+ echo -n 'sae_password='
+ ${optionalString (entry.passwordFile != null) ''tr -d '\n' < ${entry.passwordFile}''}
+ cat <<< '${escapeShellArg lineSuffix}'
+ echo ${escapeShellArg lineSuffix}
+ ) >> "$HOSTAPD_CONFIG_FILE"
+ ''
+ ) bssCfg.authentication.saePasswords

View file

@ -9,7 +9,6 @@ _inputs: [
mongodb-bin = prev.callPackage ./mongodb-bin.nix { };
disneyplus = prev.callPackage ./disney.nix { };
awakened-poe-trade = prev.callPackage ./awakened-poe-trade.nix { };
havartastorage = prev.callPackage ./havartastorage.nix { };
neovim-clean = prev.neovim-unwrapped.overrideAttrs (
_neovimFinal: neovimPrev: {
nativeBuildInputs = (neovimPrev.nativeBuildInputs or [ ]) ++ [ prev.makeWrapper ];
@ -22,7 +21,6 @@ _inputs: [
);
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
(_pythonFinal: _pythonPrev: {
vartastorage = prev.callPackage ./pyvartastorage.nix { };
})
];

View file

@ -1,30 +0,0 @@
{
lib,
fetchFromGitHub,
buildHomeAssistantComponent,
python3Packages,
}:
buildHomeAssistantComponent rec {
owner = "Vip0r";
domain = "varta_storage";
version = "2025-1-9-unstable";
src = fetchFromGitHub {
inherit owner;
repo = "varta_storage";
rev = "592cfd8692b24b131cadaa8c6280660fdc262886";
hash = "sha256-u5VneR7s3V+NjoTnDYPAO2aJeqpDQwPu5Eko5CZQXTw=";
};
dependencies = [
python3Packages.vartastorage
];
meta = with lib; {
description = "Send notifications with ntfy.sh and selfhosted ntfy-servers";
homepage = "https://github.com/hbrennhaeuser/homeassistant_integration_ntfy";
maintainers = with maintainers; [ koral ];
license = licenses.gpl3;
};
}

View file

@ -1,40 +0,0 @@
{
lib,
python3Packages,
fetchFromGitHub,
}:
python3Packages.buildPythonPackage rec {
pname = "vartastorage";
version = "2025.1.9";
disabled = python3Packages.pythonOlder "3.12";
src = fetchFromGitHub {
owner = "Vip0r";
repo = "vartastorage";
rev = "5e24b25dbafeabceefd513001f3b8b6a598463a1";
hash = "sha256-8eZOTQUbv7ing05aIYYJcP3zfLc91plC7QNqM7a3ZZQ=";
};
__darwinAllowLocalNetworking = true;
build-system = [ ];
dependencies = [
];
nativeCheckInputs = [
];
meta = with lib; {
description = "Python module to interact with HomeMatic devices";
homepage = "https://github.com/SukramJ/hahomematic";
changelog = "https://github.com/SukramJ/hahomematic/blob/${src.tag}/changelog.md";
license = licenses.mit;
maintainers = with maintainers; [
dotlambda
fab
];
};
}