homie_dart 2.0.2 copy "homie_dart: ^2.0.2" to clipboard
homie_dart: ^2.0.2 copied to clipboard

An implementation of the homie convention 4.0 with extension support in dart. Also features the homie legacy stats, homie legacy firmeware and epnw meta extensions.

example/example.dart

import 'package:homie_dart/homie_dart.dart';
import 'package:homie_dart/homie_legacy_extensions.dart';

import 'supercar.dart';
import 'printbroker.dart';

Future<Null> main(List<String> args) async {
  BrokerConnection con = new PrintBrokerConnection();
  await test(con);
}

Future<Null> test(BrokerConnection con) async {
  qos = 1;

  bool useLegacyExtensions = true;
  SuperCar superCar =
      new SuperCar(deviceId: 'super-car', useLegacyExtensions: useLegacyExtensions);
  if (useLegacyExtensions) {
    DeviceStats deviceStats=superCar.getExtension<LegacyStats>().deviceStats;
    deviceStats.cpuTemperature = 48;
    deviceStats.signalStrength = 24;
    deviceStats.batterLevel = 80;
  }

  print('Init...');
  await superCar.init(con);
  print('Updating engine temperature...');
  superCar.engineTemperature = 32.5;
  print('Engine temperature: ${superCar.engineTemperature}');

  await new Future.delayed(const Duration(seconds: 30));

  print('Disconnecting...');
  await superCar.disconnect();
  print('Disconnected');
}
1
likes
40
points
28
downloads

Publisher

verified publishereric-prokop-und-nils-wieler.de

Weekly Downloads

An implementation of the homie convention 4.0 with extension support in dart. Also features the homie legacy stats, homie legacy firmeware and epnw meta extensions.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

meta, pedantic

More

Packages that depend on homie_dart