fix: send only to enabled remotes data
This commit is contained in:
parent
cc16bb9555
commit
7b18b115c8
@ -28,6 +28,7 @@ func SendTemperatures(temperatures []*stypes.Temperature, configDir string) erro
|
||||
temperaturesAsReader := bytes.NewReader(temperaturesAsBytes)
|
||||
|
||||
for _, remote := range cnf.Remotes {
|
||||
if remote.Enabled {
|
||||
requestURL := fmt.Sprintf("%s%s", remote.Address, "/temperatures")
|
||||
req, err := http.NewRequest("POST", requestURL, temperaturesAsReader)
|
||||
if err != nil {
|
||||
@ -49,6 +50,7 @@ func SendTemperatures(temperatures []*stypes.Temperature, configDir string) erro
|
||||
return fmt.Errorf("Invalid HTTP-Statuscode - expected 200, got %d: %v", resp.StatusCode, string(b))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
|
@ -37,15 +37,20 @@ func Get(sensorNames []string, push bool, configDir string, w io.Writer) error {
|
||||
if len(sensorNames) > 0 {
|
||||
for _, sensorName := range sensorNames {
|
||||
for _, sensor := range cnf.Sensors {
|
||||
if sensorName == *sensor.SensorName ||
|
||||
sensorName == sensor.SensorID ||
|
||||
sensorName == *sensor.WireID {
|
||||
if sensorName == *sensor.SensorName && *sensor.SensorEnabled ||
|
||||
sensorName == sensor.SensorID && *sensor.SensorEnabled ||
|
||||
sensorName == *sensor.WireID && *sensor.SensorEnabled {
|
||||
sensors = append(sensors, sensor)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sensors = append(sensors, cnf.Sensors...)
|
||||
for _, sensor := range cnf.Sensors {
|
||||
if *sensor.SensorEnabled {
|
||||
sensors = append(sensors, sensor)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check if sensor exists in cnf and has a wire id
|
||||
|
Loading…
Reference in New Issue
Block a user