@@ -21,6 +21,7 @@ type WifiBridge struct {
|
|||||||
IP string
|
IP string
|
||||||
|
|
||||||
state *device.State
|
state *device.State
|
||||||
|
desiredState device.State
|
||||||
|
|
||||||
mx sync.Mutex
|
mx sync.Mutex
|
||||||
started bool
|
started bool
|
||||||
@@ -36,6 +37,8 @@ func (w *WifiBridge) SetState(id string, state device.State) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.desiredState = state
|
||||||
|
|
||||||
return true
|
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 w.desiredState.Temperature != nil && math.Abs(temp-*w.desiredState.Temperature) >= 0.1 {
|
||||||
|
|
||||||
if math.Abs(temp-*w.state.Temperature) >= 0.1 {
|
|
||||||
if err := w.writeTemperature(); err != nil {
|
if err := w.writeTemperature(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user