Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFanStatus = fmt.Errorf("Invalid status")
ErrInvalidFanStatus represent invalid fan status.
Functions ¶
This section is empty.
Types ¶
type BedroomService ¶
type BedroomService struct {
// contains filtered or unexported fields
}
BedroomService allows the user to update and get information about the bedroom state.
func NewBedroomService ¶
func NewBedroomService(s *Session) *BedroomService
NewBedroomService creates a new BedroomService, which allows to interact with the bedroom field of the timeseries.
func (*BedroomService) FetchState ¶
func (b *BedroomService) FetchState(start time.Time, finish time.Time) ([]BedroomState, error)
FetchState returns the bedroom state updates in the considered period.
func (*BedroomService) UpdateTemperature ¶
func (b *BedroomService) UpdateTemperature(t time.Time, temp float64) error
UpdateTemperature changes bedroom temperature at the specified time, updating the database.
type BedroomState ¶
type BedroomState struct { Timestamp time.Time `json:"timestamp,omitempty"` Temperature float64 `json:"temp,omitempty"` }
BedroomState state stores the bedroom state (e.g. temperature, humidity) at a certain moment.
type FanService ¶
type FanService struct {
// contains filtered or unexported fields
}
FanService allows the user to update and get information about the bedroom fan.
func NewFanService ¶
func NewFanService(s *Session) *FanService
NewFanService creates a new BedroomService, which allows to interact with the fan field of the timeseries.
func (FanService) FetchState ¶
FetchState returns the fan status updates in the considered period. Important to n
func (FanService) LastState ¶
func (f FanService) LastState() (FanState, error)
LastState returns the last fan status.
func (FanService) UpdateStatus ¶
func (f FanService) UpdateStatus(t time.Time, s FanStatus) error
UpdateStatus changes the fan status at specified time, updating the database.
type FanState ¶
type FanState struct { Timestamp time.Time `json:"timestamp,omitempty"` Status FanStatus `json:"status,omitempty"` }
FanState stores the state of the fan at a certain moment.
type ForecastService ¶
type ForecastService struct {
// contains filtered or unexported fields
}
ForecastService allows the user to update and get information about the weather forecast.
func NewForecastService ¶
func NewForecastService(s *Session) *ForecastService
NewForecastService creates a new ForecastService, which allows to interact with the forecast field of the timeseries.
func (*ForecastService) Update ¶
func (wf *ForecastService) Update(states ...weather.State) error
Update updates the database with the new information about the weather forecast. This call assumes the weather.State.Timestamp is a future timestamp, so it overrides whichever information is associated to it (it should be none).
type Prediction ¶
type Prediction struct { Timestamp time.Time `bson:"-"` TempFanOff float64 `bson:"fan_off,omitempty"` TempFanLow float64 `bson:"fan_low,omitempty"` TempFanHigh float64 `bson:"fan_high,omitempty"` }
Prediction represents a prediction of a bedroom temperature at a certain time in any of the following states: fan off, low or high.
type PredictionService ¶
type PredictionService struct {
// contains filtered or unexported fields
}
PredictionService allows users to store or fetch predictions.
func NewPredictionService ¶
func NewPredictionService(s *Session) *PredictionService
NewPredictionService creates a new PredictionService, which allows to interact with the predictions field of the timeseries.
func (*PredictionService) Update ¶
func (p *PredictionService) Update(ps ...Prediction) error
Update stores the passed-in predictions. The call overrides any previously stored predictions.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a connection to a mongo timeseries collection.
func Dial ¶
Dial sets up a connection to the specified timeseries database specified by the passed-in URI.
func NewSession ¶
NewSession creates a new Session instance, which allows the communication to the underlying timeseries mongo database;
func (*Session) Close ¶
func (s *Session) Close()
Close release resources associated with this connection.
func (*Session) Copy ¶
Copy works just like New, but preserves the database and any authentication information from the original session.
type TSRecord ¶
type TSRecord struct { Timestamp time.Time `bson:"timestamp_hour,omitempty"` Value interface{} `bson:"value,omitempty"` }
TSRecord represents a value to be added to timeseries database.
type WeatherService ¶
type WeatherService struct {
// contains filtered or unexported fields
}
WeatherService allows the user to update and get information about the weather.
func NewWeatherService ¶
func NewWeatherService(s *Session) *WeatherService
NewWeatherService creates a new WeatherService, which allows to interact with the weather field of the timeseries.