refactor: temperature
This commit is contained in:
29
pkg/types/sensor.go
Normal file
29
pkg/types/sensor.go
Normal 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
32
pkg/types/types.go
Normal 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"`
|
||||
}
|
Reference in New Issue
Block a user