From 6a738c45220a88257333332fb758e2fdfd238a48 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Sun, 23 Jun 2024 21:03:21 +0100 Subject: [PATCH] Update DeviceWorkarounds to new da. --- go.mod | 2 +- go.sum | 2 ++ implcaps/generic/device_workarounds/impl.go | 11 +++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 68829d0..f5483c7 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 require ( github.com/expr-lang/expr v1.16.9 github.com/shimmeringbee/callbacks v0.0.0-20240614104656-b56cd6b4b604 - github.com/shimmeringbee/da v0.0.0-20240622202110-ccbf24700388 + github.com/shimmeringbee/da v0.0.0-20240623195712-c921021ae9f9 github.com/shimmeringbee/logwrap v0.1.3 github.com/shimmeringbee/persistence v0.0.0-20240615183316-1a60e6781413 github.com/shimmeringbee/retry v0.0.0-20240614104711-064c2726a8b4 diff --git a/go.sum b/go.sum index 0d97b90..188f59e 100644 --- a/go.sum +++ b/go.sum @@ -16,6 +16,8 @@ github.com/shimmeringbee/callbacks v0.0.0-20240614104656-b56cd6b4b604 h1:he/14/5 github.com/shimmeringbee/callbacks v0.0.0-20240614104656-b56cd6b4b604/go.mod h1:1AzT3lP4dAEaqWDdWsldhRtcl0+jyCGcZaBTHTjtA9w= github.com/shimmeringbee/da v0.0.0-20240622202110-ccbf24700388 h1:opK7x4lWbylMm5PfCzixiG7s07FtinqNlbCat+Md7+c= github.com/shimmeringbee/da v0.0.0-20240622202110-ccbf24700388/go.mod h1:jUKTa353LvJT3TAdwtmfGEbcxkYbG58h0gbASRf0FIs= +github.com/shimmeringbee/da v0.0.0-20240623195712-c921021ae9f9 h1:beGPxE5b7k6Pz7ND7Ii1S4zf01S5tmQQlW3eI6FW/z4= +github.com/shimmeringbee/da v0.0.0-20240623195712-c921021ae9f9/go.mod h1:jUKTa353LvJT3TAdwtmfGEbcxkYbG58h0gbASRf0FIs= github.com/shimmeringbee/logwrap v0.1.3 h1:1PqPGdgbeQxACQqc6RUWERn7EnpA1jbiHzXVYFa7q2A= github.com/shimmeringbee/logwrap v0.1.3/go.mod h1:NBAcZCUl6aFOGnWTs8m67EUAmWFZXRhoRQf5nknY8W0= github.com/shimmeringbee/persistence v0.0.0-20240615183316-1a60e6781413 h1:0t4xEtg+kXXATiryn0m9p5OmsvDUvh2BPG+r7Vcpvy4= diff --git a/implcaps/generic/device_workarounds/impl.go b/implcaps/generic/device_workarounds/impl.go index c686493..7d97d04 100644 --- a/implcaps/generic/device_workarounds/impl.go +++ b/implcaps/generic/device_workarounds/impl.go @@ -51,6 +51,8 @@ func (i *Implementation) Load(ctx context.Context) (bool, error) { for _, workaround := range i.workaroundsEnabled { if err := i.loadWorkaround(ctx, workaround); err != nil { return false, err + } else { + i.workaroundsEnabled = append(i.workaroundsEnabled, "ZCLReportingKeepAlive") } } @@ -96,11 +98,11 @@ func (i *Implementation) ImplName() string { return "GenericDeviceWorkarounds" } -func (i *Implementation) Enabled(_ context.Context) []string { +func (i *Implementation) Enabled(_ context.Context) ([]string, error) { i.m.RLock() defer i.m.RUnlock() - return i.workaroundsEnabled + return i.workaroundsEnabled, nil } func (i *Implementation) loadWorkaround(ctx context.Context, workaround string) error { @@ -135,5 +137,10 @@ func (i *Implementation) enumerateZCLReportingKeepAlive(ctx context.Context, m m i.s.Section("Workarounds", "ZCLReportingKeepAlive") + i.m.Lock() + defer i.m.Unlock() + + i.workaroundsEnabled = append(i.workaroundsEnabled, "ZCLReportingKeepAlive") + return nil }