parent
70368dd016
commit
7dd626c80e
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue