parent
70368dd016
commit
7dd626c80e
|
@ -75,11 +75,13 @@ func (c *RestClient) CallServices(inputs ...*CallServiceInput) error {
|
||||||
go func(input *CallServiceInput) {
|
go func(input *CallServiceInput) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
err := c.CallService(input.EntityID, input.Service, input.Extras)
|
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)
|
}(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
var returnErrors []error
|
returnErrors := []error{}
|
||||||
for err := range errorChannel {
|
for err := range errorChannel {
|
||||||
returnErrors = append(returnErrors, err)
|
returnErrors = append(returnErrors, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,11 @@ func (c *RestClient) SetThermostatState(entityId string, desiredState Thermostat
|
||||||
return c.CallService(entityId, Services.TurnOff)
|
return c.CallService(entityId, Services.TurnOff)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.CallService(entityId, Services.TurnOn)
|
if state, _ := c.GetState(entityId); !StateToBool(state.State) {
|
||||||
if err != nil {
|
err := c.CallService(entityId, Services.TurnOn)
|
||||||
return fmt.Errorf("error turning on thermostat: %w", err)
|
if err != nil {
|
||||||
|
return fmt.Errorf("error turning on thermostat: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extras := map[string]any{
|
extras := map[string]any{
|
||||||
|
|
Loading…
Reference in New Issue