mi_iot_token 1.0.0 copy "mi_iot_token: ^1.0.0" to clipboard
mi_iot_token: ^1.0.0 copied to clipboard

A Flutter package for xiaomi iot token extract.

example/example.dart

import 'dart:convert';
import 'dart:io';

import 'package:mi_iot_token/mi_iot_token.dart';

void main() async {
  MiCloud miCloud = MiCloud();
  var account = null;
  var deviceConfig = null;

  // your can find config example in config.example.json
  final configFile = File('./example/my_config.json');
  final jsonString = await configFile.readAsString();
  final dynamic jsonMap = jsonDecode(jsonString);

  account = jsonMap['account'];
  deviceConfig = jsonMap['device'];
  await miCloud.login(account["username"], account['password']);
  print("login success");

  // set region, if not sure, may be unset that.
  miCloud.setRegion('cn');
  // get mi cloud device list by device ids, if deviceIds is null, get all devices.
  var devices = await miCloud.getDevices();
  print(devices);

  // get a devices by device id
  var device = await miCloud.getDeviceData(deviceConfig['did']);
  print(device);

  // get device props
  var result = await miCloud.getMiotProps(deviceConfig['getProps']);
  print(result);

  // set device props
  var setResult = await miCloud.setMiotProps(deviceConfig['setProps']);
  print(setResult);

  // call device action
  var actionResult = await miCloud.miotAction(deviceConfig['action']);
  print(actionResult);
}
2
likes
130
points
49
downloads

Publisher

verified publisherkujohnln.com

Weekly Downloads

A Flutter package for xiaomi iot token extract.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

convert, crypto, http, universal_io

More

Packages that depend on mi_iot_token