diff --git a/hosts/sausebiene/hass-modbus/mennekes-amtron-xtra.nix b/hosts/sausebiene/hass-modbus/mennekes-amtron-xtra.nix index 8e29b9e..6e608f9 100644 --- a/hosts/sausebiene/hass-modbus/mennekes-amtron-xtra.nix +++ b/hosts/sausebiene/hass-modbus/mennekes-amtron-xtra.nix @@ -9,26 +9,25 @@ { delay = 1; host = globals.net.home-lan.vlans.devices.hosts.wallbox.ipv4; - name = "Amtron Xtra 22 C2"; + name = "amtron_xtra_22_c2"; port = 502; - retries = 1; - retry_on_empty = true; + timeout = 10; + message_wait_milliseconds = 100; + type = "tcp"; sensors = [ { address = 768; count = 38; data_type = "custom"; input_type = "input"; - lazy_error_count = 1; name = "Amtron Registers"; precision = 0; - scan_interval = 120; + scan_interval = 30; slave = 255; structure = ">2h15H22B10H"; } { address = 1024; - count = 1; data_type = "uint16"; device_class = "current"; input_type = "holding"; @@ -39,7 +38,6 @@ } { address = 1025; - count = 1; data_type = "uint16"; input_type = "holding"; name = "Amtron Change Charge State"; @@ -47,8 +45,6 @@ unique_id = "amtron_change_charge_state"; } ]; - timeout = 10; - type = "tcp"; } ]; template = [ @@ -229,9 +225,9 @@ {% set ns = namespace(name = ''') -%} {% set input = states('sensor.amtron_registers').split(',')[17:40] -%} {% for i in range(0,11) -%} - {% set ns.name = ns.name ~ \"%c\"%input[i*2+1]|int ~ \"%c\"%input[i*2]|int -%} + {% set ns.name = ns.name ~ "%c"%input[i*2+1]|int ~ "%c"%input[i*2]|int -%} {% endfor %} - {{ ns.name.replace('\\x00',''') }} + {{ ns.name.replace('\x00',''') }} ''; unique_id = "amtron_wallbox_name"; } diff --git a/hosts/sausebiene/home-assistant.nix b/hosts/sausebiene/home-assistant.nix index dc1fc23..8ab6cf0 100644 --- a/hosts/sausebiene/home-assistant.nix +++ b/hosts/sausebiene/home-assistant.nix @@ -125,6 +125,7 @@ in adguardhome dwdwfsapi fritzconnection + getmac gtts psycopg2 pyatv @@ -140,6 +141,9 @@ in }; systemd.services.home-assistant = { + serviceConfig.LoadCredential = [ + "hass-influxdb-token:${config.age.secrets.hass-influxdb-token.path}" + ]; preStart = lib.mkBefore '' if [[ -e ${config.services.home-assistant.configDir}/secrets.yaml ]]; then rm ${config.services.home-assistant.configDir}/secrets.yaml @@ -147,7 +151,7 @@ in # Update influxdb token # We don't use -i because it would require chown with is a @privileged syscall - INFLUXDB_TOKEN="$(cat ${config.age.secrets.hass-influxdb-token.path})" \ + INFLUXDB_TOKEN="$(cat "$CREDENTIALS_DIRECTORY/hass-influxdb-token")" \ ${lib.getExe pkgs.yq-go} '.influxdb_token = strenv(INFLUXDB_TOKEN)' \ ${ config.age.secrets."home-assistant-secrets.yaml".path diff --git a/hosts/sausebiene/influxdb.nix b/hosts/sausebiene/influxdb.nix index fa006d4..e09a967 100644 --- a/hosts/sausebiene/influxdb.nix +++ b/hosts/sausebiene/influxdb.nix @@ -19,7 +19,7 @@ age.secrets.hass-influxdb-token = { generator.script = "alnum"; mode = "440"; - group = "hass"; + group = "influxdb2"; }; environment.persistence."/persist".directories = [