homie_dart 2.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 57

homie_dart #

An impelementation of the homie convention 4.0 for dart. This package can be used to create devices with nodes and properties in the homie format.

Version 2 of this package includes the core homie_dart library, as well as the homie_legacy_extensions library, which can be used to add device attributes that where removed in homie version 4.0. This is usefull for backwards compatibility. More specific, the Legacy Stats and Legacy Firmware extensions are implemented.

Also included in this package, in the epnw_meta_extension library, is the EPNW Meta extension which can be used to add tags and (nested) key-value pairs to devices, nodes and properties.

To create devices according to the homie convention 3.0.1, use version 1.1.0 of this package instead!

BrokerConnection and MQTT connection #

This package does not contain any MQTT logic! Instead it defines an abstract class BrokerConnection. You can either implement it yourselfe or use the package homie_dart_on_mqtt_client, which handles all the mqtt logic.

Missing Features #

  • Broadcast channel is not implemented

Example #

An example, how to create a device can be found here, and this file shows, how to run it.

[2.0.2] - 15.08.2019 #

  • Implemented pub health suggestions

[2.0.1] - 15.08.2019 #

  • Fixed links due to release of Homie 4
  • Published to pub
  • Did not change any code with respect to package version 2.0.0

[2.0.0] - 08.08.2019 #

  • Implemented Homie convention version 4.0
  • Added support for extensions
  • Implemented the Homie Leagcy Stats and Homie Leagcy Firmware extensions
  • Included EPNW Meta extension

[1.1.0] - 23.07.2019 #

  • Added retained topic clean-up on device disconnect

[1.0.0] - 07.07.2019 #

  • Initial public release


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;

  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));

  await superCar.disconnect();

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  homie_dart: ^2.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:homie_dart/homie_dart.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/unit.dart. (-7.24 points)

Analysis of lib/src/unit.dart reported 15 hints, including:

line 5 col 28: Avoid const keyword.

line 6 col 37: Avoid const keyword.

line 7 col 40: Avoid const keyword.

line 8 col 30: Avoid const keyword.

line 9 col 29: Avoid const keyword.

Fix lib/src/colors.dart. (-2.96 points)

Analysis of lib/src/colors.dart reported 6 hints, including:

line 7 col 14: Unnecessary new keyword.

line 10 col 13: Unnecessary new keyword.

line 39 col 12: Unnecessary new keyword.

line 87 col 14: Unnecessary new keyword.

line 90 col 13: Unnecessary new keyword.

Fix lib/src/legacy/legacy_stats.dart. (-2.96 points)

Analysis of lib/src/legacy/legacy_stats.dart reported 6 hints, including:

line 35 col 38: Unnecessary new keyword.

line 36 col 29: Unnecessary new keyword.

line 45 col 11: Unnecessary new keyword.

line 45 col 30: Unnecessary new keyword.

line 128 col 21: Unnecessary new keyword.

Fix additional 11 files with analysis or formatting issues. (-5.96 points)

Additional issues in the following files:

  • lib/src/model.dart (6 hints)
  • lib/src/extended_properties.dart (2 hints)
  • lib/src/utils.dart (2 hints)
  • lib/src/homie_datatype.dart (1 hint)
  • lib/src/mapped_enum_property.dart (1 hint)
  • lib/epnw_meta_extension.dart (Run dartfmt to format lib/epnw_meta_extension.dart.)
  • lib/homie_dart.dart (Run dartfmt to format lib/homie_dart.dart.)
  • lib/homie_legacy_extensions.dart (Run dartfmt to format lib/homie_legacy_extensions.dart.)
  • lib/src/broker_connection.dart (Run dartfmt to format lib/src/broker_connection.dart.)
  • lib/src/constants.dart (Run dartfmt to format lib/src/constants.dart.)
  • lib/src/epnw_meta/epnw_meta_extension.dart (Run dartfmt to format lib/src/epnw_meta/epnw_meta_extension.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
meta ^1.1.7 1.1.8
pedantic ^1.8.0+1 1.9.0