Documentation
¶
Index ¶
- func DumpDb(db *Db, out io.Writer) error
- type Db
- func (db *Db) Device(id string) (ret data.Device, err error)
- func (db *Db) DeviceActivity(id string) error
- func (db *Db) DeviceByID(id string) (data.Device, error)
- func (db *Db) DeviceCmds() (ret []data.DeviceCmd, err error)
- func (db *Db) DeviceDelete(id string) error
- func (db *Db) DeviceEach(callback func(device *data.Device) error) error
- func (db *Db) DeviceGetCmd(id string) (data.DeviceCmd, error)
- func (db *Db) DeviceSample(id string, sample data.Sample) error
- func (db *Db) DeviceSetCmd(cmd data.DeviceCmd) error
- func (db *Db) DeviceSetState(id string, state data.SysState) error
- func (db *Db) DeviceSetVersion(id string, ver data.DeviceVersion) error
- func (db *Db) DeviceUpdateConfig(id string, config data.DeviceConfig) error
- func (db *Db) DeviceUpdateGroups(id string, groups []uuid.UUID) error
- func (db *Db) Devices() (ret []data.Device, err error)
- func (db *Db) DevicesForGroup(tx *bolt.Tx, groupID uuid.UUID) ([]data.Device, error)
- func (db *Db) DevicesForUser(userID uuid.UUID) ([]data.Device, error)
- func (db *Db) Group(id uuid.UUID) (data.Group, error)
- func (db *Db) GroupDelete(id uuid.UUID) error
- func (db *Db) GroupInsert(group data.Group) (string, error)
- func (db *Db) GroupUpdate(gUpdate data.Group) error
- func (db *Db) Groups() ([]data.Group, error)
- func (db *Db) RuleByID(id uuid.UUID) (data.Rule, error)
- func (db *Db) RuleDelete(id uuid.UUID) error
- func (db *Db) RuleEach(callback func(rule *data.Rule) error) error
- func (db *Db) RuleInsert(rule data.Rule) (uuid.UUID, error)
- func (db *Db) RuleUpdateConfig(id uuid.UUID, config data.RuleConfig) error
- func (db *Db) RuleUpdateState(id uuid.UUID, state data.RuleState) error
- func (db *Db) Rules() ([]data.Rule, error)
- func (db *Db) UserByEmail(email string) (data.User, error)
- func (db *Db) UserByID(id string) (data.User, error)
- func (db *Db) UserCheck(email, password string) (*data.User, error)
- func (db *Db) UserDelete(id uuid.UUID) error
- func (db *Db) UserInsert(user data.User) (string, error)
- func (db *Db) UserIsRoot(id uuid.UUID) (bool, error)
- func (db *Db) UserUpdate(user data.User) error
- func (db *Db) Users() ([]data.User, error)
- func (db *Db) UsersForGroup(id uuid.UUID) ([]data.User, error)
- type Influx
- type InfluxSample
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
Db is used for all db access in the application. We will eventually turn this into an interface to handle multiple Db backends.
func (*Db) DeviceActivity ¶ added in v0.0.6
DeviceActivity is used to tell the system there has been activity from this device
func (*Db) DeviceByID ¶ added in v0.0.8
DeviceByID returns a device for a given ID
func (*Db) DeviceCmds ¶ added in v0.0.6
DeviceCmds returns all commands for device
func (*Db) DeviceDelete ¶
DeviceDelete deletes a device from the database
func (*Db) DeviceEach ¶ added in v0.0.6
DeviceEach iterates through each device calling provided function
func (*Db) DeviceGetCmd ¶
DeviceGetCmd gets a cmd for a device. If the cmd is no null, the command is deleted, and the cmdPending flag cleared in the Device data structure.
func (*Db) DeviceSample ¶
DeviceSample processes a sample for a particular device
func (*Db) DeviceSetCmd ¶
DeviceSetCmd sets a cmd for a device, and sets the CmdPending flag in the device structure.
func (*Db) DeviceSetState ¶ added in v0.0.6
DeviceSetState is used to set the current system state
func (*Db) DeviceSetVersion ¶
func (db *Db) DeviceSetVersion(id string, ver data.DeviceVersion) error
DeviceSetVersion sets a cmd for a device, and sets the
func (*Db) DeviceUpdateConfig ¶
func (db *Db) DeviceUpdateConfig(id string, config data.DeviceConfig) error
DeviceUpdateConfig updates the config for a device.
func (*Db) DeviceUpdateGroups ¶ added in v0.0.6
DeviceUpdateGroups updates the groups for a device.
func (*Db) DevicesForGroup ¶ added in v0.0.6
DevicesForGroup returns the devices which are property of the given Group.
func (*Db) DevicesForUser ¶ added in v0.0.6
DevicesForUser returns all devices for a particular user
func (*Db) GroupDelete ¶ added in v0.0.6
GroupDelete deletes a device from the database
func (*Db) GroupInsert ¶ added in v0.0.6
GroupInsert inserts a new group
func (*Db) GroupUpdate ¶ added in v0.0.6
GroupUpdate updates a group
func (*Db) RuleDelete ¶ added in v0.0.8
RuleDelete deletes a rule from the database
func (*Db) RuleInsert ¶ added in v0.0.8
RuleInsert inserts a new rule
func (*Db) RuleUpdateConfig ¶ added in v0.0.8
RuleUpdateConfig updates a rule config
func (*Db) RuleUpdateState ¶ added in v0.0.8
RuleUpdateState updates a rule state
func (*Db) UserByEmail ¶ added in v0.0.6
UserByEmail returns the user with the given email, if it exists.
func (*Db) UserDelete ¶ added in v0.0.6
UserDelete deletes a user from the database
func (*Db) UserInsert ¶ added in v0.0.6
UserInsert inserts a new user
func (*Db) UserIsRoot ¶ added in v0.0.6
UserIsRoot checks if root user
func (*Db) UserUpdate ¶ added in v0.0.6
UserUpdate updates a new user
type Influx ¶
type Influx struct {
// contains filtered or unexported fields
}
Influx represents and influxdb that we can write samples to
func (*Influx) WriteSamples ¶
func (i *Influx) WriteSamples(samples []InfluxSample) error
WriteSamples to influxdb
type InfluxSample ¶ added in v0.0.8
type InfluxSample struct {
// Type of sample (voltage, current, key, etc)
Type string `influx:"type,tag"`
// ID of the sensor that provided the sample
ID string `influx:"id,tag"`
// DeviceID of the ID of the device that provided the sample
DeviceID string `influx:"deviceId,tag"`
// Average OR
// Instantaneous analog or digital value of the sample.
// 0 and 1 are used to represent digital values
Value float64 `influx:"value"`
// statistical values that may be calculated
Min float64 `influx:"min"`
Max float64 `influx:"max"`
// Time the sample was taken
Time time.Time `influx:"time"`
// Duration over which the sample was taken
Duration time.Duration `influx:"duration"`
}
InfluxSample represents a sample that is written into influxdb
func SampleToInfluxSample ¶ added in v0.0.8
func SampleToInfluxSample(deviceID string, s data.Sample) InfluxSample
SampleToInfluxSample converts a sample to influx sample