refactor: temperature

This commit is contained in:
2019-02-24 22:46:36 +01:00
parent d6f41b8105
commit 1a3a31c5f2
24 changed files with 605 additions and 292 deletions

29
pkg/types/sensor.go Normal file
View File

@ -0,0 +1,29 @@
package types
import (
"time"
)
// Sensor ...
type Sensor struct {
SensorID string `json:"sensor_id"`
SensorName string `json:"sensor_name"`
SensorLocation string `json:"sensor_location"`
WireID *string `json:"wire_id"`
GPIONumber *string `json:"gpio_number"`
SensorType string `json:"sensor_type"`
SensorEnabled bool `json:"sensor_enabled"`
SensorLastContact time.Time `json:"sensor_last_contact"`
DeviceID string `json:"device_id"`
CreationDate time.Time `json:"creation_date"`
}
func (s *Sensor) Name() string {
if s.SensorName != "" {
return s.SensorName
} else if *s.WireID != "" {
return *s.WireID
}
return s.SensorID
}

32
pkg/types/types.go Normal file
View File

@ -0,0 +1,32 @@
package types
import (
"time"
)
// Device ...
type Device struct {
DeviceID string `json:"device_id"`
DeviceName *string `json:"device_name"`
DeviceLocation *string `json:"device_location"`
DeviceLastContact time.Time `json:"device_last_contact"`
CreationDate time.Time `json:"creation_date"`
}
// Humidity ...
type Humidity struct {
HumidityID string `json:"humidity_id"`
HumidityValue float64 `json:"humidity_value,string"`
HumidityDate time.Time `json:"humidity_date"`
SensorID string `json:"sensor_id"`
CreationDate time.Time `json:"creation_date"`
}
// Temperature ...
type Temperature struct {
TemperatureID string `json:"temperature_id"`
TemperatureValue float64 `json:"temperature_value,string"`
TemperatureDate time.Time `json:"temperature_date"`
SensorID string `json:"sensor_id"`
CreationDate time.Time `json:"creation_date"`
}