package sensor import ( "errors" "sync" "git.cryptic.systems/volker.raschek/flucky/pkg/types" ) var ( ErrSensorModelNotMatched = errors.New("Sensor model not matched") ) // New returns a new sensor func New(sensor *types.Sensor) (Sensor, error) { switch sensor.Model { case "BME280": return &BME280{ Sensor: sensor, mutex: new(sync.Mutex), }, nil case "DHT11": return &DHT11{ Sensor: sensor, mutex: new(sync.Mutex), }, nil case "DHT22": return &DHT22{ Sensor: sensor, mutex: new(sync.Mutex), }, nil case "DS18B20": return &DS18B20{ Sensor: sensor, mutex: new(sync.Mutex), }, nil default: return nil, ErrSensorModelNotMatched } }