Versions in this module Expand all Collapse all v0 v0.3.0 Oct 11, 2026 Changes in this version + const MDNSService + const SpecMirrorURL + var ErrNotMirrored = errors.New("not in the MIoT specification mirror") + func ConfigureWiFi(ctx context.Context, c *Client, ssid, password string, uid int64, ...) error + func GetProp(ctx context.Context, c *Client, keys []string, max int) ([]any, error) + func ParseMDNSInstance(name string) (model string, did uint32, ok bool) + func SupportsMIoT(ctx context.Context, c *Client) (bool, error) + func TextKey(siid, piid, aiid, value int) string + type BrowseFunc func(ctx context.Context, service string) ([]MDNSEntry, error) + func (f BrowseFunc) Browse(ctx context.Context, service string) ([]MDNSEntry, error) + type Browser interface + Browse func(ctx context.Context, service string) ([]MDNSEntry, error) + type CarpetMode struct + CurrentHigh int + CurrentIntegral int + CurrentLow int + Enabled bool + StallTime int + type CleanRecord struct + Area float64 + Complete bool + Duration time.Duration + End time.Time + Error int + Start time.Time + type CleanSummary struct + Area float64 + Count int + Duration time.Duration + Records []int64 + type Consumable string + const CleaningBrush + const Filter + const MainBrush + const Sensors + const SideBrush + const Strainer + type Consumables struct + Filter time.Duration + MainBrush time.Duration + Raw map[string]any + Sensors time.Duration + SideBrush time.Duration + type DND struct + Enabled bool + EndHour int + EndMinute int + StartHour int + StartMinute int + type DeviceError struct + Code int + Message string + Method string + func (e *DeviceError) Error() string type HTTPSpecs + Fallbacks []string + Status string + func (s *HTTPSpecs) Index(ctx context.Context) ([]SpecInstance, error) + func (s *HTTPSpecs) RawIndex(ctx context.Context) ([]byte, error) + func (s *HTTPSpecs) RawInstance(ctx context.Context, urn string) ([]byte, error) + func (s *HTTPSpecs) RawTranslations(ctx context.Context, urn string) ([]byte, error) + func (s *HTTPSpecs) Translations(ctx context.Context, urn string) (Translations, error) + type MDNSDevice struct + Addr string + DID uint32 + Instance string + Model string + func DiscoverMDNS(ctx context.Context, b Browser) ([]MDNSDevice, error) + type MDNSEntry struct + IPs []net.IP + Instance string + Port int + type SpecInstance struct + Model string + Status string + TS int64 + Type string + Version int + type SpecMirror struct + Dir string + MaxAge time.Duration + Upstream *HTTPSpecs + func (m *SpecMirror) Add(model string, version int, raw []byte) error + func (m *SpecMirror) AddTranslations(urn string, raw []byte) error + func (m *SpecMirror) Fill(ctx context.Context, models ...string) error + func (m *SpecMirror) FillAll(ctx context.Context, workers int) error + func (m *SpecMirror) FillTranslations(ctx context.Context, models ...string) error + func (m *SpecMirror) Handler() http.Handler + func (m *SpecMirror) Models() []string + func (m *SpecMirror) RawInstance(ctx context.Context, urn string) ([]byte, error) + func (m *SpecMirror) RawTranslations(ctx context.Context, urn string) ([]byte, error) + func (m *SpecMirror) Spec(ctx context.Context, model string) (*Spec, error) + func (m *SpecMirror) Stored(model string) bool + func (m *SpecMirror) Translations(ctx context.Context, urn string) (Translations, error) + func (m *SpecMirror) URN(ctx context.Context, model string) (string, error) + type Translations map[string]map[string]string + func ParseTranslations(b []byte) (Translations, error) + func (t Translations) Text(lang, key string) string type Vacuum + func (v *Vacuum) AddTimer(ctx context.Context, id, cron string) (string, error) + func (v *Vacuum) CarpetMode(ctx context.Context) (CarpetMode, error) + func (v *Vacuum) CleanRecord(ctx context.Context, id int64) (CleanRecord, error) + func (v *Vacuum) CleanSummary(ctx context.Context) (CleanSummary, error) + func (v *Vacuum) Consumables(ctx context.Context) (Consumables, error) + func (v *Vacuum) DND(ctx context.Context) (DND, error) + func (v *Vacuum) DeleteTimer(ctx context.Context, id string) error + func (v *Vacuum) DisableDND(ctx context.Context) error + func (v *Vacuum) EnableTimer(ctx context.Context, id string, on bool) error + func (v *Vacuum) FanSpeed(ctx context.Context) (int, error) + func (v *Vacuum) FanSpeedPresets() (map[string]int, error) + func (v *Vacuum) Find(ctx context.Context) error + func (v *Vacuum) ResetConsumable(ctx context.Context, part Consumable) error + func (v *Vacuum) SetCarpetMode(ctx context.Context, on bool) error + func (v *Vacuum) SetCarpetModeSettings(ctx context.Context, c CarpetMode) error + func (v *Vacuum) SetDND(ctx context.Context, startHour, startMinute, endHour, endMinute int) error + func (v *Vacuum) SetFanSpeed(ctx context.Context, speed int) error + func (v *Vacuum) SetVolume(ctx context.Context, pct int) error + func (v *Vacuum) Spot(ctx context.Context) error + func (v *Vacuum) TestVolume(ctx context.Context) error + func (v *Vacuum) Timers(ctx context.Context) ([]VacuumTimer, error) + func (v *Vacuum) Timezone(ctx context.Context) (string, error) + func (v *Vacuum) Volume(ctx context.Context) (int, error) + type VacuumTimer struct + Action string + Cron string + Enabled bool + ID string + Params any v0.2.0 Oct 11, 2026 Changes in this version + const ByEmail + const ByPhone + const OTADownloading + const OTAFailed + const OTAIdle + const OTAInstalling + var ErrAccess = errors.New("the property does not allow this access") + var ErrOTAFailed = errors.New("the device reports the firmware update as failed") + var ErrUnknownName = errors.New("no such property or action in the MIoT specification") + var ErrUnsupported = errors.New("the device model has no such function") + var ErrValue = errors.New("the value does not fit the property") + func SubDeviceModel(typeID int) string + func TokenEnc(token []byte) string + func Update(ctx context.Context, c *Client, url, md5Hex string) error + func UpdateProgress(ctx context.Context, c *Client) (int, error) + func UpdateState(ctx context.Context, c *Client) (string, error) + func WaitUpdate(ctx context.Context, c *Client, interval time.Duration, ...) error type Action + Description string + Out []int type Cloud + CaptchaCode string + func (c *Cloud) Captcha(ctx context.Context) ([]byte, error) + func (c *Cloud) CloudCall(ctx context.Context, region, did, method string, params any) (json.RawMessage, error) + func (c *Cloud) CloudDoAction(ctx context.Context, region, did string, siid, aiid int, in []any) error + func (c *Cloud) CloudGetProperties(ctx context.Context, region string, refs []PropRef) ([]PropResult, error) + func (c *Cloud) CloudSetProperties(ctx context.Context, region string, refs []PropRef) ([]PropResult, error) + func (c *Cloud) SendCode(ctx context.Context, by string) error + func (c *Cloud) VerifyCode(ctx context.Context, by, code string) error type CloudDevice + ParentID string + ParentModel string + func GatewaySubDevices(devs []CloudDevice, gatewayDID string) []CloudDevice + type EventInfo struct + Action string + CommandExtra string + Event string + Extra string + SourceDID string + SourceModel string + TriggerToken string + TriggerValue any + type Family struct + Client *Client + DID string + LegacyModel string + Model *Model + type Gateway struct + Client *Client + Model string + func (g *Gateway) RemoveSubDevice(ctx context.Context, sid string) error + func (g *Gateway) SetSubProp(ctx context.Context, sid, name string, v any) error + func (g *Gateway) SubBattery(ctx context.Context, sid string) (int, error) + func (g *Gateway) SubDevices(ctx context.Context) ([]SubDevice, error) + func (g *Gateway) SubProp(ctx context.Context, sid, name string) (any, error) + func (g *Gateway) SubProps(ctx context.Context, sid string, names ...string) ([]any, error) + type Light struct + func (l *Light) Off(ctx context.Context) error + func (l *Light) On(ctx context.Context) error + func (l *Light) SetBrightness(ctx context.Context, pct int) error + func (l *Light) SetColor(ctx context.Context, rgb int) error + func (l *Light) SetColorTemperature(ctx context.Context, kelvin int) error + func (l *Light) SetColorTemperatureScale(ctx context.Context, v int) error + func (l *Light) Status(ctx context.Context) (LightStatus, error) + type LightStatus struct + Brightness int + Color int + ColorTemperature int + On bool + type MappedAction struct + Name string + SIID int + type MappedProperty struct + Name string + SIID int + type Model struct + Spec *Spec + func ModelFor(ctx context.Context, specs SpecSource, model string) (*Model, error) + func NewModel(sp *Spec) (*Model, error) + func (m *Model) Action(name string) (MappedAction, error) + func (m *Model) Actions() []MappedAction + func (m *Model) Do(ctx context.Context, c *Client, did, name string, in ...any) error + func (m *Model) Get(ctx context.Context, c *Client, did string, names ...string) (map[string]any, error) + func (m *Model) Has(name string) bool + func (m *Model) Properties() []MappedProperty + func (m *Model) Property(name string) (MappedProperty, error) + func (m *Model) Set(ctx context.Context, c *Client, did, name string, v any) error + func (m *Model) SetMany(ctx context.Context, c *Client, did string, vals map[string]any) error + type Plug struct + func (p *Plug) Off(ctx context.Context) error + func (p *Plug) On(ctx context.Context) error + func (p *Plug) Status(ctx context.Context) (PlugStatus, error) + type PlugStatus struct + On bool + Temperature float64 type Property + func (p Property) Check(v any) (any, error) + func (p Property) Describe(v any) string + func (p Property) ValueOf(desc string) (int, bool) + type Purifier struct + func (p *Purifier) Off(ctx context.Context) error + func (p *Purifier) On(ctx context.Context) error + func (p *Purifier) SetFanLevel(ctx context.Context, level int) error + func (p *Purifier) SetMode(ctx context.Context, mode string) error + func (p *Purifier) Status(ctx context.Context) (PurifierStatus, error) + type PurifierStatus struct + FanLevel int + Humidity float64 + Mode string + On bool + PM25 float64 + Temperature float64 + type Push struct + Action string + Device string + Params json.RawMessage + Source string + type PushServer struct + Addr string + DeviceID uint32 + Model string + ServerIP string + func (s *PushServer) Close() error + func (s *PushServer) LocalAddr() net.Addr + func (s *PushServer) Register(c *Client, handler func(Push)) error + func (s *PushServer) Start() error + func (s *PushServer) Subscribe(ctx context.Context, c *Client, ev EventInfo) (string, error) + func (s *PushServer) Subscriptions(c *Client) []string + func (s *PushServer) Unsubscribe(ctx context.Context, c *Client, id string) error + type SubDevice struct + Firmware int + Model string + SID string + TypeID int + type Vacuum struct + func (v *Vacuum) Home(ctx context.Context) error + func (v *Vacuum) Pause(ctx context.Context) error + func (v *Vacuum) Start(ctx context.Context) error + func (v *Vacuum) Status(ctx context.Context) (VacuumStatus, error) + func (v *Vacuum) Stop(ctx context.Context) error + type VacuumStatus struct + Battery int + Code int + State string + type VerifyError struct + CaptchaURL string + NotificationURL string + WrongCaptcha bool + func (e *VerifyError) Error() string + func (e *VerifyError) Unwrap() error v0.1.0 Oct 11, 2026 Changes in this version + const DefaultSpecURL + const Port + var ErrCloudAuth = errors.New("the Mi account refused the user name or password") + var ErrCloudVerify = errors.New(...) + var ErrNoSpec = errors.New("no MIoT specification of the model") + var ErrToken = errors.New("the device's answer does not open with the token") + var Regions = []string + func CheckAction(raw json.RawMessage) error + func Decrypt(token, ct []byte) ([]byte, error) + func DefaultAPIBase(region string) string + func Discover(ctx context.Context, bcast string, wait time.Duration) (map[uint32]string, error) + func DoAction(ctx context.Context, c *Client, did string, siid, aiid int, in []any) error + func EncSignature(method, path string, params [][2]string, signedNonce string) string + func Encrypt(token, plain []byte) []byte + func Hello() []byte + func Keys(token []byte) (key, iv []byte) + func Packet(token []byte, deviceID, stamp uint32, plain []byte) []byte + func RC4Decrypt(signedNonce, v string) ([]byte, error) + func RC4Encrypt(signedNonce, v string) string + func SignedNonce(ssecurity, nonce string) string + func URNName(urn string) (string, bool) + type Action struct + IID int + In []int + Type string + type Client struct + Addr string + Timeout time.Duration + Token []byte + func (c *Client) Call(ctx context.Context, method string, params any) (json.RawMessage, error) + func (c *Client) DeviceID() uint32 + type Cloud struct + APIBase func(region string) string + AccountBase string + HTTP *http.Client + Password string + Username string + func (c *Cloud) Devices(ctx context.Context, regions []string) ([]CloudDevice, error) + func (c *Cloud) Login(ctx context.Context) error + type CloudDevice struct + DID string + LocalIP string + MAC string + Model string + Name string + Online bool + Region string + Token string + type HTTPSpecs struct + Base string + HTTP *http.Client + func (s *HTTPSpecs) Spec(ctx context.Context, model string) (*Spec, error) + type Header struct + Checksum []byte + DeviceID uint32 + Length uint16 + Stamp uint32 + Unknown uint32 + func Open(token, b []byte) (Header, []byte, error) + func ParseHeader(b []byte) (Header, error) + type PropError struct + Action bool + Code int + IID int + SIID int + func (e *PropError) Error() string + type PropRef struct + Code int + DID string + PIID int + SIID int + Value any + type PropResult struct + Code int + DID string + PIID int + SIID int + Value any + func CheckSet(raw json.RawMessage) ([]PropResult, error) + func GetProperties(ctx context.Context, c *Client, refs []PropRef) ([]PropResult, error) + func SetProperties(ctx context.Context, c *Client, refs []PropRef) ([]PropResult, error) + type Property struct + Access []string + Description string + Format string + IID int + Type string + Unit string + ValueList []ValueItem + ValueRange []float64 + func (p Property) Can(a string) bool + type Service struct + Actions []Action + Description string + IID int + Properties []Property + Type string + type Spec struct + Description string + Services []Service + Type string + type SpecSource interface + Spec func(ctx context.Context, model string) (*Spec, error) + type ValueItem struct + Description string + Value int