Documentation ¶
Index ¶
- Variables
- type ClickType
- type DeviceUpdateMessage
- type Gateway
- type GatewayState
- type IDevice
- type ILogger
- type Magnet
- type MagnetState
- type Motion
- type MotionState
- type SensorHT
- type SensorHTState
- type Switch
- type SwitchState
- type VacError
- type VacState
- type Vacuum
- func (v *Vacuum) FindMe() bool
- func (v *Vacuum) GetUpdateMessage() *DeviceUpdateMessage
- func (v *Vacuum) PauseCleaning() bool
- func (v *Vacuum) SetFanPower(val uint8) bool
- func (v *Vacuum) StartCleaning() bool
- func (v *Vacuum) Stop()
- func (v *Vacuum) StopCleaning() bool
- func (v *Vacuum) StopCleaningAndDock() bool
- func (v *Vacuum) UpdateState()
- func (v *Vacuum) UpdateStatus() bool
- type VacuumState
- type XiaomiDevice
- func (d *XiaomiDevice) GetBatteryLevel(curVal float32) float32
- func (d *XiaomiDevice) GetFieldPercentage(field fldName, curVal float64) float64
- func (d *XiaomiDevice) GetFieldValueBool(field fldName, curVal bool) bool
- func (d *XiaomiDevice) GetFieldValueFloat64(field fldName, curVal float64) float64
- func (d *XiaomiDevice) GetFieldValueInt32(field fldName, curVal int32) int32
- func (d *XiaomiDevice) GetFieldValueUint32(field fldName, curVal uint32) uint32
- func (d *XiaomiDevice) SetRawState(state map[string]interface{})
Constants ¶
This section is empty.
Variables ¶
var (
// LOGGER implementation.
LOGGER = newLogger()
)
Functions ¶
This section is empty.
Types ¶
type ClickType ¶
type ClickType int
ClickType represents Xiaomi switch state.
const ( // ClickNo describes no click. ClickNo ClickType = iota // ClickSingle describes single click. ClickSingle // ClickDouble describes double click. ClickDouble // ClickLongPress describes the beginning of a long click. ClickLongPress // ClickLongRelease describes the end of a long click. ClickLongRelease )
type DeviceUpdateMessage ¶
type DeviceUpdateMessage struct { ID string State interface{} }
DeviceUpdateMessage contains data about an update.
type Gateway ¶
type Gateway struct { XiaomiDevice State *GatewayState UpdateChan chan *DeviceUpdateMessage Sensors map[string]*SensorHT Magnets map[string]*Magnet Motions map[string]*Motion Switches map[string]*Switch // contains filtered or unexported fields }
Gateway represents a Xiaomi gateway.
func NewGateway ¶
NewGateway creates a new gateway.
func (*Gateway) GetUpdateMessage ¶
func (g *Gateway) GetUpdateMessage() *DeviceUpdateMessage
GetUpdateMessage returns a state update message.
func (*Gateway) SetBrightness ¶
SetBrightness sets the LED light brightness.
func (*Gateway) UpdateState ¶
func (g *Gateway) UpdateState()
UpdateState updates the gateway state.
type GatewayState ¶
type GatewayState struct { On bool RGB color.Color Brightness uint8 // contains filtered or unexported fields }
GatewayState defines the gateway state.
type IDevice ¶
type IDevice interface { Stop() GetUpdateMessage() *DeviceUpdateMessage SetRawState(map[string]interface{}) UpdateState() }
IDevice defines Xiaomi device.
type ILogger ¶
type ILogger interface { Debug(format string, v ...interface{}) Info(format string, v ...interface{}) Warn(format string, v ...interface{}) Error(format string, v ...interface{}) Fatal(format string, v ...interface{}) }
ILogger defines a logger interface.
type Magnet ¶
type Magnet struct { XiaomiDevice ID string Gateway *Gateway State *MagnetState }
Magnet defines a Xiaomi magnet.
func (*Magnet) GetUpdateMessage ¶
func (m *Magnet) GetUpdateMessage() *DeviceUpdateMessage
GetUpdateMessage returns device's state update message.
type MagnetState ¶
MagnetState describes a state of the magnet.
type Motion ¶
type Motion struct { XiaomiDevice ID string Gateway *Gateway State *MotionState }
Motion defines a Xiaomi motion sensor.
func (*Motion) GetUpdateMessage ¶
func (m *Motion) GetUpdateMessage() *DeviceUpdateMessage
GetUpdateMessage returns device's state update message.
type MotionState ¶
MotionState describes a state of the motion sensor.
type SensorHT ¶
type SensorHT struct { XiaomiDevice ID string Gateway *Gateway State *SensorHTState }
SensorHT defines a Xiaomi humidity-temperature sensor.
func (*SensorHT) GetUpdateMessage ¶
func (s *SensorHT) GetUpdateMessage() *DeviceUpdateMessage
GetUpdateMessage returns device's state update message.
func (*SensorHT) UpdateState ¶
func (s *SensorHT) UpdateState()
UpdateState performs a device update.
type SensorHTState ¶
SensorHTState describes a state of the humidity-temperature sensor.
type Switch ¶
type Switch struct { XiaomiDevice ID string Gateway *Gateway State *SwitchState }
Switch defines a Xiaomi switch.
func (*Switch) GetUpdateMessage ¶
func (s *Switch) GetUpdateMessage() *DeviceUpdateMessage
GetUpdateMessage returns device's state update message.
type SwitchState ¶
SwitchState describes a state of the switch.
type VacState ¶
type VacState int
VacState defines possible vacuum state.
const ( // VacStateUnknown describes unknown state. VacStateUnknown VacState = iota // VacStateInitiating indicates that vacuum is in initializing mode. VacStateInitiating // VacStateSleeping indicates that vacuum is in a sleep mode. VacStateSleeping // VacStateWaiting indicates that vacuum is in waiting mode. VacStateWaiting // VacStateCleaning indicates that vacuums is cleaning. VacStateCleaning // VacStateReturning indicates that vacuum is returning to the dock. VacStateReturning // VacStateCharging indicates that vacuum is charging. VacStateCharging // VacStatePaused indicates that cleaning is paused. VacStatePaused // VacStateSpot indicates that vacuum is cleaning a spot. VacStateSpot //VacStateShuttingDown indicates that vacuum is shutting down. VacStateShuttingDown // VacStateUpdating indicates that vacuum is in an update mode. VacStateUpdating // VacStateDocking indicates that vacuum is in a process of docking. VacStateDocking // VacStateZone indicates that vacuum is cleaning az one. VacStateZone // VacStateFull indicates that dust bag is full. VacStateFull )
type Vacuum ¶
type Vacuum struct { XiaomiDevice State *VacuumState UpdateChan chan *DeviceUpdateMessage }
Vacuum defines a Xiaomi vacuum cleaner.
func (*Vacuum) GetUpdateMessage ¶
func (v *Vacuum) GetUpdateMessage() *DeviceUpdateMessage
GetUpdateMessage returns an update message.
func (*Vacuum) PauseCleaning ¶
PauseCleaning pauses the cleaning cycle.
func (*Vacuum) SetFanPower ¶
SetFanSpeed sets fan speed
func (*Vacuum) StartCleaning ¶
StartCleaning starts the cleaning cycle.
func (*Vacuum) StopCleaning ¶
StopCleaning stops the cleaning cycle.
func (*Vacuum) StopCleaningAndDock ¶
StopCleaningAndDock stops the cleaning cycle and returns to dock.
func (*Vacuum) UpdateStatus ¶
UpdateStatus requests for a state update.
type VacuumState ¶
type VacuumState struct { Battery int CleanArea int CleanTime int IsDND bool IsCleaning bool FanPower int Error VacError State VacState }
VacuumState describes a vacuum state.
type XiaomiDevice ¶
XiaomiDevice represents Xiaomi device.
func (*XiaomiDevice) GetBatteryLevel ¶
func (d *XiaomiDevice) GetBatteryLevel(curVal float32) float32
GetBatteryLevel returns current battery level percent.
func (*XiaomiDevice) GetFieldPercentage ¶
func (d *XiaomiDevice) GetFieldPercentage(field fldName, curVal float64) float64
GetFieldPercentage returns percent field.
func (*XiaomiDevice) GetFieldValueBool ¶
func (d *XiaomiDevice) GetFieldValueBool(field fldName, curVal bool) bool
GetFieldValueBool returns bool value.
func (*XiaomiDevice) GetFieldValueFloat64 ¶
func (d *XiaomiDevice) GetFieldValueFloat64(field fldName, curVal float64) float64
GetFieldValueFloat64 returns float64 value.
func (*XiaomiDevice) GetFieldValueInt32 ¶
func (d *XiaomiDevice) GetFieldValueInt32(field fldName, curVal int32) int32
GetFieldValueInt32 returns int32 value.
func (*XiaomiDevice) GetFieldValueUint32 ¶
func (d *XiaomiDevice) GetFieldValueUint32(field fldName, curVal uint32) uint32
GetFieldValueUint32 returns uint32 value.
func (*XiaomiDevice) SetRawState ¶
func (d *XiaomiDevice) SetRawState(state map[string]interface{})
Sets raw state of the device. Used for Gateway devices.