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

outdated

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
pub points
0%
popularity

Publisher

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

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

More

Packages that depend on homie_dart