diff --git a/go.mod b/go.mod index be24457ed..00b2bf69c 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/BurntSushi/toml v1.4.0 github.com/PuerkitoBio/goquery v1.9.2 github.com/andig/go-powerwall v0.2.1-0.20230808194509-dd70cdb6e140 - github.com/andig/gosunspec v0.0.0-20231205122018-1daccfa17912 + github.com/andig/gosunspec v0.0.0-20240918203654-860ce51d602b github.com/andig/mbserver v0.0.0-20230310211055-1d29cbb5820e github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef github.com/aws/aws-sdk-go v1.55.5 diff --git a/go.sum b/go.sum index 2c9deba1d..28430257b 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/andig/go-powerwall v0.2.1-0.20230808194509-dd70cdb6e140 h1:C93T8vg7CN4Q4BBDbBMOvBoTYBA+CaBEvlY2SZF8aa0= github.com/andig/go-powerwall v0.2.1-0.20230808194509-dd70cdb6e140/go.mod h1:Xk09mD+7RTCuuHMX5RxlqgEUeh9oZdIX0rL0qiY6l/4= -github.com/andig/gosunspec v0.0.0-20231205122018-1daccfa17912 h1:pphS+WUa9zK0ZH/Rt2JMEaOx0qz8dDzOzbr/W7BMiXQ= -github.com/andig/gosunspec v0.0.0-20231205122018-1daccfa17912/go.mod h1:c6P6szcR+ROkqZruOR4f6qbDKFjZX6OitPpj+yJ/r8k= +github.com/andig/gosunspec v0.0.0-20240918203654-860ce51d602b h1:81UMfM949I7StrRay7YDUZazY8M1u/JHkzwcFEjiilQ= +github.com/andig/gosunspec v0.0.0-20240918203654-860ce51d602b/go.mod h1:c6P6szcR+ROkqZruOR4f6qbDKFjZX6OitPpj+yJ/r8k= github.com/andig/mbserver v0.0.0-20230310211055-1d29cbb5820e h1:m/NTP3JWpR7M0ljLxiQU4fzR25jjhe1LDtxLMNcoNJQ= github.com/andig/mbserver v0.0.0-20230310211055-1d29cbb5820e/go.mod h1:4VtYzTm//oUipwvO3yh0g/udTE7pYJM+U/kyAuFDsgM= github.com/andig/yaml v0.0.0-20240531135838-1ff5761ab467 h1:JqIoHxsQSV39xaemvVRu3HOkSf5AbhQ1YEENJa2cL3Q= diff --git a/provider/modbus_sunspec.go b/provider/modbus_sunspec.go index 90e64c8af..5f16b44f4 100644 --- a/provider/modbus_sunspec.go +++ b/provider/modbus_sunspec.go @@ -161,8 +161,6 @@ func (m *ModbusSunspec) blockPoint() (block sunspec.Block, point sunspec.Point, return block, point, err } -// TODO scale factors - var _ SetFloatProvider = (*Modbus)(nil) // FloatSetter executes configured modbus write operation and implements SetFloatProvider @@ -213,6 +211,7 @@ func (m *ModbusSunspec) IntSetter(_ string) (func(int64) error, error) { val = int64(float64(val) * m.scale) + // SetValue is used to include the scale factor when writing switch typ { case typelabel.Bitfield16: point.SetBitfield16(sunspec.Bitfield16(val)) @@ -223,17 +222,17 @@ func (m *ModbusSunspec) IntSetter(_ string) (func(int64) error, error) { case typelabel.Enum32: point.SetEnum32(sunspec.Enum32(val)) case typelabel.Int16: - point.SetInt16(int16(val)) + point.SetValue(int16(val)) case typelabel.Int32: - point.SetInt32(int32(val)) + point.SetValue(int32(val)) case typelabel.Int64: - point.SetInt64(val) + point.SetValue(val) case typelabel.Uint16: - point.SetUint16(uint16(val)) + point.SetValue(uint16(val)) case typelabel.Uint32: - point.SetUint32(uint32(val)) + point.SetValue(uint32(val)) case typelabel.Uint64: - point.SetUint64(uint64(val)) + point.SetValue(uint64(val)) default: return fmt.Errorf("invalid point type: %s", typ) }