homie_dart 2.0.2

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

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

Use this package as a library

1. Depend on it

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


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Aug 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:homie_dart/homie_dart.dart.

Health suggestions

Format lib/epnw_meta_extension.dart.

Run dartfmt to format lib/epnw_meta_extension.dart.

Format lib/homie_dart.dart.

Run dartfmt to format lib/homie_dart.dart.

Format lib/homie_legacy_extensions.dart.

Run dartfmt to format lib/homie_legacy_extensions.dart.

Fix additional 6 files with analysis or formatting issues.

Additional issues in the following files:

  • 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.)
  • lib/src/homie_datatype.dart (Run dartfmt to format lib/src/homie_datatype.dart.)
  • lib/src/legacy/legacy_stats.dart (Run dartfmt to format lib/src/legacy/legacy_stats.dart.)
  • lib/src/utils.dart (Run dartfmt to format lib/src/utils.dart.)

Dependencies

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