mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
ozw: Rework and add some device specific drivers and examples.
This commit reworks ozw somewhat and adds some device specific drivers with examples. All of these drivers are kept in the UPM ozw library. The OZW class has been reworked to make it a proper singleton, since the OpenZWave::Manager() it depends on is already a singleton. This avoids issues such as opening and initializing OpenZWave multiple times. A new, relatively thin base class, ozwInterface is also now present. This class wraps some basic functionality, and handles initialization of the OZW base class. It is intended to be inherited by device driver classes. It operates on a node id for a device. Each OZW device is referenced by a node id, which does not change unless the device is removed (and possibly re-added) to a Z-Wave network. Finally, a series of device specific drivers have been implemented. These provide basic functionality to monitor and in some cases control the operation of a Z-Wave device. They are the following: ozwdump - This is a fake 'device' driver that initializes an OZW network and dumps information on all of the nodes (devices) present. Along with each node, available information on each valueid associated with that node is also printed. This fake device and it's examples replace the original ozw example. aeotecss6 - Aeotec Smart Switch 6. This device allows control of the switch, as well as reporting of information the switch makes available, such as current consumption, volts, watts, and accumulated energy use (kWh). aeotecsdg2 - Aeotec Smart Dimmer Gen 2. This device is similar to the Smart Switch 6, but also provides dimming functionality. It also provides information on energy use. aeotecdw2e - Aeotec Door/Window Sensor 2nd Edition. This device is a magnetic switch with an embedded tamper switch used to detect the opening/closing of windows and doors. This is a battery powered device. aeotecdsb09104 - Aeotec Home Energy Monitor. This device is intended to be installed at the MAINS or Breaker box. It reports current and cumulative energy consumption. tzemt400 - Trane TZEMT400 Thermostat. This device is a thermostat with Z-Wave functionality. The variant tested was the TZEMT400BB32MAA. The driver reports various information on the status of the thermostat, as well as the current measured temperature. Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
96
examples/java/AeotecDSB09104_Example.java
Normal file
96
examples/java/AeotecDSB09104_Example.java
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_ozw.AeotecDSB09104;
|
||||
|
||||
public class AeotecDSB09104_Example
|
||||
{
|
||||
private static String defaultDev = "/dev/ttyACM0";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
{
|
||||
// ! [Interesting]
|
||||
|
||||
if (args.length > 0)
|
||||
defaultDev = args[0];
|
||||
System.out.println("Using device " + defaultDev);
|
||||
|
||||
// Instantiate an Aeotec DSB09104 instance, on device node 12.
|
||||
// You will almost certainly need to change this to reflect
|
||||
// your own network. Use the ozwdump example to see what
|
||||
// nodes are available.
|
||||
AeotecDSB09104 sensor = new AeotecDSB09104(12);
|
||||
|
||||
// The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate();
|
||||
sensor.optionsLock();
|
||||
|
||||
System.out.println("Initializing, this may take awhile depending "
|
||||
+ "on your ZWave network");
|
||||
|
||||
sensor.init(defaultDev);
|
||||
System.out.println("Initialization complete");
|
||||
|
||||
System.out.println("Querying data...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
sensor.update();
|
||||
|
||||
System.out.println("Watts, Channel 1: "
|
||||
+ sensor.getWattsC1()
|
||||
+ " W");
|
||||
|
||||
System.out.println("Watts, Channel 2: "
|
||||
+ sensor.getWattsC2()
|
||||
+ " W");
|
||||
|
||||
System.out.println("Watts, Channel 3: "
|
||||
+ sensor.getWattsC3()
|
||||
+ " W");
|
||||
|
||||
System.out.println("Energy, Channel 1: "
|
||||
+ sensor.getEnergyC1()
|
||||
+ " kWh");
|
||||
|
||||
System.out.println("Energy, Channel 2: "
|
||||
+ sensor.getEnergyC2()
|
||||
+ " kWh");
|
||||
|
||||
System.out.println("Energy, Channel 3: "
|
||||
+ sensor.getEnergyC3()
|
||||
+ " kWh");
|
||||
|
||||
System.out.println("Battery Level: "
|
||||
+ sensor.getBatteryLevel()
|
||||
+ "%");
|
||||
|
||||
System.out.println();
|
||||
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
89
examples/java/AeotecDW2E_Example.java
Normal file
89
examples/java/AeotecDW2E_Example.java
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_ozw.AeotecDW2E;
|
||||
|
||||
public class AeotecDW2E_Example
|
||||
{
|
||||
private static String defaultDev = "/dev/ttyACM0";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
{
|
||||
// ! [Interesting]
|
||||
|
||||
if (args.length > 0)
|
||||
defaultDev = args[0];
|
||||
System.out.println("Using device " + defaultDev);
|
||||
|
||||
// Instantiate an Aeotec Door/Window 2nd Edition sensor
|
||||
// instance, on device node 10. You will almost certainly
|
||||
// need to change this to reflect your own network. Use the
|
||||
// ozwdump example to see what nodes are available.
|
||||
AeotecDW2E sensor = new AeotecDW2E(10);
|
||||
|
||||
// The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate();
|
||||
sensor.optionsLock();
|
||||
|
||||
System.out.println("Initializing, this may take awhile depending "
|
||||
+ "on your ZWave network");
|
||||
|
||||
sensor.init(defaultDev);
|
||||
System.out.println("Initialization complete");
|
||||
|
||||
System.out.println("Querying data...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (sensor.isDeviceAvailable())
|
||||
{
|
||||
System.out.println("Alarm status: "
|
||||
+ sensor.isAlarmTripped());
|
||||
|
||||
System.out.println("Tamper Switch status: "
|
||||
+ sensor.isTamperTripped());
|
||||
|
||||
System.out.println("Battery Level: "
|
||||
+ sensor.getBatteryLevel()
|
||||
+ "%");
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Device has not yet responded "
|
||||
+ "to probe.");
|
||||
System.out.println("Try waking it, or wait until "
|
||||
+ "it wakes itself if "
|
||||
+ "configured to do so.");
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
100
examples/java/AeotecSDG2_Example.java
Normal file
100
examples/java/AeotecSDG2_Example.java
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_ozw.AeotecSDG2;
|
||||
|
||||
public class AeotecSDG2_Example
|
||||
{
|
||||
private static String defaultDev = "/dev/ttyACM0";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
{
|
||||
// ! [Interesting]
|
||||
|
||||
if (args.length > 0)
|
||||
defaultDev = args[0];
|
||||
System.out.println("Using device " + defaultDev);
|
||||
|
||||
// Instantiate an Aeotec Smart Dimmer Gen2 instance, on device node
|
||||
// 9. You will almost certainly need to change this to reflect your
|
||||
// own network. Use the ozwdump example to see what nodes are
|
||||
// available.
|
||||
AeotecSDG2 sensor = new AeotecSDG2(9);
|
||||
|
||||
// The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate();
|
||||
sensor.optionsLock();
|
||||
|
||||
System.out.println("Initializing, this may take awhile depending "
|
||||
+ "on your ZWave network");
|
||||
|
||||
sensor.init(defaultDev);
|
||||
System.out.println("Initialization complete");
|
||||
|
||||
// turn light on
|
||||
System.out.println("Turning switch on, then sleeping for 5 secs");
|
||||
sensor.on();
|
||||
Thread.sleep(5000);
|
||||
|
||||
System.out.println("Querying data...");
|
||||
|
||||
boolean dim = false;
|
||||
while (true)
|
||||
{
|
||||
// put on a light show...
|
||||
if (dim)
|
||||
sensor.setLevel(25);
|
||||
else
|
||||
sensor.on();
|
||||
|
||||
dim = !dim;
|
||||
|
||||
sensor.update();
|
||||
|
||||
System.out.println("Switch status: "
|
||||
+ sensor.isOn());
|
||||
|
||||
System.out.println("Volts: "
|
||||
+ sensor.getVolts()
|
||||
+ " volts");
|
||||
|
||||
System.out.println("Energy Consumption: "
|
||||
+ sensor.getEnergy()
|
||||
+ " kWh");
|
||||
|
||||
System.out.println("Watts: "
|
||||
+ sensor.getWatts());
|
||||
|
||||
System.out.println("Current: "
|
||||
+ sensor.getCurrent()
|
||||
+ " amps");
|
||||
|
||||
System.out.println();
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
91
examples/java/AeotecSS6_Example.java
Normal file
91
examples/java/AeotecSS6_Example.java
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_ozw.AeotecSS6;
|
||||
|
||||
public class AeotecSS6_Example
|
||||
{
|
||||
private static String defaultDev = "/dev/ttyACM0";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
{
|
||||
// ! [Interesting]
|
||||
|
||||
if (args.length > 0)
|
||||
defaultDev = args[0];
|
||||
System.out.println("Using device " + defaultDev);
|
||||
|
||||
// Instantiate an Aeotec Smart Switch 6 instance, on device
|
||||
// node 11. You will almost certainly need to change this to
|
||||
// reflect your own network. Use the ozwdump example to see
|
||||
// what nodes are available.
|
||||
AeotecSS6 sensor = new AeotecSS6(11);
|
||||
|
||||
// The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate();
|
||||
sensor.optionsLock();
|
||||
|
||||
System.out.println("Initializing, this may take awhile depending "
|
||||
+ "on your ZWave network");
|
||||
|
||||
sensor.init(defaultDev);
|
||||
System.out.println("Initialization complete");
|
||||
|
||||
// turn light on
|
||||
System.out.println("Turning switch on, then sleeping for 5 secs");
|
||||
sensor.on();
|
||||
Thread.sleep(5000);
|
||||
|
||||
System.out.println("Querying data...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
sensor.update();
|
||||
|
||||
System.out.println("Switch status: "
|
||||
+ sensor.isOn());
|
||||
|
||||
System.out.println("Volts: "
|
||||
+ sensor.getVolts()
|
||||
+ " volts");
|
||||
|
||||
System.out.println("Energy Consumption: "
|
||||
+ sensor.getEnergy()
|
||||
+ " kWh");
|
||||
|
||||
System.out.println("Watts: "
|
||||
+ sensor.getWatts());
|
||||
|
||||
System.out.println("Current: "
|
||||
+ sensor.getCurrent()
|
||||
+ " amps");
|
||||
|
||||
System.out.println();
|
||||
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
@ -144,4 +144,11 @@ add_example_with_path(BMG160_Example bmx055 bmx055)
|
||||
add_example_with_path(BMM150_Example bmx055 bmx055)
|
||||
add_example_with_path(BMC150_Example bmx055 bmx055)
|
||||
add_example_with_path(BMI055_Example bmx055 bmx055)
|
||||
if (OPENZWAVE_FOUND)
|
||||
add_example_with_path(AeotecSS6_Example ozw ozw)
|
||||
add_example_with_path(AeotecSDG2_Example ozw ozw)
|
||||
add_example_with_path(AeotecDW2E_Example ozw ozw)
|
||||
add_example_with_path(AeotecDSB09104_Example ozw ozw)
|
||||
add_example_with_path(TZEMT400_Example ozw ozw)
|
||||
endif()
|
||||
|
||||
|
98
examples/java/TZEMT400_Example.java
Normal file
98
examples/java/TZEMT400_Example.java
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_ozw.TZEMT400;
|
||||
|
||||
public class TZEMT400_Example
|
||||
{
|
||||
private static String defaultDev = "/dev/ttyACM0";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException
|
||||
{
|
||||
// ! [Interesting]
|
||||
|
||||
if (args.length > 0)
|
||||
defaultDev = args[0];
|
||||
System.out.println("Using device " + defaultDev);
|
||||
|
||||
// Instantiate a TZEMT400 instance, on device node 13. You
|
||||
// will almost certainly need to change this to reflect your
|
||||
// own network. Use the ozwdump example to see what nodes are
|
||||
// available.
|
||||
TZEMT400 sensor = new TZEMT400(13);
|
||||
|
||||
// The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate();
|
||||
sensor.optionsLock();
|
||||
|
||||
System.out.println("Initializing, this may take awhile depending "
|
||||
+ "on your ZWave network");
|
||||
|
||||
sensor.init(defaultDev);
|
||||
System.out.println("Initialization complete");
|
||||
|
||||
System.out.println("Querying data...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
sensor.update();
|
||||
|
||||
System.out.println("Temperature: "
|
||||
+ sensor.getTemperature()
|
||||
+ " C / "
|
||||
+ sensor.getTemperature(true)
|
||||
+ " F");
|
||||
|
||||
System.out.println("Mode: "
|
||||
+ sensor.getMode());
|
||||
|
||||
System.out.println("Operating State: "
|
||||
+ sensor.getOperatingState());
|
||||
|
||||
System.out.println("Heating Point: "
|
||||
+ sensor.getHeatingPointTemperature()
|
||||
+ " C / "
|
||||
+ sensor.getHeatingPointTemperature(true)
|
||||
+ " F");
|
||||
|
||||
System.out.println("Cooling Point: "
|
||||
+ sensor.getCoolingPointTemperature()
|
||||
+ " C / "
|
||||
+ sensor.getCoolingPointTemperature(true)
|
||||
+ " F");
|
||||
|
||||
System.out.println("Fan Mode: "
|
||||
+ sensor.getFanMode());
|
||||
|
||||
System.out.println("Fan State: "
|
||||
+ sensor.getFanState());
|
||||
|
||||
System.out.println();
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
// ! [Interesting]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user