fix: modbus for amtron updates

This commit is contained in:
oddlama 2025-01-29 02:17:07 +01:00
parent f70e9e83f8
commit 40ce6c041e
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
3 changed files with 13 additions and 13 deletions

View file

@ -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";
}

View file

@ -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

View file

@ -19,7 +19,7 @@
age.secrets.hass-influxdb-token = {
generator.script = "alnum";
mode = "440";
group = "hass";
group = "influxdb2";
};
environment.persistence."/persist".directories = [