package sensor import ( "fmt" "time" uuid "github.com/satori/go.uuid" "github.com/volker-raschek/flucky/pkg/types" "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 }