| 226 | } |
| 227 | |
| 228 | func (sm *SmartManager) parseConfiguredDevices(config string) ([]*DeviceInfo, error) { |
| 229 | splitChar, _ := utils.GetEnv("SMART_DEVICES_SEPARATOR") |
| 230 | if splitChar == "" { |
| 231 | splitChar = "," |
| 232 | } |
| 233 | entries := strings.Split(config, splitChar) |
| 234 | devices := make([]*DeviceInfo, 0, len(entries)) |
| 235 | for _, entry := range entries { |
| 236 | entry = strings.TrimSpace(entry) |
| 237 | if entry == "" { |
| 238 | continue |
| 239 | } |
| 240 | |
| 241 | parts := strings.SplitN(entry, ":", 2) |
| 242 | |
| 243 | name := strings.TrimSpace(parts[0]) |
| 244 | if name == "" { |
| 245 | return nil, fmt.Errorf("invalid SMART_DEVICES entry %q", entry) |
| 246 | } |
| 247 | |
| 248 | devType := "" |
| 249 | if len(parts) == 2 { |
| 250 | devType = strings.ToLower(strings.TrimSpace(parts[1])) |
| 251 | } |
| 252 | |
| 253 | devices = append(devices, &DeviceInfo{ |
| 254 | Name: name, |
| 255 | Type: devType, |
| 256 | }) |
| 257 | } |
| 258 | |
| 259 | if len(devices) == 0 { |
| 260 | return nil, errNoValidSmartData |
| 261 | } |
| 262 | |
| 263 | return devices, nil |
| 264 | } |
| 265 | |
| 266 | func (sm *SmartManager) refreshExcludedDevices() { |
| 267 | rawValue, _ := utils.GetEnv("EXCLUDE_SMART") |