Documentation
¶
Overview ¶
* Copyright (c) 2018 Vlad Korniev - Original work * Copyright (c) 2020 Hendrik Hagendorn - Modified work * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
* Copyright (c) 2018 Vlad Korniev - Original work * Copyright (c) 2020 Hendrik Hagendorn - Modified work * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
* Copyright (c) 2018 Vlad Korniev - Original work * Copyright (c) 2020 Hendrik Hagendorn - Modified work * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
* Copyright (c) 2018 Vlad Korniev - Original work * Copyright (c) 2020 Hendrik Hagendorn - Modified work * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
Index ¶
- type DeviceUpdateMessage
- type IDevice
- type VacError
- type VacState
- type Vacuum
- func (v *Vacuum) Dock() bool
- func (v *Vacuum) FindMe() bool
- func (v *Vacuum) GetUpdateMessage() *DeviceUpdateMessage
- func (v *Vacuum) GotoTarget(x int, y int) bool
- func (v *Vacuum) PauseCleaning() bool
- func (v *Vacuum) SetFanPower(val uint8) bool
- func (v *Vacuum) SetVolume(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
- func (v *Vacuum) ZonedClean(zones [][]int) 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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeviceUpdateMessage ¶
type DeviceUpdateMessage struct { ID string State *VacuumState }
DeviceUpdateMessage contains data about an update.
type IDevice ¶
type IDevice interface { Stop() GetUpdateMessage() *DeviceUpdateMessage SetRawState(map[string]interface{}) UpdateState() }
IDevice defines Xiaomi device.
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 // VacStateIdle indicates that vacuum is idle. VacStateIdle // VacStateRemoteControl indicates that vacuum is remotely controlled. VacStateRemoteControl // VacStateCleaning indicates that vacuums is cleaning. VacStateCleaning // VacStateReturning indicates that vacuum is returning to the dock. VacStateReturning // VacStateManualMode VacStateManualMode // VacStateCharging indicates that vacuum is charging. VacStateCharging // VacStateChargingError indicates that vacuum has charging issues. VacStateChargingError // VacStatePaused indicates that cleaning is paused. VacStatePaused // VacStateSpot indicates that vacuum is cleaning a spot. VacStateSpot // VacStateInError indicates that vacuum is in error state. VacStateInError //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 // VacStateGoTo indicates that vacuum is going to a target point. VacStateGoTo // VacStateZoneClean indicates that vacuum is cleaning a zone. VacStateZoneClean // VacStateRoomClean indicates that vacuum is cleaning a room. VacStateRoomClean // VacStateFullyCharged indicates that vacuum is fully charged. VacStateFullyCharged )
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) GotoTarget ¶
GotoTarget goes to the given target coordinates.
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.
func (*Vacuum) ZonedClean ¶
ZonedClean cleans the given zones n times.
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.