miio

package
v0.0.0-...-bb88ee3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2020 License: LGPL-3.0 Imports: 11 Imported by: 0

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

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 VacError

type VacError int

VacError defines possible vacuum error.

const (
	// VacErrorNo describes no errors.
	VacErrorNo VacError = iota
	// VacErrorCharge describes error with charger.
	VacErrorCharge
	// VacErrorFull describes full dust container.
	VacErrorFull
	// VacErrorUnknown describes unknown error
	VacErrorUnknown
)

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 NewVacuum

func NewVacuum(deviceIP, token string) (*Vacuum, error)

NewVacuum creates a new vacuum.

func (*Vacuum) Dock

func (v *Vacuum) Dock() bool

Dock returns to dock.

func (*Vacuum) FindMe

func (v *Vacuum) FindMe() bool

FindMe sends the find me command.

func (*Vacuum) GetUpdateMessage

func (v *Vacuum) GetUpdateMessage() *DeviceUpdateMessage

GetUpdateMessage returns an update message.

func (*Vacuum) GotoTarget

func (v *Vacuum) GotoTarget(x int, y int) bool

GotoTarget goes to the given target coordinates.

func (*Vacuum) PauseCleaning

func (v *Vacuum) PauseCleaning() bool

PauseCleaning pauses the cleaning cycle.

func (*Vacuum) SetFanPower

func (v *Vacuum) SetFanPower(val uint8) bool

SetFanSpeed sets fan speed

func (*Vacuum) SetVolume

func (v *Vacuum) SetVolume(val uint8) bool

SetVolume sets the sound volume

func (*Vacuum) StartCleaning

func (v *Vacuum) StartCleaning() bool

StartCleaning starts the cleaning cycle.

func (*Vacuum) Stop

func (v *Vacuum) Stop()

Stop stops the device.

func (*Vacuum) StopCleaning

func (v *Vacuum) StopCleaning() bool

StopCleaning stops the cleaning cycle.

func (*Vacuum) StopCleaningAndDock

func (v *Vacuum) StopCleaningAndDock() bool

StopCleaningAndDock stops the cleaning cycle and returns to dock.

func (*Vacuum) UpdateState

func (v *Vacuum) UpdateState()

UpdateState performs a state update.

func (*Vacuum) UpdateStatus

func (v *Vacuum) UpdateStatus() bool

UpdateStatus requests for a state update.

func (*Vacuum) ZonedClean

func (v *Vacuum) ZonedClean(zones [][]int) bool

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

type XiaomiDevice struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL