package sensor import ( "fmt" "time" "git.cryptic.systems/fh-trier/go-flucky/pkg/types" uuid "github.com/satori/go.uuid" "github.com/yryz/ds18b20" ) type DS18B20 struct { *types.Sensor } func (s *DS18B20) ReadTemperature() (*types.Temperature, error) { t, err := ds18b20.Temperature(*s.WireID) if err != nil { return nil, fmt.Errorf("Can not read from Sensor %v (UUID: %v, Wire-ID: %v): %v", s.SensorName, s.SensorID, s.WireID, err) } temperature := &types.Temperature{ TemperatureID: uuid.NewV4().String(), TemperatureValue: t, TemperatureDate: time.Now(), SensorID: s.SensorID, } return temperature, nil }