ecovacs

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// https://github.com/wpietri/sucks/blob/master/sucks/__init__.py
	CLIENT_KEY = "eJUWrzRv34qFSaYk"
	SECRET     = "Cyu5jcR4zyK6QEPn1hdIGXB5QIDAQABMA0GC"
	PUBLIC_KEY = `` /* 271-byte string literal not displayed */

)
View Source
const (
	// Time-to-live for any state
	DELTA_OTHER_TTL    = 4 * time.Minute
	DELTA_VERSION_TTL  = 6 * time.Hour
	DELTA_LIFESPAN_TTL = 2 * time.Hour
)
View Source
const (
	MAIN_URL_FORMAT   = "" /* 155-byte string literal not displayed */
	USER_URL_FORMAT   = "https://users-{{.continent}}.ecouser.net:8000/user.do"
	ECOVACS_REALM     = "ecouser.net"
	ECOVACS_XMPP_PORT = 5223
)

Variables

View Source
var (
	COUNTRY_ALPHA2_TO_CONTINENT_CODE = map[string]string{}/* 245 elements not displayed */

)
View Source
var (
	ServerMap = map[string]string{
		"msg.ecouser.net":    "CH",
		"msg-as.ecouser.net": "TW,MY,JP,SG,TH,HK,IN,KR",
		"msg-na.ecouser.net": "US",
		"msg-eu.ecouser.net": "FR,ES,UK,NO,MX,DE,PT,CH,AU,IT,NL,SE,BE,DK",
		"msg-ww.ecouser.net": "",
	}
)

Functions

func CountryToXMPPServer

func CountryToXMPPServer(country string) string

CountryToXMPPServer returns hostname for countrycode

func DecodePublicKey

func DecodePublicKey() (*rsa.PublicKey, error)

func Encrypt

func Encrypt(key *rsa.PublicKey, data string) (string, error)

func MD5String

func MD5String(data string) string

func SortedKeys

func SortedKeys(params url.Values) []string

func SortedQuery

func SortedQuery(params url.Values) string

Types

type AccessToken

type AccessToken struct {
	Response
	Data struct {
		UserId      string `json:"uid"`
		Username    string `json:"username"`
		Email       string `json:"email"`
		Country     string `json:"country"`
		AccessToken string `json:"accessToken"`
	} `json:"data"`
}

type AuthCode

type AuthCode struct {
	Response
	Data struct {
		AuthCode   string `json:"authCode"`
		EcovacsUid string `json:"ecovacsUid"`
	} `json:"data"`
}

type DeviceState

type DeviceState struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*DeviceState) AddExpiredKey

func (this *DeviceState) AddExpiredKey(key home.EcovacsEventType)

func (*DeviceState) NextExpiredKey

func (this *DeviceState) NextExpiredKey() home.EcovacsEventType

func (*DeviceState) RemoveAll

func (this *DeviceState) RemoveAll()

Remove all elements from state

func (*DeviceState) Set

func (this *DeviceState) Set(value *XMPPMessage, ttl time.Duration) bool

Sets a value for key, and returns true if value was added or modified

func (*DeviceState) String

func (this *DeviceState) String() string

type DevicesResponse

type DevicesResponse struct {
	UserResponse
	Devices []*device `json:"devices"`
}

type Ecovacs

type Ecovacs struct {
	Country      string
	AccountId    string
	PasswordHash string
	Bus          gopi.Bus
}

func (Ecovacs) Name

func (Ecovacs) Name() string

func (Ecovacs) New

func (config Ecovacs) New(log gopi.Logger) (gopi.Unit, error)

type EcovacsEvent

type EcovacsEvent struct {
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent(source home.Ecovacs, device home.EvovacsDevice, message *XMPPMessage) *EcovacsEvent

func (*EcovacsEvent) Device

func (this *EcovacsEvent) Device() home.EvovacsDevice

func (*EcovacsEvent) Id

func (this *EcovacsEvent) Id() string

func (*EcovacsEvent) NS

func (*EcovacsEvent) NS() gopi.EventNS

func (*EcovacsEvent) Name

func (*EcovacsEvent) Name() string

func (*EcovacsEvent) Source

func (this *EcovacsEvent) Source() gopi.Unit

func (*EcovacsEvent) String

func (this *EcovacsEvent) String() string

func (*EcovacsEvent) Type

func (this *EcovacsEvent) Type() home.EcovacsEventType

func (*EcovacsEvent) Value

func (this *EcovacsEvent) Value() interface{}

type LoginResponse

type LoginResponse struct {
	UserResponse
	UserId   string `json:"userId"`
	Resource string `json:"resource"`
	Token    string `json:"token"`
	Last     uint   `json:"last"`
}

type RequestId

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

func (*RequestId) Next

func (this *RequestId) Next() string

Returns next requestId as a string

type Response

type Response struct {
	Code      string `json:"code"`
	Message   string `json:"msg"`
	Timestamp uint64 `json:"time"`
}

type UserResponse

type UserResponse struct {
	Result       string `json:"result"`
	ErrorCode    uint   `json:"errno"`
	ErrorMessage string `json:"error"`
}

type XMPPClient

type XMPPClient struct {
	Client   *xmpp.Client
	DeviceId string
	Class    string

	RequestId
	sync.Mutex
}

func (*XMPPClient) Address

func (this *XMPPClient) Address() string

func (*XMPPClient) Charge

func (this *XMPPClient) Charge() (string, error)

func (*XMPPClient) Clean

func (this *XMPPClient) Clean(mode home.EcovacsCleanMode, suction home.EcovacsCleanSuction) (string, error)

func (*XMPPClient) Close

func (this *XMPPClient) Close() error

func (*XMPPClient) GetBatteryInfo

func (this *XMPPClient) GetBatteryInfo() (string, error)

func (*XMPPClient) GetChargeState

func (this *XMPPClient) GetChargeState() (string, error)

func (*XMPPClient) GetCleanState

func (this *XMPPClient) GetCleanState() (string, error)

func (*XMPPClient) GetLifeSpan

func (this *XMPPClient) GetLifeSpan(part home.EcovacsPart) (string, error)

func (*XMPPClient) GetVersion

func (this *XMPPClient) GetVersion() (string, error)

func (*XMPPClient) IsConnected

func (this *XMPPClient) IsConnected() bool

func (*XMPPClient) NewClient

func (this *XMPPClient) NewClient(opts xmpp.Options, deviceId, class string) error

func (*XMPPClient) Ping

func (this *XMPPClient) Ping() error

func (*XMPPClient) Recv

func (this *XMPPClient) Recv() (*XMPPMessage, error)

type XMPPMessage

type XMPPMessage struct {
	XMLName xml.Name `xml:"query"`

	// Data structure
	Control struct {
		Id      string `xml:"id,attr"`
		Ret     string `xml:"ret,attr"`
		ErrorNo uint   `xml:"errno,attr"`
		Error   string `xml:"error,attr"`
		Type    string `xml:"type,attr"`
		Val     uint   `xml:"val,attr"`
		Total   uint   `xml:"total,attr"`
		Battery struct {
			Power uint `xml:"power,attr"`
		} `xml:"battery"`
		Charge struct {
			Type string `xml:"type,attr"`
		} `xml:"charge"`
		Clean struct {
			Type  string `xml:"type,attr"`
			Speed string `xml:"speed,attr"`
		} `xml:"clean"`
		Version struct {
			Name  string `xml:"name,attr"`
			Value string `xml:",chardata"`
		} `xml:"ver"`
	} `xml:"ctl"`
	// contains filtered or unexported fields
}

XMPPMessage encapsulates all the message information which can be returned from DeeBot

func NewXMPPMessage

func NewXMPPMessage(data []byte, id string) (*XMPPMessage, error)

NewXMPPMessage creates a new message

func Parse

func Parse(in xmpp.IQ) (*XMPPMessage, error)

func (*XMPPMessage) BatteryLevel

func (this *XMPPMessage) BatteryLevel() uint

func (*XMPPMessage) ChargeState

func (this *XMPPMessage) ChargeState() string

func (*XMPPMessage) CleanState

func (*XMPPMessage) Equals

func (this *XMPPMessage) Equals(other *XMPPMessage) bool

func (*XMPPMessage) Error

func (this *XMPPMessage) Error() (uint, string)

func (*XMPPMessage) ErrorMsg

func (this *XMPPMessage) ErrorMsg() string

func (*XMPPMessage) Id

func (this *XMPPMessage) Id() string

ReqId returns the ID for the message

func (*XMPPMessage) LifeSpan

func (this *XMPPMessage) LifeSpan() (home.EcovacsPart, uint, uint)

func (*XMPPMessage) String

func (this *XMPPMessage) String() string

func (*XMPPMessage) Type

func (this *XMPPMessage) Type() home.EcovacsEventType

Type returns the type of message which the message represents

func (*XMPPMessage) Value

func (this *XMPPMessage) Value() interface{}

Value returns the information contained within the message

func (*XMPPMessage) Version

func (this *XMPPMessage) Version() string

Jump to

Keyboard shortcuts

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