1
0
Fork 0
main v0.17.1
Jordan Hotmann 2023-12-14 06:27:22 -07:00
parent 70368dd016
commit 7dd626c80e
No known key found for this signature in database
GPG Key ID: 01B504170C2A2EA3
2 changed files with 9 additions and 5 deletions

View File

@ -75,11 +75,13 @@ func (c *RestClient) CallServices(inputs ...*CallServiceInput) error {
go func(input *CallServiceInput) {
defer wg.Done()
err := c.CallService(input.EntityID, input.Service, input.Extras)
errorChannel <- err
if err != nil {
errorChannel <- fmt.Errorf("error calling service %s for %s: %w", input.Service, input.EntityID, err)
}
}(input)
}
var returnErrors []error
returnErrors := []error{}
for err := range errorChannel {
returnErrors = append(returnErrors, err)
}

View File

@ -69,9 +69,11 @@ func (c *RestClient) SetThermostatState(entityId string, desiredState Thermostat
return c.CallService(entityId, Services.TurnOff)
}
err := c.CallService(entityId, Services.TurnOn)
if err != nil {
return fmt.Errorf("error turning on thermostat: %w", err)
if state, _ := c.GetState(entityId); !StateToBool(state.State) {
err := c.CallService(entityId, Services.TurnOn)
if err != nil {
return fmt.Errorf("error turning on thermostat: %w", err)
}
}
extras := map[string]any{