From 1cafc24627ab33cb22ed182735d2f3b0e11a76d5 Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 1 Mar 2025 11:31:35 +0100 Subject: [PATCH] Modbus Proxy: fix yaml serialisation (#19279) --- api/globalconfig/types.go | 4 ++-- util/modbus/modbus.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/globalconfig/types.go b/api/globalconfig/types.go index 0c4e2fb9a..03365666d 100644 --- a/api/globalconfig/types.go +++ b/api/globalconfig/types.go @@ -54,8 +54,8 @@ type Go struct { type ModbusProxy struct { Port int - ReadOnly string - modbus.Settings `mapstructure:",squash"` + ReadOnly string `yaml:",omitempty" json:",omitempty"` + modbus.Settings `mapstructure:",squash" yaml:",inline,omitempty" json:",omitempty"` } var _ api.Redactor = (*Hems)(nil) diff --git a/util/modbus/modbus.go b/util/modbus/modbus.go index d9852b3cf..52dcaae35 100644 --- a/util/modbus/modbus.go +++ b/util/modbus/modbus.go @@ -32,12 +32,12 @@ type TcpSettings struct { // Settings contains the ModBus settings type Settings struct { - ID uint8 - SubDevice int - URI, Device, Comset string - Baudrate int - UDP bool - RTU *bool // indicates RTU over TCP if true + ID uint8 `json:",omitempty" yaml:",omitempty"` + SubDevice int `json:",omitempty" yaml:",omitempty"` + URI, Device, Comset string `json:",omitempty" yaml:",omitempty"` + Baudrate int `json:",omitempty" yaml:",omitempty"` + UDP bool `json:",omitempty" yaml:",omitempty"` + RTU *bool `json:",omitempty" yaml:",omitempty"` } // Protocol identifies the wire format from the RTU setting