You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mijia/test/login_test.go

50 lines
819 B
Go

7 months ago
package test
import (
"encoding/json"
"fmt"
5 months ago
"git.r-2.top/kunmeng/mijia"
7 months ago
"testing"
"time"
)
func Test_login(t *testing.T) {
user := "15542100924"
pwd := "1XAII@wsk"
5 months ago
result, _ := mijia.Login(user, pwd)
7 months ago
_, err := json.Marshal(result)
if err != nil {
return
}
5 months ago
Mi := mijia.NewMiJia(result)
7 months ago
//Mi.Rooms()
Mi.Devices()
//Mi.Scenes(0)
//Mi.RunScene("1784216758920822784")
var data []map[string]interface{}
data = append(data, map[string]interface{}{
"did": "740885802",
"siid": 9,
"piid": 1,
})
data = append(data, map[string]interface{}{
"did": "740885802",
"siid": 9,
"piid": 2,
})
deviceVar, err := Mi.GetDeviceVar(data)
if err != nil {
return
}
for _, v := range deviceVar {
fmt.Printf("%f", v.Value)
}
time.Sleep(10 * time.Second)
//Mi.Consumables(0)
//Mi.Scenes(0)
}