Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Battery ¶
type Battery struct {
ID uint `gorm:"primaryKey"`
Timestamp time.Time `gorm:"index;not null"`
DeviceID uint `gorm:"index;not null"` // Foreign key to devices table
Device Device `gorm:"foreignKey:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
BatteryPercentage *int // Battery percentage (0-100)
}
Battery represents battery status for a device at a specific time
type Device ¶
type Device struct {
ID uint `gorm:"primaryKey"`
DeviceID string `gorm:"uniqueIndex;size:255;not null"` // Device CR name
DeviceName string `gorm:"size:255"` // Friendly name from Tasmota
SensorType string `gorm:"size:50"` // Sensor type (moisture, valve, water_level, room)
ShortAddr string `gorm:"index;size:50"` // Zigbee short address (e.g., "0xBF16")
IEEEAddr string `gorm:"index;size:100"` // IEEE address if available
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
}
Device represents a sensor device in the database
type LinkQuality ¶
type LinkQuality struct {
ID uint `gorm:"primaryKey"`
Timestamp time.Time `gorm:"index;not null"`
DeviceID uint `gorm:"index;not null"` // Foreign key to devices table
Device Device `gorm:"foreignKey:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
LinkQuality *int // Link quality (0-255)
}
LinkQuality represents link quality for a device at a specific time
func (LinkQuality) TableName ¶
func (LinkQuality) TableName() string
TableName overrides the default table name
type MoistureMeasurement ¶
type MoistureMeasurement struct {
ID uint `gorm:"primaryKey"`
Timestamp time.Time `gorm:"index;not null"`
DeviceID uint `gorm:"index;not null"` // Foreign key to devices table
Device Device `gorm:"foreignKey:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Temperature *float64 `gorm:"type:decimal(5,2)"` // Temperature in Celsius
Humidity *float64 `gorm:"type:decimal(5,2)"` // Soil humidity/moisture percentage
Endpoint *int // Zigbee endpoint
}
MoistureMeasurement represents a moisture sensor measurement in the database This model is used by GORM to auto-create/manage the moisture_measurements table
func (MoistureMeasurement) TableName ¶
func (MoistureMeasurement) TableName() string
TableName overrides the default table name
type RoomMeasurement ¶
type RoomMeasurement struct {
ID uint `gorm:"primaryKey"`
Timestamp time.Time `gorm:"index;not null"`
DeviceID uint `gorm:"index;not null"` // Foreign key to devices table
Device Device `gorm:"foreignKey:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Temperature *float64 `gorm:"type:decimal(5,2)"` // Temperature in Celsius
Humidity *float64 `gorm:"type:decimal(5,2)"` // Humidity percentage
Endpoint *int // Zigbee endpoint
}
RoomMeasurement represents a room sensor measurement in the database This model is used by GORM to auto-create/manage the room_measurements table
func (RoomMeasurement) TableName ¶
func (RoomMeasurement) TableName() string
TableName overrides the default table name
type ValveMeasurement ¶
type ValveMeasurement struct {
ID uint `gorm:"primaryKey"`
Timestamp time.Time `gorm:"index;not null"`
DeviceID uint `gorm:"index;not null"` // Foreign key to devices table
Device Device `gorm:"foreignKey:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Power *int // Power state (0=off, 1=on)
LastValveOpenDuration *int // Duration valve was open (seconds)
IrrigationStartTime *int64 // Unix timestamp when irrigation started
IrrigationEndTime *int64 // Unix timestamp when irrigation ended
DailyIrrigationVolume *int // Daily irrigation volume
Endpoint *int // Zigbee endpoint
}
ValveMeasurement represents a valve sensor measurement in the database This model is used by GORM to auto-create/manage the valve_measurements table
func (ValveMeasurement) TableName ¶
func (ValveMeasurement) TableName() string
TableName overrides the default table name
type WaterLevelMeasurement ¶
type WaterLevelMeasurement struct {
ID uint `gorm:"primaryKey"`
Timestamp time.Time `gorm:"index;not null"`
DeviceID uint `gorm:"index;not null"` // Foreign key to devices table
Device Device `gorm:"foreignKey:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Level *int // Water level value (e.g., 285)
Endpoint *int // Zigbee endpoint
}
WaterLevelMeasurement represents a water level sensor measurement in the database This model is used by GORM to auto-create/manage the water_level_measurements table
func (WaterLevelMeasurement) TableName ¶
func (WaterLevelMeasurement) TableName() string
TableName overrides the default table name