zwave 0.9.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 38

zwave.dart #

zwave is a Dart package for interacting with Z-Wave devices.

Overview #

This Dart package enables interacting with Z-Wave devices on Linux.

Usage #

This package provides

Requirements #

Setup #

  1. Setup your Z-Wave controller with your Z-Wave devices

  2. Activate this zwave package using the pub global command.

    pub global activate zwave
  1. From your application directory (the application that references the zwave package) run the following command to build the native library
    pub global run zwave:build_lib
  1. Finally, run the included command line application to ensure that this package is installed correctly and can communicate with your devices using your Z-Wave Controller.
    pub global run zwave:zw

pub global activate makes the Dart scripts in the zwave/bin directory runnable from the command line. pub global run zwave:build_lib runs the zwave/bin/build_lib.dart program which in turn calls the build_lib script to compile the native library for the zwave package.

Example #

The example demonstrates how to use this package to build an application for interacting with a Z-Wave network.

Changelog #

0.9.0 #

  • Overhaul for Dart2
  • Rewrote native to remove dependency on Open ZWave binary
  • Restructured to allow composing nodes based on capability

0.8.0 #

  • last Dart 1 compatible version
  • add node group/association accessor, add node, remove node
  • add Device.requestAllConfigParams, Device.get/setConfigParam
  • use Device.setConfigParam instead of the ZWave.device "configuration" parameter
  • track last time that each value changes
  • add orElse named argument to Device.valueByIndex
  • add zwave command line application for querying and updating the ZWave devices

0.7.0 #

  • implement addDevice and removeDevice methods
  • implement RawValue
  • partially implement ScheduleValue
  • add ZWave.heal to update node routing tables
  • add Device.neighborIds indicating which other devices a device can directly communicate with

0.6.0 #

  • enhance ZWave.device to optionally set device name and configuration
  • add ZWave.pollInterval and Value.pollIntensity accessors
  • add Value help text and Device.valueByIndex accessors
  • new NodeEvent and SceneEvent subclasses of Notification

0.5.0 #

  • add Value.index to differentiate between values with the same label
  • update Device.value(...) to search userValues first then all values
  • enhance toString to include device name and value label
  • fix Value.min and max
  • add support for setting short and byte values

0.3.0 #

  • update generate to include comments in src/zwave_g.dart
  • new ZWave deviceSummary convenience method for listing device info
  • add device and value lookup convenience methods
  • add Device update method for updating all a device's information
  • add Device onNotification event stream
  • add support for setting int value
  • rename ZWave.deviceSummary() --> summary() and add Device.summary()
  • add and Device.label getters and setters

0.2.0 #

  • add writeConfig to save network configuration
  • add setters to bool and list values
  • add onChange notification stream
  • add value readOnly and writeOnly accessors
  • parameterize the Value class and its methods
  • add userPath for specifying user data directory
  • add support for DoubleValue

0.1.4 #

  • add value label accessor
  • add value genre and device userValues accessors
  • improve docs

0.1.3 #

  • add device accessors for product and manufacturer information
  • write network config to file on shutdown
  • cleanup generated code and usages

0.1.2 #

  • build device value list from notifications

0.1.1 #

  • initialize Open Z-Wave library
  • connect to Z-Wave controller
  • build device list from notifications


import 'dart:async';

import 'package:logging/logging.dart';
import 'package:zwave/port/rpi_zw_port.dart';
import 'package:zwave/zw_manager.dart';
import 'package:zwave/port/zw_port.dart';

import 'wall_switch.dart';

Future<void> main() async {
  final example = new Example(new RpiZwPort());
  await example.start();
  await example.turnLampOn();
  await new Future.delayed(const Duration(seconds: 2));
  await example.turnLampOff();
  await example.stop();

class Example {
  final ZwPort port;
  final ZwManager manager;

  // Change `9` to the node id of your wall switch or switched outlet
  final lamp = new WallSwitch(9, 'living room', 'lamp');

  Example(this.port) : manager = new ZwManager(port.driver) {

  Future<void> start() async {

    // Update this line with the path to your Z-Wave controller

    final version = await manager.apiLibraryVersion();;

  Future<void> turnLampOn() => lamp.setState(true);
  Future<void> turnLampOff() => lamp.setState(false);

  Future<void> stop() async {
    await port.close();

Logger logger = new Logger('Example');

Use this package as a library

1. Depend on it

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

  zwave: ^0.9.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:zwave/capability/basic.dart';
import 'package:zwave/capability/battery.dart';
import 'package:zwave/capability/meter/electrical.dart';
import 'package:zwave/capability/node_naming.dart';
import 'package:zwave/capability/sensor/binary_sensor.dart';
import 'package:zwave/capability/sensor/multilevel/air_temperature.dart';
import 'package:zwave/capability/sensor/multilevel/humidity.dart';
import 'package:zwave/capability/sensor/multilevel/power.dart';
import 'package:zwave/capability/switch_binary.dart';
import 'package:zwave/capability/thermostat.dart';
import 'package:zwave/capability/zw_node_mixin.dart';
import 'package:zwave/command/zw_command.dart';
import 'package:zwave/command/zw_request.dart';
import 'package:zwave/command/zw_send_data.dart';
import 'package:zwave/handler/application_command_handler.dart';
import 'package:zwave/handler/application_update_handler.dart';
import 'package:zwave/handler/command_handler.dart';
import 'package:zwave/handler/message_dispatcher.dart';
import 'package:zwave/handler/send_data_dispatcher.dart';
import 'package:zwave/message_consts.dart';
import 'package:zwave/node/sleepy_node.dart';
import 'package:zwave/node/unknown_node.dart';
import 'package:zwave/node/unknown_sleepy_node.dart';
import 'package:zwave/node/zw_node.dart';
import 'package:zwave/port/rpi_zw_port.dart';
import 'package:zwave/port/zw_port.dart';
import 'package:zwave/report/api_library_version.dart';
import 'package:zwave/report/basic_report.dart';
import 'package:zwave/report/meter_report.dart';
import 'package:zwave/report/scene_activation_set.dart';
import 'package:zwave/report/sensor_binary_report.dart';
import 'package:zwave/report/sensor_multilevel_report.dart';
import 'package:zwave/report/zw_command_class_report.dart';
import 'package:zwave/zw_driver.dart';
import 'package:zwave/zw_exception.dart';
import 'package:zwave/zw_manager.dart';
import 'package:zwave/zw_message.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 Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms:

Low code quality prevents platform classification.

Health issues and suggestions

Fix bin/build_lib.dart. (-68.36 points)

Analysis of bin/build_lib.dart failed with 4 errors:

line 4 col 8: Target of URI doesn't exist: 'package:path/path.dart'.

line 39 col 32: The function 'join' isn't defined.

line 45 col 35: The function 'join' isn't defined.

line 46 col 36: The function 'join' isn't defined.

Fix lib/capability/node_naming.dart. (-1 points)

Analysis of lib/capability/node_naming.dart reported 2 hints:

line 41 col 7: DO use curly braces for all flow control structures.

line 75 col 7: DO use curly braces for all flow control structures.

Fix bin/zw.dart. (-0.50 points)

Analysis of bin/zw.dart reported 1 hint:

line 10 col 5: DO use curly braces for all flow control structures.

Fix additional 10 files with analysis or formatting issues. (-2.50 points)

Additional issues in the following files:

  • lib/command/zw_command.dart (1 hint)
  • lib/command/zw_request.dart (1 hint)
  • lib/node/zw_node.dart (1 hint)
  • lib/zw_driver.dart (1 hint)
  • lib/zw_manager.dart (1 hint)
  • lib/capability/meter/electrical.dart (Run dartfmt to format lib/capability/meter/electrical.dart.)
  • lib/capability/sensor/multilevel/power.dart (Run dartfmt to format lib/capability/sensor/multilevel/power.dart.)
  • lib/handler/message_dispatcher.dart (Run dartfmt to format lib/handler/message_dispatcher.dart.)
  • lib/report/basic_report.dart (Run dartfmt to format lib/report/basic_report.dart.)
  • lib/report/scene_activation_set.dart (Run dartfmt to format lib/report/scene_activation_set.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Low code quality prevents platform classification.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.60.0 <3.0.0
args ^1.5.0 1.5.2
logging ^0.11.3 0.11.3+2
Dev dependencies
grinder ^0.8.0
mockito ^3.0.0
pedantic ^1.1.0
test ^1.3.4