From 204f372be24ab21a4e1982c6c06a3e44e921a8d5 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Fri, 8 Nov 2024 22:55:23 +0100 Subject: [PATCH] fix mill --- services/mill/wifi.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/mill/wifi.go b/services/mill/wifi.go index 33f4db8..8194667 100644 --- a/services/mill/wifi.go +++ b/services/mill/wifi.go @@ -20,7 +20,8 @@ type WifiBridge struct { ID string IP string - state *device.State + state *device.State + desiredState device.State mx sync.Mutex started bool @@ -36,6 +37,8 @@ func (w *WifiBridge) SetState(id string, state device.State) bool { return false } + w.desiredState = state + return true } @@ -93,9 +96,7 @@ func (w *WifiBridge) refresh() error { }) } - w.state.Temperature = gentools.Ptr(*w.state.Temperature - math.Mod(*w.state.Temperature, 0.5)) - - if math.Abs(temp-*w.state.Temperature) >= 0.1 { + if w.desiredState.Temperature != nil && math.Abs(temp-*w.desiredState.Temperature) >= 0.1 { if err := w.writeTemperature(); err != nil { return err }