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,10 +69,12 @@ func (c *RestClient) SetThermostatState(entityId string, desiredState Thermostat
|
||||||
return c.CallService(entityId, Services.TurnOff)
|
return c.CallService(entityId, Services.TurnOff)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if state, _ := c.GetState(entityId); !StateToBool(state.State) {
|
||||||
err := c.CallService(entityId, Services.TurnOn)
|
err := c.CallService(entityId, Services.TurnOn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error turning on thermostat: %w", err)
|
return fmt.Errorf("error turning on thermostat: %w", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extras := map[string]any{
|
extras := map[string]any{
|
||||||
"hvac_mode": string(desiredState.Mode),
|
"hvac_mode": string(desiredState.Mode),
|
||||||
|
|
Loading…
Reference in New Issue