Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Characteristic ¶ added in v1.3.0
type Characteristic struct {
// contains filtered or unexported fields
}
Characteristic is a songle sensor value.
type IndoorClimateMeasurement ¶ added in v1.3.0
type IndoorClimateMeasurement struct {
DeviceId string
Timestamp time.Time
Type MeasurementType
Value string
}
IndoorClimateMeasurement is a metric read from a sensor device.
type IndoorClimateSensor ¶ added in v1.3.0
type IndoorClimateSensor struct {
// contains filtered or unexported fields
}
IndoorClimateSensor is used to fetch tem eprature, humidiy and bettery status from a Xiaomi Mijia (LYWSD03MMC) indoor climate sensor.
func (*IndoorClimateSensor) Connect ¶ added in v1.3.0
func (sensor *IndoorClimateSensor) Connect() error
Connect will try to connect to a device and will return with an error if failing.
func (*IndoorClimateSensor) Disconnect ¶ added in v1.3.0
func (sensor *IndoorClimateSensor) Disconnect() error
Disconnect will try to disconnect from current device and returns with an error if it fails.
func (*IndoorClimateSensor) Id ¶ added in v1.3.0
func (sensor *IndoorClimateSensor) Id() string
ID returns sensor device id.
type LogPublisher ¶ added in v1.3.0
type LogPublisher struct {
// contains filtered or unexported fields
}
LogPublisher will log indoor climate measuremnts.
type MeasurementType ¶ added in v1.6.0
type MeasurementType string
MeasurementType is a indoor climate date type, e.g. temperature.
const ( MEASUREMENTTYPE_TEMPERATURE MeasurementType = "temperature" MEASUREMENTTYPE_HUMIDITY MeasurementType = "humidity" MEASUREMENTTYPE_BATTERY MeasurementType = "battery" )
type Publisher ¶ added in v1.3.0
type Publisher interface {
// SendMeasurement will start to transfer passed measurement to a target.
SendMeasurement(IndoorClimateMeasurement) error
}
Publisher sends given measuremnts to different targets.
type SensorDataCollector ¶ added in v1.3.0
type SensorDataCollector struct {
// contains filtered or unexported fields
}
SensorDataCollector will try to fetch temperature, humidity and bettery status from a given list of sensors.
func (*SensorDataCollector) AppendTarget ¶ added in v1.6.0
func (collector *SensorDataCollector) AppendTarget(newTarget Publisher)
AooendTarget will append passed target to internal publisher list.
func (*SensorDataCollector) Run ¶ added in v1.3.0
func (collector *SensorDataCollector) Run(ctx context.Context) error
Run will start collecting sensor data from all defined devices.
func (*SensorDataCollector) RunContinouous ¶ added in v1.4.3
func (collector *SensorDataCollector) RunContinouous(ctx context.Context)
RunContinouous will run in an endless loop and fetches device data in a defines schedule.
func (*SensorDataCollector) RunSingle ¶ added in v1.4.3
func (collector *SensorDataCollector) RunSingle(ctx context.Context)
RunSingle run indoor climate data fetch once for all devices.
type SensorDevice ¶ added in v1.3.0
type SensorDevice interface {
// Returns the id of current sensor device.
Id() string
// Connect will try to connect to a device and will return with an error if failing.
Connect() error
// Disconnect will try to disconnect from current device and returns with an error if it fails.
Disconnect() error
// ReadValue will try to read measurment value for given characteristics.
ReadValue(string) ([]byte, error)
}
SensorDevice represents a device to fetch indoor cliamte data.
func NewIndoorClimateSensor ¶ added in v1.3.0
func NewIndoorClimateSensor(adapterId, deviceId string) SensorDevice
NewIndoorClimateSensor returns a new indoor climate device.