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:
Jon Trulson 2016-07-06 13:25:39 -06:00
parent 8da6095c35
commit 9ab9e2c403
47 changed files with 4067 additions and 205 deletions

View File

@ -224,10 +224,6 @@ add_example (groveultrasonic)
add_example (sx1276-lora)
add_example (sx1276-fsk)
add_example (ili9341)
if (OPENZWAVE_FOUND)
include_directories(${OPENZWAVE_INCLUDE_DIRS})
add_example (ozw)
endif()
add_example (nlgpio16)
add_example (ads1x15)
if (MODBUS_FOUND)
@ -303,3 +299,13 @@ add_custom_example (bmg160-example bmg160.cxx bmx055)
add_custom_example (bmm150-example bmm150.cxx bmx055)
add_custom_example (bmc150-example bmc150.cxx bmx055)
add_custom_example (bmi055-example bmi055.cxx bmx055)
if (OPENZWAVE_FOUND)
include_directories(${OPENZWAVE_INCLUDE_DIRS})
add_custom_example (ozwdump-example ozwdump.cxx ozw)
add_custom_example (aeotecss6-example aeotecss6.cxx ozw)
add_custom_example (aeotecsdg2-example aeotecsdg2.cxx ozw)
add_custom_example (aeotecdw2e-example aeotecdw2e.cxx ozw)
add_custom_example (aeotecdsb09104-example aeotecdsb09104.cxx ozw)
add_custom_example (tzemt400-example tzemt400.cxx ozw)
endif()

View File

@ -0,0 +1,123 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "aeotecdsb09104.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
string defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
// 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.
upm::AeotecDSB09104 *sensor = new upm::AeotecDSB09104(12);
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
sensor->init(defaultDev);
cout << "Initialization complete" << endl;
cout << "Querying data..." << endl;
while (shouldRun)
{
sensor->update();
cout << "Watts, Channel 1: "
<< sensor->getWattsC1()
<< " W"
<< endl;
cout << "Watts, Channel 2: "
<< sensor->getWattsC2()
<< " W"
<< endl;
cout << "Watts, Channel 3: "
<< sensor->getWattsC3()
<< " W"
<< endl;
cout << "Energy, Channel 1: "
<< sensor->getEnergyC1()
<< " kWh"
<< endl;
cout << "Energy, Channel 2: "
<< sensor->getEnergyC2()
<< " kWh"
<< endl;
cout << "Energy, Channel 3: "
<< sensor->getEnergyC3()
<< " kWh"
<< endl;
cout << "Battery Level: "
<< sensor->getBatteryLevel()
<< "%"
<< endl;
cout << endl;
sleep(3);
}
// sensor->dumpNodes(true);
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

109
examples/c++/aeotecdw2e.cxx Normal file
View File

@ -0,0 +1,109 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "aeotecdw2e.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
string defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
// 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.
upm::AeotecDW2E *sensor = new upm::AeotecDW2E(10);
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
sensor->init(defaultDev);
cout << "Initialization complete" << endl;
cout << "Querying data..." << endl;
while (shouldRun)
{
if (sensor->isDeviceAvailable())
{
cout << "Alarm status: "
<< sensor->isAlarmTripped()
<< endl;
cout << "Tamper Switch status: "
<< sensor->isTamperTripped()
<< endl;
cout << "Battery Level: "
<< sensor->getBatteryLevel()
<< "%"
<< endl;
cout << endl;
}
else
{
cout << "Device has not yet responded to probe."
<< endl;
cout << "Try waking it, or wait until it wakes itself if configured"
<< " to do so."
<< endl;
cout << endl;
}
sleep(1);
}
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

127
examples/c++/aeotecsdg2.cxx Normal file
View File

@ -0,0 +1,127 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "aeotecsdg2.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
string defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
// 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.
upm::AeotecSDG2 *sensor = new upm::AeotecSDG2(9);
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
sensor->init(defaultDev);
cout << "Initialization complete" << endl;
// turn light on
cout << "Turning switch on, then sleeping for 5 secs" << endl;
sensor->on();
sleep(5);
cout << "Querying data..." << endl;
bool dim = false;
while (shouldRun)
{
// put on a light show...
if (dim)
sensor->setLevel(25);
else
sensor->on();
dim = !dim;
sensor->update();
cout << "Current Level: "
<< sensor->getLevel()
<< endl;
cout << "Volts: "
<< sensor->getVolts()
<< " volts"
<< endl;
cout << "Energy Consumption: "
<< sensor->getEnergy()
<< " kWh"
<< endl;
cout << "Watts: "
<< sensor->getWatts()
<< endl;
cout << "Current: "
<< sensor->getCurrent()
<< " amps"
<< endl;
cout << endl;
sleep(5);
}
cout << "Turning switch off and sleeping for 5 seconds..." << endl;
sensor->off();
sleep(5);
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

117
examples/c++/aeotecss6.cxx Normal file
View File

@ -0,0 +1,117 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "aeotecss6.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
string defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
// Instantiate an Aeotec SS6 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.
upm::AeotecSS6 *sensor = new upm::AeotecSS6(11);
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
sensor->init(defaultDev);
cout << "Initialization complete" << endl;
// turn light on
cout << "Turning switch on, then sleeping for 5 secs" << endl;
sensor->on();
sleep(5);
cout << "Querying data..." << endl;
while (shouldRun)
{
sensor->update();
cout << "Switch status: "
<< sensor->isOn()
<< endl;
cout << "Volts: "
<< sensor->getVolts()
<< " volts"
<< endl;
cout << "Energy Consumption: "
<< sensor->getEnergy()
<< " kWh"
<< endl;
cout << "Watts: "
<< sensor->getWatts()
<< endl;
cout << "Current: "
<< sensor->getCurrent()
<< " amps"
<< endl;
cout << endl;
sleep(3);
}
cout << "Turning switch off and sleeping for 5 seconds..." << endl;
sensor->off();
sleep(5);
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include "ozw.hpp"
#include "ozwdump.hpp"
using namespace std;
@ -39,53 +39,49 @@ int main(int argc, char **argv)
if (argc > 1)
defaultDev = string(argv[1]);
// Instantiate an OZW instance
upm::OZW *sensor = new upm::OZW();
// Instantiate an OZWDUMP instance
upm::OZWDUMP *sensor = new upm::OZWDUMP();
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
if (!sensor->init(defaultDev))
{
cerr << "Init failed." << endl;
return 0;
}
sensor->init(defaultDev);
cout << "Initialization complete" << endl;
cout << "Dumping nodes..." << endl;
sensor->dumpNodes();
sensor->dumpNodes(true);
// The following is example output of dumpNodes:
//
// Dumping nodes...
// Node 1: Z-Stick Gen5
// Node 2: Smart Switch 6
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Energy, Value: 1.190 kWh
// Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh
// Index: 4, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 5, Type: float, Label: Power, Value: 0.000 W
// Index: 6, Type: float, Label: Voltage, Value: 121.256 V
// Index: 7, Type: float, Label: Current, Value: 0.000 A
// Index: 8, Type: bool, Label: Exporting, Value: False
// Index: 45, Type: list, Label: Day, Value: Friday
// Index: 46, Type: byte, Label: Hour, Value: 5
// Index: 47, Type: byte, Label: Minute, Value: 53
// Index: 8, Type: bool, Label: Exporting, Value: False
// Index: 45, Type: list, Label: Day, Value: Friday
// Index: 46, Type: byte, Label: Hour, Value: 5
// Index: 47, Type: byte, Label: Minute, Value: 53
// Node 3: Multi Sensor
// Index: 0, Type: bool, Label: Sensor, Value: True
// Index: 0, Type: bool, Label: Sensor, Value: True
// Index: 1, Type: float, Label: Temperature, Value: 72.8 F
// Index: 2, Type: float, Label: Luminance, Value: 4 lux
// Index: 3, Type: float, Label: Relative Humidity, Value: 22 %
// Index: 17, Type: byte, Label: Battery Level, Value: 98 %
// Node 5: Minimote
// Node 6: Smart Energy Switch
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Power, Value: 0.000 W
// Index: 3, Type: float, Label: Energy, Value: 1.609 kWh
// Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh
@ -93,9 +89,9 @@ int main(int argc, char **argv)
// Index: 6, Type: float, Label: Power, Value: 0.000 W
// Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 9, Type: bool, Label: Exporting, Value: False
// Index: 9, Type: bool, Label: Exporting, Value: False
// Node 7: Smart Energy Switch
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Power, Value: 0.000 W
// Index: 3, Type: float, Label: Energy, Value: 0.000 kWh
// Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh
@ -103,39 +99,14 @@ int main(int argc, char **argv)
// Index: 6, Type: float, Label: Power, Value: 0.000 W
// Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 9, Type: bool, Label: Exporting, Value: False
// Index: 9, Type: bool, Label: Exporting, Value: False
//
// So, with the above in mind:
//
// 1. Query the temperature on node 3 and print it out (as a
// string), along with the units of measure:
//
// cout << "Temperature: " << sensor->getValueAsString(3, 1)
// << " " << sensor->getValueUnits(3, 1) << endl;
//
// 2. query the same temperature as a float:
//
// float temperature = sensor->getValueAsFloat(3, 1);
//
// 3. Turn on the light plugged into the switch on Node 7, wait 5
// seconds, then turn it back off again:
//
// cout << "Turning ON node 7" << endl;
// sensor->setValueAsBool(7, 0, true);
//
// cout << "Sleeping for 5 seconds" << endl;
// sleep(5);
//
// cout << "Turning OFF node 7" << endl;
// sensor->setValueAsBool(7, 0, false);
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

114
examples/c++/tzemt400.cxx Normal file
View File

@ -0,0 +1,114 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "tzemt400.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
string defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
// 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.
upm::TZEMT400 *sensor = new upm::TZEMT400(13);
// The first thing to do is create options, then lock them when done.
sensor->optionsCreate();
sensor->optionsLock();
// Next, initialize it.
cout << "Initializing, this may take awhile depending on your ZWave network"
<< endl;
sensor->init(defaultDev);
cout << "Initialization complete" << endl;
cout << "Querying data..." << endl;
while (shouldRun)
{
sensor->update();
// we show both C and F for temperatures
cout << "Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
<< endl;
cout << "Mode: "
<< sensor->getMode()
<< endl;
cout << "Operating State: "
<< sensor->getOperatingState()
<< endl;
cout << "Heating Point: " << sensor->getHeatingPointTemperature()
<< " C / " << sensor->getHeatingPointTemperature(true) << " F"
<< endl;
cout << "Cooling Point: " << sensor->getCoolingPointTemperature()
<< " C / " << sensor->getCoolingPointTemperature(true) << " F"
<< endl;
cout << "Fan Mode: "
<< sensor->getFanMode()
<< endl;
cout << "Fan State: "
<< sensor->getFanState()
<< endl;
cout << endl;
sleep(5);
}
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View 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]
}
}

View 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]
}
}

View 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]
}
}

View 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]
}
}

View File

@ -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()

View 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]
}
}

View File

@ -0,0 +1,103 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_ozw');
/************** Main code **************/
var defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (process.argv.length > 2)
{
defaultDev = process.argv[2];
}
console.log("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.
var sensor = new sensorObj.AeotecDSB09104(12);
// The first thing to do is create options, then lock them when done.
sensor.optionsCreate();
sensor.optionsLock();
// Next, initialize it.
console.log("Initializing, this may take awhile depending on your ZWave network");
sensor.init(defaultDev);
console.log("Initialization complete");
console.log("Querying data...");
setInterval(function()
{
sensor.update();
console.log("Watts, Channel 1: "
+ sensor.getWattsC1()
+ " W");
console.log("Watts, Channel 2: "
+ sensor.getWattsC2()
+ " W");
console.log("Watts, Channel 3: "
+ sensor.getWattsC3()
+ " W");
console.log("Energy, Channel 1: "
+ sensor.getEnergyC1()
+ " kWh");
console.log("Energy, Channel 2: "
+ sensor.getEnergyC2()
+ " kWh");
console.log("Energy, Channel 3: "
+ sensor.getEnergyC3()
+ " kWh");
console.log("Battery Level: "
+ sensor.getBatteryLevel()
+ "%");
console.log();
}, 3000);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,95 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_ozw');
/************** Main code **************/
var defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (process.argv.length > 2)
{
defaultDev = process.argv[2];
}
console.log("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.
var sensor = new sensorObj.AeotecDW2E(10);
// The first thing to do is create options, then lock them when done.
sensor.optionsCreate();
sensor.optionsLock();
// Next, initialize it.
console.log("Initializing, this may take awhile depending on your ZWave network");
sensor.init(defaultDev);
console.log("Initialization complete");
console.log("Querying data...");
setInterval(function()
{
if (sensor.isDeviceAvailable())
{
console.log("Alarm status: "
+ sensor.isAlarmTripped());
console.log("Tamper Switch status: "
+ sensor.isTamperTripped());
console.log("Battery Level: "
+ sensor.getBatteryLevel()
+ "%");
console.log();
}
else
{
console.log("Device has not yet responded to probe.");
console.log("Try waking it, or wait until it wakes itself if "
+ "configured to do so.");
console.log();
}
}, 1000);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,119 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_ozw');
function sleepFor(millis)
{
var now = new Date().getTime();
while(new Date().getTime() < now + millis)
{
/* do nothing */
}
}
/************** Main code **************/
var defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (process.argv.length > 2)
{
defaultDev = process.argv[2];
}
console.log("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.
var sensor = new sensorObj.AeotecSDG2(9);
// The first thing to do is create options, then lock them when done.
sensor.optionsCreate();
sensor.optionsLock();
// Next, initialize it.
console.log("Initializing, this may take awhile depending on your ZWave network");
sensor.init(defaultDev);
console.log("Initialization complete");
// turn light on
console.log("Turning switch on, then sleeping for 5 secs");
sensor.on();
sleepFor(5000);
console.log("Querying data...");
var dim = false;
setInterval(function()
{
// put on a light show...
if (dim)
sensor.setLevel(25);
else
sensor.on();
dim = !dim;
sensor.update();
console.log("Current Level: "
+ sensor.getLevel());
console.log("Volts: "
+ sensor.getVolts()
+ " volts");
console.log("Energy Consumption: "
+ sensor.getEnergy()
+ " kWh");
console.log("Watts: "
+ sensor.getWatts());
console.log("Current: "
+ sensor.getCurrent()
+ " amps");
console.log();
}, 5000);
// exit on ^C
process.on('SIGINT', function()
{
console.log("Turning switch off and sleeping for 5 seconds...");
sensor.off();
sleepFor(5000);
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,110 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_ozw');
function sleepFor(millis)
{
var now = new Date().getTime();
while(new Date().getTime() < now + millis)
{
/* do nothing */
}
}
/************** Main code **************/
var defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (process.argv.length > 2)
{
defaultDev = process.argv[2];
}
console.log("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.
var sensor = new sensorObj.AeotecSS6(11);
// The first thing to do is create options, then lock them when done.
sensor.optionsCreate();
sensor.optionsLock();
// Next, initialize it.
console.log("Initializing, this may take awhile depending on your ZWave network");
sensor.init(defaultDev);
console.log("Initialization complete");
// turn light on
console.log("Turning switch on, then sleeping for 5 secs");
sensor.on();
sleepFor(5000);
console.log("Querying data...");
setInterval(function()
{
sensor.update();
console.log("Switch status: "
+ sensor.isOn());
console.log("Volts: "
+ sensor.getVolts()
+ " volts");
console.log("Energy Consumption: "
+ sensor.getEnergy()
+ " kWh");
console.log("Watts: "
+ sensor.getWatts());
console.log("Current: "
+ sensor.getCurrent()
+ " amps");
console.log();
}, 3000);
// exit on ^C
process.on('SIGINT', function()
{
console.log("Turning switch off and sleeping for 5 seconds...");
sensor.off();
sleepFor(5000);
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -3,7 +3,7 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -31,7 +31,7 @@ var sensorObj = require('jsupm_ozw');
/************** Main code **************/
// Instantiate an OZW instance
var sensor = new sensorObj.OZW();
var sensor = new sensorObj.OZWDUMP();
var defaultDev = "/dev/ttyACM0";
@ -48,42 +48,38 @@ sensor.optionsLock();
// Next, initialize it.
console.log("Initializing, this may take awhile depending on your ZWave network");
if (!sensor.init(defaultDev))
{
console.log("Init failed.");
process.exit(0);
}
sensor.init(defaultDev);
console.log("Initialization complete");
console.log("Dumping nodes...");
sensor.dumpNodes();
sensor.dumpNodes(true);
// The following is example output of dumpNodes:
//
// Dumping nodes...
// Node 1: Z-Stick Gen5
// Node 2: Smart Switch 6
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Energy, Value: 1.190 kWh
// Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh
// Index: 4, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 5, Type: float, Label: Power, Value: 0.000 W
// Index: 6, Type: float, Label: Voltage, Value: 121.256 V
// Index: 7, Type: float, Label: Current, Value: 0.000 A
// Index: 8, Type: bool, Label: Exporting, Value: False
// Index: 45, Type: list, Label: Day, Value: Friday
// Index: 46, Type: byte, Label: Hour, Value: 5
// Index: 47, Type: byte, Label: Minute, Value: 53
// Index: 8, Type: bool, Label: Exporting, Value: False
// Index: 45, Type: list, Label: Day, Value: Friday
// Index: 46, Type: byte, Label: Hour, Value: 5
// Index: 47, Type: byte, Label: Minute, Value: 53
// Node 3: Multi Sensor
// Index: 0, Type: bool, Label: Sensor, Value: True
// Index: 0, Type: bool, Label: Sensor, Value: True
// Index: 1, Type: float, Label: Temperature, Value: 72.8 F
// Index: 2, Type: float, Label: Luminance, Value: 4 lux
// Index: 3, Type: float, Label: Relative Humidity, Value: 22 %
// Index: 17, Type: byte, Label: Battery Level, Value: 98 %
// Node 5: Minimote
// Node 6: Smart Energy Switch
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Power, Value: 0.000 W
// Index: 3, Type: float, Label: Energy, Value: 1.609 kWh
// Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh
@ -91,9 +87,9 @@ sensor.dumpNodes();
// Index: 6, Type: float, Label: Power, Value: 0.000 W
// Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 9, Type: bool, Label: Exporting, Value: False
// Index: 9, Type: bool, Label: Exporting, Value: False
// Node 7: Smart Energy Switch
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 0, Type: bool, Label: Switch, Value: False
// Index: 2, Type: float, Label: Power, Value: 0.000 W
// Index: 3, Type: float, Label: Energy, Value: 0.000 kWh
// Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh
@ -101,24 +97,7 @@ sensor.dumpNodes();
// Index: 6, Type: float, Label: Power, Value: 0.000 W
// Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W
// Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
// Index: 9, Type: bool, Label: Exporting, Value: False
//
// So, with the above in mind:
//
// 1. Query the temperature on node 3 and print it out (as a
// string), along with the units of measure:
//
// console.log("Temperature: " + sensor.getValueAsString(3, 1) +
// " " + sensor.getValueUnits(3, 1));
//
// 2. query the same temperature as a float:
//
// var temperature = sensor.getValueAsFloat(3, 1);
//
// 3. Turn on the light plugged into the switch on Node 7
//
// console.log("Turning ON node 7");
// sensor.setValueAsBool(7, 0, true);
// Index: 9, Type: bool, Label: Exporting, Value: False
//
sensor = null;

View File

@ -0,0 +1,104 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_ozw');
/************** Main code **************/
var defaultDev = "/dev/ttyACM0";
// if an argument was specified, use it as the device instead
if (process.argv.length > 2)
{
defaultDev = process.argv[2];
}
console.log("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.
var sensor = new sensorObj.TZEMT400(13);
// The first thing to do is create options, then lock them when done.
sensor.optionsCreate();
sensor.optionsLock();
// Next, initialize it.
console.log("Initializing, this may take awhile depending on your ZWave network");
sensor.init(defaultDev);
console.log("Initialization complete");
console.log("Querying data...");
setInterval(function()
{
sensor.update();
console.log("Temperature: "
+ sensor.getTemperature()
+ " C / "
+ sensor.getTemperature(true)
+ " F");
console.log("Mode: "
+ sensor.getMode());
console.log("Operating State: "
+ sensor.getOperatingState());
console.log("Heating Point: "
+ sensor.getHeatingPointTemperature()
+ " C / "
+ sensor.getHeatingPointTemperature(true)
+ " F");
console.log("Cooling Point: "
+ sensor.getCoolingPointTemperature()
+ " C / "
+ sensor.getCoolingPointTemperature(true)
+ " F");
console.log("Fan Mode: "
+ sensor.getFanMode());
console.log("Fan State: "
+ sensor.getFanState());
console.log();
}, 5000);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,88 @@
#!/usr/bin/python
# 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 time, sys, signal, atexit
import pyupm_ozw as sensorObj
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
defaultDev = "/dev/ttyACM0"
if (len(sys.argv) > 1):
defaultDev = sys.argv[1]
print "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.
sensor = sensorObj.AeotecDSB09104(12)
# The first thing to do is create options, then lock them when done.
sensor.optionsCreate()
sensor.optionsLock()
# Next, initialize it.
print "Initializing, this may take awhile depending on your ZWave network"
sensor.init(defaultDev)
print "Initialization complete"
print "Querying data..."
while (True):
sensor.update()
print "Watts, Channel 1:",
print sensor.getWattsC1(),
print "W"
print "Watts, Channel 2:",
print sensor.getWattsC2(),
print "W"
print "Watts, Channel 3:",
print sensor.getWattsC3(),
print "W"
print "Energy, Channel 1:",
print sensor.getEnergyC1(),
print "kWh"
print "Energy, Channel 2:",
print sensor.getEnergyC2(),
print "kWh"
print "Energy, Channel 3:",
print sensor.getEnergyC3(),
print "kWh"
print "Battery Level:",
print sensor.getBatteryLevel(),
print "%"
print
time.sleep(3)

View File

@ -0,0 +1,80 @@
#!/usr/bin/python
# 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 time, sys, signal, atexit
import pyupm_ozw as sensorObj
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
defaultDev = "/dev/ttyACM0"
if (len(sys.argv) > 1):
defaultDev = sys.argv[1]
print "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.
sensor = sensorObj.AeotecDW2E(10)
# The first thing to do is create options, then lock them when done.
sensor.optionsCreate()
sensor.optionsLock()
# Next, initialize it.
print "Initializing, this may take awhile depending on your ZWave network"
sensor.init(defaultDev)
print "Initialization complete"
print "Querying data..."
while (True):
if (sensor.isDeviceAvailable()):
print "Alarm status:",
print sensor.isAlarmTripped()
print "Tamper Switch status:",
print sensor.isTamperTripped()
print "Battery Level:",
print sensor.getBatteryLevel(),
print "%"
print
else:
print "Device has not yet responded to probe."
print "Try waking it, or wait until it wakes itself if ",
print "configured to do so."
print
time.sleep(1)

View File

@ -0,0 +1,96 @@
#!/usr/bin/python
# 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 time, sys, signal, atexit
import pyupm_ozw as sensorObj
# This function lets you run code on exit
def exitHandler():
print "Turning switch off and sleeping for 5 seconds..."
sensor.off()
time.sleep(5)
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
defaultDev = "/dev/ttyACM0"
if (len(sys.argv) > 1):
defaultDev = sys.argv[1]
print "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.
sensor = sensorObj.AeotecSDG2(9)
# The first thing to do is create options, then lock them when done.
sensor.optionsCreate()
sensor.optionsLock()
# Next, initialize it.
print "Initializing, this may take awhile depending on your ZWave network"
sensor.init(defaultDev)
print "Initialization complete"
# turn light on
print "Turning switch on, then sleeping for 5 secs"
sensor.on();
time.sleep(5);
print "Querying data..."
dim = False;
while (True):
# put on a light show...
if (dim):
sensor.setLevel(25)
else:
sensor.on()
dim = not dim;
sensor.update()
print "Current Level:",
print sensor.getLevel()
print "Volts:",
print sensor.getVolts(),
print "volts"
print "Energy Consumption:",
print sensor.getEnergy(),
print "kWh"
print "Watts:",
print sensor.getWatts()
print "Current:",
print sensor.getCurrent(),
print "amps"
print
time.sleep(5)

View File

@ -0,0 +1,87 @@
#!/usr/bin/python
# 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 time, sys, signal, atexit
import pyupm_ozw as sensorObj
# This function lets you run code on exit
def exitHandler():
print "Turning switch off and sleeping for 5 seconds..."
sensor.off()
time.sleep(5)
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
defaultDev = "/dev/ttyACM0"
if (len(sys.argv) > 1):
defaultDev = sys.argv[1]
print "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.
sensor = sensorObj.AeotecSS6(11)
# The first thing to do is create options, then lock them when done.
sensor.optionsCreate()
sensor.optionsLock()
# Next, initialize it.
print "Initializing, this may take awhile depending on your ZWave network"
sensor.init(defaultDev)
print "Initialization complete"
# turn light on
print "Turning switch on, then sleeping for 5 secs"
sensor.on();
time.sleep(5);
print "Querying data..."
while (True):
sensor.update()
print "Switch status:",
print sensor.isOn()
print "Volts:",
print sensor.getVolts(),
print "volts"
print "Energy Consumption:",
print sensor.getEnergy(),
print "kWh"
print "Watts:",
print sensor.getWatts()
print "Current:",
print sensor.getCurrent(),
print "amps"
print
time.sleep(3)

View File

@ -1,6 +1,6 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
# Copyright (c) 2015-2016 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@ -25,7 +25,7 @@ import time, sys, signal, atexit
import pyupm_ozw as sensorObj
# Instantiate an OZW instance
sensor = sensorObj.OZW()
sensor = sensorObj.OZWDUMP()
# This function lets you run code on exit
def exitHandler():
@ -46,41 +46,39 @@ sensor.optionsLock()
# Next, initialize it.
print "Initializing, this may take awhile depending on your ZWave network"
if (not sensor.init(defaultDev)):
print "Init failed."
sys.exit(1)
sensor.init(defaultDev)
print "Initialization complete"
print "Dumping nodes..."
sensor.dumpNodes()
sensor.dumpNodes(True)
# The following is example output of dumpNodes:
#
# Dumping nodes...
# Node 1: Z-Stick Gen5
# Node 2: Smart Switch 6
# Index: 0, Type: bool, Label: Switch, Value: False
# Index: 0, Type: bool, Label: Switch, Value: False
# Index: 2, Type: float, Label: Energy, Value: 1.190 kWh
# Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh
# Index: 4, Type: int32, Label: Interval, Value: 1521 seconds
# Index: 5, Type: float, Label: Power, Value: 0.000 W
# Index: 6, Type: float, Label: Voltage, Value: 121.256 V
# Index: 7, Type: float, Label: Current, Value: 0.000 A
# Index: 8, Type: bool, Label: Exporting, Value: False
# Index: 45, Type: list, Label: Day, Value: Friday
# Index: 46, Type: byte, Label: Hour, Value: 5
# Index: 47, Type: byte, Label: Minute, Value: 53
# Index: 8, Type: bool, Label: Exporting, Value: False
# Index: 45, Type: list, Label: Day, Value: Friday
# Index: 46, Type: byte, Label: Hour, Value: 5
# Index: 47, Type: byte, Label: Minute, Value: 53
# Node 3: Multi Sensor
# Index: 0, Type: bool, Label: Sensor, Value: True
# Index: 0, Type: bool, Label: Sensor, Value: True
# Index: 1, Type: float, Label: Temperature, Value: 72.8 F
# Index: 2, Type: float, Label: Luminance, Value: 4 lux
# Index: 3, Type: float, Label: Relative Humidity, Value: 22 %
# Index: 17, Type: byte, Label: Battery Level, Value: 98 %
# Node 5: Minimote
# Node 6: Smart Energy Switch
# Index: 0, Type: bool, Label: Switch, Value: False
# Index: 0, Type: bool, Label: Switch, Value: False
# Index: 2, Type: float, Label: Power, Value: 0.000 W
# Index: 3, Type: float, Label: Energy, Value: 1.609 kWh
# Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh
@ -88,9 +86,9 @@ sensor.dumpNodes()
# Index: 6, Type: float, Label: Power, Value: 0.000 W
# Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W
# Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
# Index: 9, Type: bool, Label: Exporting, Value: False
# Index: 9, Type: bool, Label: Exporting, Value: False
# Node 7: Smart Energy Switch
# Index: 0, Type: bool, Label: Switch, Value: False
# Index: 0, Type: bool, Label: Switch, Value: False
# Index: 2, Type: float, Label: Power, Value: 0.000 W
# Index: 3, Type: float, Label: Energy, Value: 0.000 kWh
# Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh
@ -98,29 +96,4 @@ sensor.dumpNodes()
# Index: 6, Type: float, Label: Power, Value: 0.000 W
# Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W
# Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
# Index: 9, Type: bool, Label: Exporting, Value: False
#
# So, with the above in mind:
#
# 1. Query the temperature on node 3 and print it out (as a
# string), along with the units of measure:
#
# print "Temperature:", sensor.getValueAsString(3, 1),
# sensor->getValueUnits(3, 1)
#
# 2. query the same temperature as a float:
#
# temperature = sensor.getValueAsFloat(3, 1)
#
# 3. Turn on the light plugged into the switch on Node 7, wait 5
# seconds, then turn it back off again:
#
# print "Turning ON node 7"
# sensor.setValueAsBool(7, 0, true)
#
# print "Sleeping for 5 seconds";
# time.sleep(5)
#
# print "Turning OFF node 7"
# sensor.setValueAsBool(7, 0, false);
# Index: 9, Type: bool, Label: Exporting, Value: False

View File

@ -0,0 +1,82 @@
#!/usr/bin/python
# 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 time, sys, signal, atexit
import pyupm_ozw as sensorObj
# This function lets you run code on exit
def exitHandler():
print "Exiting..."
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
defaultDev = "/dev/ttyACM0"
if (len(sys.argv) > 1):
defaultDev = sys.argv[1]
print "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.
sensor = sensorObj.TZEMT400(13)
# The first thing to do is create options, then lock them when done.
sensor.optionsCreate()
sensor.optionsLock()
# Next, initialize it.
print "Initializing, this may take awhile depending on your ZWave network"
sensor.init(defaultDev)
print "Initialization complete"
print "Querying data..."
while (True):
sensor.update()
print "Temperature:", sensor.getTemperature(), "C /",
print sensor.getTemperature(True), "F"
print "Mode:",
print sensor.getMode()
print "Operating State:",
print sensor.getOperatingState()
print "Heating Point:", sensor.getHeatingPointTemperature(), "C /",
print sensor.getHeatingPointTemperature(True), "F"
print "Cooling Point:", sensor.getCoolingPointTemperature(), "C /",
print sensor.getCoolingPointTemperature(True), "F"
print "Fan Mode:",
print sensor.getFanMode()
print "Fan State:",
print sensor.getFanState()
print
time.sleep(5)

View File

@ -1,7 +1,7 @@
set (libname "ozw")
set (libdescription "upm module for the OpenZWave library interface")
set (module_src ${libname}.cxx zwNode.cxx)
set (module_hpp ${libname}.hpp)
set (module_src ${libname}.cxx zwNode.cxx ozwinterface.cxx ozwdump.cxx aeotecss6.cxx aeotecsdg2.cxx aeotecdw2e.cxx aeotecdsb09104.cxx tzemt400.cxx)
set (module_hpp ${libname}.hpp ozwinterface.hpp ozwdump.hpp aeotecss6.hpp aeotecsdg2.hpp aeotecdw2e.hpp aeotecdsb09104.hpp tzemt400.hpp)
pkg_check_modules(OPENZWAVE libopenzwave)
if (OPENZWAVE_FOUND)
@ -11,10 +11,16 @@ if (OPENZWAVE_FOUND)
target_link_libraries(${libname} ${OPENZWAVE_LIBRARIES})
if (BUILDSWIG)
if (BUILDSWIGNODE)
set_target_properties(${SWIG_MODULE_jsupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
swig_link_libraries (jsupm_${libname} ${OPENZWAVE_LIBRARIES})
endif()
if (BUILDSWIGPYTHON)
set_target_properties(${SWIG_MODULE_pyupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
swig_link_libraries (pyupm_${libname} ${OPENZWAVE_LIBRARIES})
endif()
if (BUILDSWIGJAVA)
set_target_properties(${SWIG_MODULE_javaupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
swig_link_libraries (javaupm_${libname} ${OPENZWAVE_LIBRARIES})
endif()
endif()
endif ()

View File

@ -0,0 +1,87 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <stdexcept>
#include "aeotecdsb09104.hpp"
using namespace upm;
using namespace std;
AeotecDSB09104::AeotecDSB09104(int nodeID) :
ozwInterface(nodeID)
{
}
AeotecDSB09104::~AeotecDSB09104()
{
}
float AeotecDSB09104::getWattsC1()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_PowerC1);
}
float AeotecDSB09104::getWattsC2()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_PowerC2);
}
float AeotecDSB09104::getWattsC3()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_PowerC3);
}
float AeotecDSB09104::getEnergyC1()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_EnergyC1);
}
float AeotecDSB09104::getEnergyC2()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_EnergyC2);
}
float AeotecDSB09104::getEnergyC3()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_EnergyC3);
}
int AeotecDSB09104::getBatteryLevel()
{
return (int)m_instance->getValueAsByte(m_nodeID, INDEX_BatteryLevel);
}
void AeotecDSB09104::update()
{
m_instance->refreshValue(m_nodeID, INDEX_PowerC1);
m_instance->refreshValue(m_nodeID, INDEX_PowerC2);
m_instance->refreshValue(m_nodeID, INDEX_PowerC3);
m_instance->refreshValue(m_nodeID, INDEX_EnergyC1);
m_instance->refreshValue(m_nodeID, INDEX_EnergyC2);
m_instance->refreshValue(m_nodeID, INDEX_EnergyC3);
m_instance->refreshValue(m_nodeID, INDEX_BatteryLevel);
}

141
src/ozw/aeotecdsb09104.hpp Normal file
View File

@ -0,0 +1,141 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozwinterface.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM API for he Aeotec Home Energy Meter Gen 1
* @con uart
*
* @brief UPM API for Aeotec Home Energy Meter Gen 1
*
* This module allows for monitoring certain elements of an Aeotec
* Home Energy Meter Gen 1.
*/
class AeotecDSB09104 : public ozwInterface {
public:
/**
* These values correspond to the index values of the given node
*
*/
typedef enum : int {
INDEX_PowerC1 = 0,
INDEX_PowerC2 = 1,
INDEX_PowerC3 = 2,
INDEX_EnergyC1 = 3,
INDEX_EnergyC2 = 4,
INDEX_EnergyC3 = 5,
INDEX_BatteryLevel = 18
} INDEX_VALUES_T;
/**
* AeotecDSB09104 constructor
*
* @param nodeID The ZWave node number of the device we are
* interested in. Use the ozwdump example to see what nodes you
* have available.
*/
AeotecDSB09104(int nodeID);
/**
* AeotecDSB09104 Destructor
*/
~AeotecDSB09104();
/**
* Get the current Watts reading from Channel 1.
*
* @return The Watts reading.
*/
float getWattsC1();
/**
* Get the current Watts reading from Channel 2.
*
* @return The Watts reading.
*/
float getWattsC2();
/**
* Get the current Watts reading from Channel 3.
*
* @return The Watts reading.
*/
float getWattsC3();
/**
* Get the current Energy reading from Channel 1. The value is in
* kWh.
*
* @return The Energy reading.
*/
float getEnergyC1();
/**
* Get the current Energy reading from Channel 2. The value is in
* kWh.
*
* @return The Energy reading.
*/
float getEnergyC2();
/**
* Get the current Energy reading from Channel 3. The value is in
* kWh.
*
* @return The Energy reading.
*/
float getEnergyC3();
/**
* Query the device and update internal state. Strictly speaking,
* this is not really neccessary -- a device may send this data on
* it's own at periodic intervals if configured to do so. This
* method causes OZW to specifically query the device for it's
* current Energy, Watts, and Battery Level status. The device
* may take some time to respond.
*/
void update();
/**
* Return the current bettery level of the meter as a percentage.
* The number returned will be between 0-100.
*
* @return The Battery power level.
*/
int getBatteryLevel();
protected:
private:
};
}

77
src/ozw/aeotecdw2e.cxx Normal file
View File

@ -0,0 +1,77 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <stdexcept>
#include "aeotecdw2e.hpp"
using namespace upm;
using namespace std;
AeotecDW2E::AeotecDW2E(int nodeID) :
ozwInterface(nodeID)
{
}
AeotecDW2E::~AeotecDW2E()
{
}
bool AeotecDW2E::isDeviceAvailable()
{
return m_instance->isNodeInfoReceived(m_nodeID);
}
bool AeotecDW2E::isAlarmTripped()
{
if (isDeviceAvailable())
return m_instance->getValueAsBool(m_nodeID, INDEX_Alarm);
else
return false;
}
bool AeotecDW2E::isTamperTripped()
{
if (isDeviceAvailable())
{
if (m_instance->getValueAsByte(m_nodeID, INDEX_AlarmLevel) > 0)
return true;
else
return false;
}
else
return false;
}
int AeotecDW2E::getBatteryLevel()
{
if (isDeviceAvailable())
return (int)m_instance->getValueAsByte(m_nodeID, INDEX_BatteryLevel);
else
return 0;
}

126
src/ozw/aeotecdw2e.hpp Normal file
View File

@ -0,0 +1,126 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozwinterface.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM API for he Aeotec Door/Window Sensor 2nd Edition
* @altname DSB29
* @con uart
*
* @brief UPM API for Aeotec Door/Window Sensor 2nd Edition
*
* This module allows for monitoring certain elements of an Aeotec
* Door/Window Sensor 2nd Edition Z-Wave device.
*
* NOTE: This is a battery powered device that spends most of it's
* time sleeping (sort of like a cat). This means that on initial
* startup, there is not enough information known about the device
* to reliably query anything. Use isDeviceAvailable() to test
* whether the device has responded to OZW's probe request before
* requesting information for it.
*
* The device information should become known once the device has
* awakened, either via it's configuration, or manually via the
* include button on the device. By default the device will never
* wake on it's own, so you should use the openzwave control panel
* or similar software to configure a periodic wakeup time.
*/
class AeotecDW2E : public ozwInterface {
public:
/**
* These values correspond to the index values of the given node
*
*/
typedef enum : int {
INDEX_Alarm = 0, // alarm
INDEX_AlarmLevel = 2, // tamper switch
INDEX_BatteryLevel = 3
} INDEX_VALUES_T;
/**
* AeotecDW2E constructor
*
* @param nodeID The ZWave node number of the device we are
* interested in. Use the ozwdump example to see what nodes you
* have available.
*/
AeotecDW2E(int nodeID);
/**
* AeotecDW2E Destructor
*/
~AeotecDW2E();
/**
* Returns true if the node (device) information has been
* received yet, false otherwise. A sleeping node (like this
* device) will not be available for monitoring until all node
* info has been received. This will occur once the device has
* been awakened and has responded to OZW's probe request.
*
* @return true if the node is available, false otherwise.
*/
bool isDeviceAvailable();
/**
* Return the alarm value. If the device is not available yet
* (see isDeviceAvailable()), false will always be returned.
*
* @return true if in the tripped state, false otherwise.
*/
bool isAlarmTripped();
/**
* Return the alarm's tamper switch valu. If the device is not
* available yet (see isDeviceAvailable()), false will always be
* returned.
*
* @return true if in the tripped state, false otherwise.
*/
bool isTamperTripped();
/**
* Return the current bettery level of the sensor as a percentage.
* The number returned will be between 0-100. If the device is
* not available yet (see isDeviceAvailable()), 0 will always be
* returned.
*
* @return The Battery power level.
*/
int getBatteryLevel();
protected:
private:
};
}

95
src/ozw/aeotecsdg2.cxx Normal file
View File

@ -0,0 +1,95 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <stdexcept>
#include "aeotecsdg2.hpp"
using namespace upm;
using namespace std;
AeotecSDG2::AeotecSDG2(int nodeID) :
ozwInterface(nodeID)
{
}
AeotecSDG2::~AeotecSDG2()
{
}
void AeotecSDG2::setLevel(int level)
{
// level must be between 0-99, so we clamp it
if (level < 0)
level = 0;
if (level > 99)
level = 99;
m_instance->setValueAsByte(m_nodeID, INDEX_Level, level);
}
int AeotecSDG2::getLevel()
{
return m_instance->getValueAsByte(m_nodeID, INDEX_Level);
}
bool AeotecSDG2::isOn()
{
if (m_instance->getValueAsByte(m_nodeID, INDEX_Level) > 0)
return true;
else
return false;
}
float AeotecSDG2::getEnergy()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Energy_kWh);
}
float AeotecSDG2::getWatts()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Power_Watts);
}
float AeotecSDG2::getVolts()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Volts);
}
float AeotecSDG2::getCurrent()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Current);
}
void AeotecSDG2::update()
{
m_instance->refreshValue(m_nodeID, INDEX_Level);
m_instance->refreshValue(m_nodeID, INDEX_Energy_kWh);
m_instance->refreshValue(m_nodeID, INDEX_Power_Watts);
m_instance->refreshValue(m_nodeID, INDEX_Volts);
m_instance->refreshValue(m_nodeID, INDEX_Current);
}

158
src/ozw/aeotecsdg2.hpp Normal file
View File

@ -0,0 +1,158 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozwinterface.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM API for the Aeotec Smart Dimmer Gen 2
* @con uart
*
* @brief UPM API for Aeotec Smart Dimmer Gen 2
*
* This module allows for controlling and monitoring certain
* elements of an Aeotec Smart Dimmer Gen 2.
*/
class AeotecSDG2 : public ozwInterface {
public:
/**
* These values correspond to the index values of the given node
*
*/
typedef enum : int {
INDEX_Level = 0,
INDEX_Energy_kWh = 3,
INDEX_Power_Watts = 6,
INDEX_Volts = 9,
INDEX_Current = 12
} INDEX_VALUES_T;
/**
* AeotecSDG2 constructor
*
* @param nodeID The ZWave node number of the device we are
* interested in. Use the ozwdump example to see what nodes you
* have available.
*/
AeotecSDG2(int nodeID);
/**
* AeotecSDG2 Destructor
*/
~AeotecSDG2();
/**
* Set the output level of the dimmer switch. This is a value
* between 0 (fully off) and 99 (fully on).
*
* @param level The desired output level of the dimmer switch.
* Valid values are between 0-99.
*/
void setLevel(int level);
/**
* Return the current output level of the dimmer switch. This
* will be a number between 0 (fully off) and 99 (fully on).
*
* @return the current dimmer output level.
*/
int getLevel();
/**
* Turn the switch fully on by setting the highest level (99).
* This is equivalent to calling setLevel(99).
*/
void on()
{
setLevel(99);
}
/**
* Turn the switch off by setting the lowest level (0). This is
* equivalent to calling setLevel(0).
*/
void off()
{
setLevel(0);
}
/**
* Check to see if the switch is on or off. Any dimmer level
* greater that 0 is considered 'on'.
*
* @return true if the dimmer switch is on, false otherwise.
*/
bool isOn();
/**
* Query the device and update internal state. Strictly speaking,
* this is not really neccessary -- a device may send this data on
* it's own at periodic intervals. This method causes OZW to
* specifically query the device for it's current Energy, Watts,
* Volts, Current, and dimmer Level status. The device may take
* some time to respond.
*/
void update();
/**
* Return the device's accumulated energy usage in kilo-watt-hours
* (kWh).
*
* @return The energy usage in kWh.
*/
float getEnergy();
/**
* Return the device's current power consumption in Watts.
*
* @return The current power consumption in Watts.
*/
float getWatts();
/**
* Return the device's current voltage measurement in Volts.
*
* @return The volts measurement.
*/
float getVolts();
/**
* Return the device's current consumption in Amps.
*
* @return The current consumption measurement in Amps.
*/
float getCurrent();
protected:
private:
};
}

86
src/ozw/aeotecss6.cxx Normal file
View File

@ -0,0 +1,86 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <stdexcept>
#include "aeotecss6.hpp"
using namespace upm;
using namespace std;
AeotecSS6::AeotecSS6(int nodeID) :
ozwInterface(nodeID)
{
}
AeotecSS6::~AeotecSS6()
{
}
void AeotecSS6::on()
{
m_instance->setValueAsBool(m_nodeID, INDEX_SwitchCtrl, true);
}
void AeotecSS6::off()
{
m_instance->setValueAsBool(m_nodeID, INDEX_SwitchCtrl, false);
}
bool AeotecSS6::isOn()
{
return m_instance->getValueAsBool(m_nodeID, INDEX_SwitchCtrl);
}
float AeotecSS6::getEnergy()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Energy_kWh);
}
float AeotecSS6::getWatts()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Power_Watts);
}
float AeotecSS6::getVolts()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Volts);
}
float AeotecSS6::getCurrent()
{
return m_instance->getValueAsFloat(m_nodeID, INDEX_Current);
}
void AeotecSS6::update()
{
m_instance->refreshValue(m_nodeID, INDEX_SwitchCtrl);
m_instance->refreshValue(m_nodeID, INDEX_Energy_kWh);
m_instance->refreshValue(m_nodeID, INDEX_Power_Watts);
m_instance->refreshValue(m_nodeID, INDEX_Volts);
m_instance->refreshValue(m_nodeID, INDEX_Current);
}

132
src/ozw/aeotecss6.hpp Normal file
View File

@ -0,0 +1,132 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozwinterface.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM API for he Aeotec Smart Switch 6
* @con uart
*
* @brief UPM API for Aeotec Smart Switch 6
*
* This module allows for controlling and monitoring certain
* elements of an Aeotec Smart Switch 6.
*/
class AeotecSS6 : public ozwInterface {
public:
/**
* These values correspond to the index values of the given node
*
*/
typedef enum : int {
INDEX_SwitchCtrl = 0,
INDEX_Energy_kWh = 4,
INDEX_Power_Watts = 7,
INDEX_Volts = 8,
INDEX_Current = 9
} INDEX_VALUES_T;
/**
* AeotecSS6 constructor
*
* @param nodeID The ZWave node number of the device we are
* interested in. Use the ozwdump example to see what nodes you
* have available.
*/
AeotecSS6(int nodeID);
/**
* AeotecSS6 Destructor
*/
~AeotecSS6();
/**
* Turn the switch on.
*/
void on();
/**
* Turn the switch off.
*/
void off();
/**
* Check to see if the switch is on or off.
*
* @return true if the switch is on, false otherwise.
*/
bool isOn();
/**
* Query the device and update internal state. Strictly speaking,
* this is not really neccessary -- a device may send this data on
* it's own at periodic intervals. This method causes OZW to
* specifically query the device for it's current Energy, Watts,
* Volts, Current, and Switch status. The device may take some
* time to respond.
*/
void update();
/**
* Return the device's accumulated energy usage in kilo-watt-hours
* (kWh).
*
* @return The energy usage in kWh.
*/
float getEnergy();
/**
* Return the device's current power consumption in Watts.
*
* @return The current power consumption in Watts.
*/
float getWatts();
/**
* Return the device's current voltage measurement in Volts.
*
* @return The volts measurement.
*/
float getVolts();
/**
* Return the device's current consumption in Amps.
*
* @return The current consumption measurement in Amps.
*/
float getCurrent();
protected:
private:
};
}

View File

@ -5,11 +5,45 @@
%include "arrays_java.i";
%include "../java_buffer.i"
%include "ozw.hpp"
%{
#include "ozw.hpp"
%}
%include "ozw.hpp"
%include "ozwinterface.hpp"
%{
#include "ozwinterface.hpp"
%}
%include "ozwdump.hpp"
%{
#include "ozwdump.hpp"
%}
%include "aeotecss6.hpp"
%{
#include "aeotecss6.hpp"
%}
%include "aeotecsdg2.hpp"
%{
#include "aeotecsdg2.hpp"
%}
%include "aeotecdw2e.hpp"
%{
#include "aeotecdw2e.hpp"
%}
%include "aeotecdsb09104.hpp"
%{
#include "aeotecdsb09104.hpp"
%}
%include "tzemt400.hpp"
%{
#include "tzemt400.hpp"
%}
%pragma(java) jniclasscode=%{
static {

View File

@ -10,3 +10,37 @@
#include "ozw.hpp"
%}
%include "ozwinterface.hpp"
%{
#include "ozwinterface.hpp"
%}
%include "ozwdump.hpp"
%{
#include "ozwdump.hpp"
%}
%include "aeotecss6.hpp"
%{
#include "aeotecss6.hpp"
%}
%include "aeotecsdg2.hpp"
%{
#include "aeotecsdg2.hpp"
%}
%include "aeotecdw2e.hpp"
%{
#include "aeotecdw2e.hpp"
%}
%include "aeotecdsb09104.hpp"
%{
#include "aeotecdsb09104.hpp"
%}
%include "tzemt400.hpp"
%{
#include "tzemt400.hpp"
%}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -38,9 +38,12 @@ using namespace upm;
using namespace std;
using namespace OpenZWave;
// our singleton instance
OZW* OZW::m_instance = 0;
OZW::OZW()
{
m_initialized = false;
m_mgrCreated = false;
m_driverFailed = false;
m_homeId = 0;
@ -98,8 +101,8 @@ OZW::~OZW()
// delete any nodes. This should be safe after deleting the node
// mutex since the handler is no longer registered.
for (zwNodeMap_t::iterator it = m_zwNodeMap.begin();
it != m_zwNodeMap.end(); ++it)
for (auto it = m_zwNodeMap.cbegin();
it != m_zwNodeMap.cend(); ++it)
{
// delete the zwNode pointer
delete (*it).second;
@ -108,6 +111,14 @@ OZW::~OZW()
m_zwNodeMap.clear();
}
OZW* OZW::instance()
{
if (!m_instance)
m_instance = new OZW;
return m_instance;
}
void OZW::optionsCreate(std::string configPath,
std::string userConfigDir,
std::string cmdLine)
@ -117,17 +128,20 @@ void OZW::optionsCreate(std::string configPath,
void OZW::optionAddInt(std::string name, int val)
{
Options::Get()->AddOptionInt(name, val);
if (!Options::Get()->AreLocked())
Options::Get()->AddOptionInt(name, val);
}
void OZW::optionAddBool(std::string name, bool val)
{
Options::Get()->AddOptionBool(name, val);
if (!Options::Get()->AreLocked())
Options::Get()->AddOptionBool(name, val);
}
void OZW::optionAddString(std::string name, std::string val, bool append)
{
Options::Get()->AddOptionString(name, val, append);
if (!Options::Get()->AreLocked())
Options::Get()->AddOptionString(name, val, append);
}
void OZW::optionsLock()
@ -139,6 +153,16 @@ void OZW::optionsLock()
bool OZW::init(string devicePath, bool isHID)
{
if (m_initialized)
{
// we are already initialized...
if (m_debugging)
cerr << __FUNCTION__ << ": Already initialized, continuing..."
<< endl;
return true;
}
// make sure options are locked
optionsLock();
@ -174,6 +198,19 @@ bool OZW::init(string devicePath, bool isHID)
return false;
}
// if we succeeded, update (sort) all of the VIDs in each zwNode, and
// enable autoupdating from here on out.
lockNodes();
for (auto it = m_zwNodeMap.cbegin();
it != m_zwNodeMap.cend(); ++it)
{
(*it).second->updateVIDMap();
(*it).second->setAutoUpdate(true);
}
unlockNodes();
m_initialized = true;
return true;
}
@ -249,7 +286,7 @@ void OZW::notificationHandler(Notification const* notification, void *ctx)
// all nodes deleted. According to OZW docs, this happens
// when a driver is reset, instead of sending potentially
// hundreds of ValueRemoved/NodeRemoved events.
for (zwNodeMap_t::iterator it = This->m_zwNodeMap.begin();
for (auto it = This->m_zwNodeMap.begin();
it != This->m_zwNodeMap.end(); ++it)
{
// delete the zwNode pointer
@ -314,8 +351,8 @@ void OZW::dumpNodes(bool all)
lockNodes();
for (zwNodeMap_t::iterator it = m_zwNodeMap.begin();
it != m_zwNodeMap.end(); ++it)
for (auto it = m_zwNodeMap.cbegin();
it != m_zwNodeMap.cend(); ++it)
{
uint8_t nodeId = (*it).first;
@ -323,6 +360,43 @@ void OZW::dumpNodes(bool all)
<< ": "
<< Manager::Get()->GetNodeProductName(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Type: "
<< Manager::Get()->GetNodeType(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Product Type: "
<< Manager::Get()->GetNodeProductType(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Manufacturer ID: "
<< Manager::Get()->GetNodeManufacturerId(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Product ID: "
<< Manager::Get()->GetNodeProductId(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Generic Type: "
<< (int)Manager::Get()->GetNodeGeneric(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Device Type: "
<< (int)Manager::Get()->GetNodeDeviceType(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Node Basic: "
<< (int)Manager::Get()->GetNodeBasic(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Node Query Stage: "
<< Manager::Get()->GetNodeQueryStage(m_homeId, nodeId)
<< endl;
cerr << "\t"
<< "Is Node Info Rcvd: "
<< Manager::Get()->IsNodeInfoReceived(m_homeId, nodeId)
<< endl;
(*it).second->dumpNode(all);
}
@ -898,6 +972,18 @@ bool OZW::isNodeAwake(int nodeId)
return rv;
}
bool OZW::isNodeInfoReceived(int nodeId)
{
nodeId &= 0xff;
lockNodes();
bool rv = Manager::Get()->IsNodeInfoReceived(m_homeId, nodeId);
unlockNodes();
return rv;
}
void OZW::setDebug(bool enable)
{
m_debugging = enable;

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -37,7 +37,7 @@
namespace upm {
/**
* @brief OZW OpenZWave library
* @brief UPM OpenZWave library
* @defgroup ozw libupm-ozw
* @ingroup uart wifi
*/
@ -53,47 +53,40 @@ namespace upm {
*
* @brief UPM API for the OpenZWave library
*
* This module implements a wrapper around the OpenZWave library.
* OpenZWave must be compiled and installed on your machine in order
* to use this library.
* This module implements a singleton wrapper around the OpenZWave
* library. OpenZWave must be compiled and installed on your
* machine in order to use this library.
*
* This module was developed with OpenZWave 1.3, and an Aeon Z-Stick
* Gen5 configured as a Primary Controller. It provides the ability
* to query and set various values that can be used to control ZWave
* devices. It does not concern itself with configuration of
* devices. It is assumed that you have already setup your ZWave
* network using a tool like the OpenZWave control panel, and have
* already configured your devices as appropriate.
* This module was developed with OpenZWave 1.3/1.4, and an Aeon
* Z-Stick Gen5 configured as a Primary Controller. It provides the
* ability to query and set various values that can be used to
* control ZWave devices. It does not concern itself with
* configuration of devices. It is assumed that you have already
* setup your ZWave network using a tool like the OpenZWave control
* panel, and have already configured your devices as appropriate.
*
* To avoid exposing some of the internals of OpenZWave, devices
* (nodes) and their values, are accessed via a nodeId and a value
* index number. The example will run dumpNodes() which will list
* the currently connected devices and the values that are available
* to them, along with an index number for that value. It is
* through these values (nodeId and index) that you can query and
* set device values.
* index number. The ozwdump example will run dumpNodes() which
* will list the currently connected devices and the values that are
* available to them, along with an index number for that value. It
* is through these values (nodeId and index) that you can query and
* set device values at a low level.
*
* In addition to querying values from a device (such as state
* (on/off), or temperature, etc), methods are provided to allow you
* to control these devices to the extent they allow, for example,
* using a ZWave connected switch to turn on a lamp.
*
* Since it's likely no two ZWave networks are going to be the same,
* the example will just initialize OpenZWave and run the
* dumpNodes() method to allow you to see what devices are present,
* the values they support and their current content, along with the
* per-node index number you can use to address them. There will be
* commented out code examples showing you how to query or set a
* specific value for a device.
*
* See the ozw example code comments for an example of the ouput of
* running dumpNodes().
* Access to this class by OZW drivers is handled by the
* ozwInterface class. It is that class that drivers use for access
* to ozw, and therefore the Z-Wave network.
*
* In most of the methods below, You will need the NodeId (Node
* number), and the Index number to access or otherwise affect these
* values.
*
* @snippet openzwave.cxx Interesting
* This class is not intended to be used directly by end users.
* When writing an OZW driver, the ozwInterface class should be used
* (inherited) by your driver, and your driver should wrap and
* expose only those methods needed by the user. Take a look at
* some of the drivers (like aeotecss6) to see how this works.
*/
// forward declaration of private zwNode data
@ -105,14 +98,13 @@ namespace upm {
typedef std::map<uint8_t, zwNode *> zwNodeMap_t;
/**
* OZW constructor
* Get our singleton instance, initializing it if neccessary. All
* requests to this class should be done through this instance
* accessor.
*
* @return static pointer to our class instance
*/
OZW();
/**
* OZW Destructor
*/
~OZW();
static OZW* instance();
/**
* Start configuration with basic options. This must be called
@ -193,11 +185,11 @@ namespace upm {
bool init(std::string devicePath, bool isHID=false);
/**
* Dump information about all configured nodes and their values to
* stdout. This is useful to determine what nodes are available,
* and the index (used for querying and seting values for them).
* In addition, it includes information about each value (type,
* current value, etc).
* Dump information about all configured nodes (devices) and their
* available values to stdout. This is useful to determine what
* nodes are available, and the index (used for querying and
* seting values for them). In addition, it includes information
* about each value (type, current value, etc).
*
* @param all set to true to dump information about all values
* available for each node. If false, only information about
@ -519,7 +511,36 @@ namespace upm {
*/
bool isNodeAwake(int nodeId);
/**
* Determine whether a Node's information has been received. For
* sleeping nodes, this may take a while (until the node wakes).
*
* @param nodeId The node ID
* @return true if the node information is known, false otherwise
*/
bool isNodeInfoReceived(int nodeId);
/**
* Determine if the Z-Wave network has been initialized yet.
*
* @return true if the network is initialized, false otherwise
*/
bool isInitialized()
{
return m_initialized;
}
protected:
/**
* OZW constructor
*/
OZW();
/**
* OZW Destructor
*/
~OZW();
/**
* Based on a nodeId and a value index, lookup the corresponding
* OpenZWave ValueID.
@ -531,23 +552,41 @@ namespace upm {
*/
bool getValueID(int nodeId, int index, OpenZWave::ValueID *vid);
/**
* Return the Home ID of the network.
*
* @return The Home ID.
*/
uint32_t getHomeID()
{
return m_homeId;
}
/**
* Lock the m_zwNodeMap mutex to protect against changes made to
* the the the map by the OpenZWave notification handler. Always
* lock this mutex when acessing anything in the zwNodeMap map.
*/
void lockNodes() { pthread_mutex_lock(&m_nodeLock); };
/**
* Unlock the m_zwNodeMap mutex after lockNodes() has been called.
*/
void unlockNodes() { pthread_mutex_unlock(&m_nodeLock); };
private:
// prevent copying and assignment
OZW(OZW const &) {};
OZW& operator=(OZW const&) {};
// our class instance
static OZW* m_instance;
uint32_t m_homeId;
bool m_mgrCreated;
bool m_driverFailed;
bool m_debugging;
bool m_initialized;
bool m_driverIsHID;
std::string m_devicePath;

42
src/ozw/ozwdump.cxx Normal file
View File

@ -0,0 +1,42 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <stdexcept>
#include "ozwdump.hpp"
using namespace upm;
using namespace std;
OZWDUMP::OZWDUMP() :
ozwInterface(0) // nodeID is not used
{
}
OZWDUMP::~OZWDUMP()
{
}

63
src/ozw/ozwdump.hpp Normal file
View File

@ -0,0 +1,63 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozwinterface.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM Interface API for ozwdump
* @con uart
*
* @brief UPM Utility driver for OZW.
*
* This "driver" does not actually control any device. It is meant
* as an example. It's only purpose is to support it's example
* (ozwdump), which initializes OZW on a Z-Wave network, and then
* prints out all Nodes (devices) and their associated valueids.
*
* @snippet ozwdump.cxx
*/
class OZWDUMP : public ozwInterface {
public:
/**
* ozwdump constructor
*/
OZWDUMP();
/**
* OZWDUMP Destructor
*/
~OZWDUMP();
protected:
private:
};
}

75
src/ozw/ozwinterface.cxx Normal file
View File

@ -0,0 +1,75 @@
/*
* 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.
*/
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <iostream>
#include <stdexcept>
#include <string>
#include "ozwinterface.hpp"
using namespace upm;
using namespace std;
ozwInterface::ozwInterface(int nodeID) :
m_instance(0)
{
// Save our device's ID
m_nodeID = nodeID;
// create the OZW instance here if it does not already exist, and
// store the pointer in our class to save on some typing.
m_instance = OZW::instance();
// now see if it has been initialized yet for init()
m_initialized = m_instance->isInitialized();
setDebug(false);
}
ozwInterface::~ozwInterface()
{
}
void ozwInterface::init(string devicePath, bool isHID)
{
// if we are already intitialized, don't try to do it again...
if (!m_initialized)
m_instance->init(devicePath, isHID);
// either it threw, or we are initialized now...
m_initialized = true;
}
void ozwInterface::setDebug(bool enable)
{
m_debugging = enable;
// we also enable/disable debugging in OZW
m_instance->setDebug(enable);
}

216
src/ozw/ozwinterface.hpp Normal file
View File

@ -0,0 +1,216 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozw.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM Interface API for OpenZWave (OZW)
* @con uart
*
* @brief UPM Interface API for OpenZWave (OZW)
*
* This class implements some common access functions that are
* useful to any driver making use of the ozw driver.
*
* It is intended to be inherited by device-specific ozw drivers,
* and provides some basic public methods all ozw drivers need to
* have, as well as protected access to other OZW facilities that
* are needed by a driver, but should not be exposed to the
* end-user.
*/
class ozwInterface {
public:
/**
* ozwInterface constructor
*
* @param nodeID The ZWave node number of the device we are
* interested in.
*/
ozwInterface(int nodeID);
/**
* ozwInterface Destructor
*/
virtual ~ozwInterface();
/**
* Enable some debugging output in this module as well as the
* OZW module. Debugging is disabled by default.
*
* @param enable true to enable, false to disable.
*/
virtual void setDebug(bool enable);
/**
* Start configuration with basic options. This must be called
* prior to init(), after the OZW() contructor is called.
*
* @param configPath Set the location of the OpenZWave config
* directory, default is /etc/openzwave
* @param userConfigDir Set the path to the user configuration
* directory. This is the location of the zwcfg*.xml and
* option.xml files for the user (probably created by the
* OpenZWave Control Panel example application). The default is
* the current directory ("").
* @param cmdLine Specify command line formatted options to
* OpenZWave. The default is "".
*/
virtual void optionsCreate(std::string configPath="/etc/openzwave",
std::string userConfigDir="",
std::string cmdLine="")
{
m_instance->optionsCreate(configPath, userConfigDir, cmdLine);
}
/**
* Add an integer Option. See the OpenZWave documentation for
* valid values.
*
* @param name The name of the configuration option
* @param val The value to set it to
*/
virtual void optionAddInt(std::string name, int val)
{
m_instance->optionAddInt(name, val);
}
/**
* Add a boolean Option. See the OpenZWave documentation for
* valid values.
*
* @param name The name of the configuration option
* @param val The value to set it to
*/
virtual void optionAddBool(std::string name, bool val)
{
m_instance->optionAddBool(name, val);
}
/**
* Add a string Option. See the OpenZWave documentation for valid
* values.
*
* @param name The name of the configuration option
* @param val The value to set it to
* @append true to append to the option, false to override
*/
virtual void optionAddString(std::string name, std::string val,
bool append)
{
m_instance->optionAddString(name, val, append);
}
/**
* Lock the Options. This must be called after all options have
* been set, and before init() is called. If init() is called
* without locking the Options, init() will lock them itself.
* After the options have been locked, no further options can be
* specified.
*/
virtual void optionsLock()
{
m_instance->optionsLock();
}
/**
* This function initializes the underlying OZW Master singleton
* and the openzwave library in the event it has not already been
* initialized. If the OZW Master singleton has already been
* initialized, then this call will be ignored.
*
* @param devicePath The path to the device, typically something
* like /dev/ttyACM0.
* @param isHID true if this is an HID device, false if it's a
* serial device. The default is false.
*/
virtual void init(std::string devicePath, bool isHID=false);
/**
* Dump information about all configured nodes and their valueids
* to stderr. This is useful to determine what nodes are
* available, and the index (used for querying and seting values
* for them). In addition, it includes information about each
* value (type, current value, etc).
*
* @param all set to true to dump information about all values
* available for each node. If false, only information about
* 'user' values (ignoring 'system' and 'configuration') are
* output. The default is false ('user' values only).
*/
virtual void dumpNodes(bool all=false)
{
m_instance->dumpNodes(all);
}
/**
* Return a string (which may be empty) indicating the Units of
* measure for a given value. For example, querying a temperature
* value may return "F" to indicate Fahrenheit.
*
* @param index The value index (see dumpNodes()) of the value to query.
* @return A string containing the Unit of measure for the value
*/
virtual std::string getValueUnits(int index)
{
return m_instance->getValueUnits(m_nodeID, index);
}
/**
* Return a string (which may be empty) indicating the Label set
* for a given value. For example, querying a temperature value
* may return "Temperature" to indicate what it is.
*
* @param index The value index (see dumpNodes()) of the value to query.
* @return A string containing the Label for the value
*/
virtual std::string getValueLabel(int index)
{
return m_instance->getValueLabel(m_nodeID, index);
}
protected:
// also enable debugging in ozw
bool m_debugging;
// our target Device Node ID
uint32_t m_nodeID;
// a copy of the OZW singleton instance pointer. This is used by
// drivers to access underlying OZW facilities.
OZW* m_instance;
// are we initialized?
bool m_initialized;
private:
};
}

View File

@ -15,3 +15,37 @@
#include "ozw.hpp"
%}
%include "ozwinterface.hpp"
%{
#include "ozwinterface.hpp"
%}
%include "ozwdump.hpp"
%{
#include "ozwdump.hpp"
%}
%include "aeotecss6.hpp"
%{
#include "aeotecss6.hpp"
%}
%include "aeotecsdg2.hpp"
%{
#include "aeotecsdg2.hpp"
%}
%include "aeotecdw2e.hpp"
%{
#include "aeotecdw2e.hpp"
%}
%include "aeotecdsb09104.hpp"
%{
#include "aeotecdsb09104.hpp"
%}
%include "tzemt400.hpp"
%{
#include "tzemt400.hpp"
%}

148
src/ozw/tzemt400.cxx Normal file
View File

@ -0,0 +1,148 @@
/*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <stdexcept>
#include "tzemt400.hpp"
using namespace upm;
using namespace std;
// conversion from fahrenheit to celcius and back
static float f2c(float f)
{
return ((f - 32.0) / (9.0 / 5.0));
}
static float c2f(float c)
{
return (c * (9.0 / 5.0) + 32.0);
}
TZEMT400::TZEMT400(int nodeID) :
ozwInterface(nodeID)
{
}
TZEMT400::~TZEMT400()
{
}
float TZEMT400::getTemperature(bool fahrenheit)
{
float temp = m_instance->getValueAsFloat(m_nodeID, INDEX_Temperature);
uint8_t isFahrenheit = m_instance->getValueAsByte(m_nodeID, INDEX_FC_Units);
if (fahrenheit)
{
if (isFahrenheit)
return temp;
else
return c2f(temp);
}
else
{
if (isFahrenheit)
return f2c(temp);
else
return temp;
}
}
string TZEMT400::getMode()
{
return m_instance->getValueAsString(m_nodeID, INDEX_Mode);
}
string TZEMT400::getOperatingState()
{
return m_instance->getValueAsString(m_nodeID, INDEX_Operating_State);
}
float TZEMT400::getHeatingPointTemperature(bool fahrenheit)
{
float temp = m_instance->getValueAsFloat(m_nodeID, INDEX_Heating_Point);
uint8_t isFahrenheit = m_instance->getValueAsByte(m_nodeID, INDEX_FC_Units);
if (fahrenheit)
{
if (isFahrenheit)
return temp;
else
return c2f(temp);
}
else
{
if (isFahrenheit)
return f2c(temp);
else
return temp;
}
}
float TZEMT400::getCoolingPointTemperature(bool fahrenheit)
{
float temp = m_instance->getValueAsFloat(m_nodeID, INDEX_Cooling_Point);
uint8_t isFahrenheit = m_instance->getValueAsByte(m_nodeID, INDEX_FC_Units);
if (fahrenheit)
{
if (isFahrenheit)
return temp;
else
return c2f(temp);
}
else
{
if (isFahrenheit)
return f2c(temp);
else
return temp;
}
}
string TZEMT400::getFanMode()
{
return m_instance->getValueAsString(m_nodeID, INDEX_Fan_Mode);
}
string TZEMT400::getFanState()
{
return m_instance->getValueAsString(m_nodeID, INDEX_Fan_State);
}
void TZEMT400::update()
{
m_instance->refreshValue(m_nodeID, INDEX_Temperature);
m_instance->refreshValue(m_nodeID, INDEX_Mode);
m_instance->refreshValue(m_nodeID, INDEX_Operating_State);
m_instance->refreshValue(m_nodeID, INDEX_Heating_Point);
m_instance->refreshValue(m_nodeID, INDEX_Cooling_Point);
m_instance->refreshValue(m_nodeID, INDEX_Fan_Mode);
m_instance->refreshValue(m_nodeID, INDEX_Fan_State);
m_instance->refreshValue(m_nodeID, INDEX_FC_Units);
}

155
src/ozw/tzemt400.hpp Normal file
View File

@ -0,0 +1,155 @@
/*
* 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.
*/
#pragma once
#include <string>
#include "ozwinterface.hpp"
namespace upm {
/**
* @library ozw
* @comname UPM API for the Trane TZEMT400 Z-Wave Thermostat.
* @con uart
*
* @brief UPM API for Trane TZEMT400 Z-Wave Thermostat
*
* This module allows for monitoring certain elements of a Trane
* TZEMT400 Z-Wave Thermostat. It was tested with a Trane
* TZEMT400BB32MAA variant.
*/
class TZEMT400 : public ozwInterface {
public:
/**
* These values correspond to the index values of the given node
*
*/
typedef enum : int {
INDEX_Temperature = 0,
INDEX_Mode = 1,
INDEX_Operating_State = 2,
INDEX_Heating_Point = 3,
INDEX_Cooling_Point = 4,
INDEX_Fan_Mode = 5,
INDEX_Fan_State = 6,
INDEX_FC_Units = 14 // F or C units
} INDEX_VALUES_T;
/**
* TZEMT400 constructor
*
* @param nodeID The ZWave node number of the device we are
* interested in. Use the ozwdump example to see what nodes you
* have available.
*/
TZEMT400(int nodeID);
/**
* TZEMT400 Destructor
*/
~TZEMT400();
/**
* Return the current measured temperature in Celcius or
* Fahrenheit.
*
* @param fahrenheit true to return data in Fahrenheit, false for
* Celicus. Celcius is the default.
* @return The temperature in degrees Celcius or Fahrenheit.
*/
float getTemperature(bool fahrenheit=false);
/**
* Return a string representing the current Mode. This is usually
* something like "Cool", "Heat", "Auto", etc.
*
* @return a string representing the current mode.
*/
std::string getMode();
/**
* Return a string representing the current Operating State. This
* is usually something like "Idle", or "Cooling".
*
* @return a string representing the current operating state.
*/
std::string getOperatingState();
/**
* Return the current Heating Point temperature in Celcius or
* Fahrenheit. This is the temperature at which the thermostat
* will want to engage Heat.
*
* @param fahrenheit true to return data in Fahrenheit, false for
* Celicus. Celcius is the default.
* @return The Heating Point temperature in degrees Celcius or
* Fahrenheit.
*/
float getHeatingPointTemperature(bool fahrenheit=false);
/**
* Return the current Cooling Point temperature in Celcius or
* Fahrenheit. This is the temperature at which the thermostat
* will want to engage Cooling.
*
* @param fahrenheit true to return data in Fahrenheit, false for
* Celicus. Celcius is the default.
* @return The Cooling Point temperature in degrees Celcius or
* Fahrenheit.
*/
float getCoolingPointTemperature(bool fahrenheit=false);
/**
* Return a string representing the current Fan Mode. This
* is usually something like "Auto Low".
*
* @return a string representing the Fan Mode.
*/
std::string getFanMode();
/*
* Return a string representing the current Fan State. This
* is usually something like "Idle".
*
* @return a string representing the Fan State.
*/
std::string getFanState();
/**
* Query the device and update internal state. Strictly speaking,
* this is not really neccessary -- a device may send this data on
* it's own at periodic intervals. This method causes OZW to
* specifically query the device for it's current information.
* The device may take some time to respond.
*/
void update();
protected:
private:
};
}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -38,6 +38,9 @@ zwNode::zwNode(uint32_t homeId, uint8_t nodeId)
m_nodeId = nodeId;
m_vindex = 0;
m_list.clear();
m_values.clear();
m_autoUpdate = false;
}
zwNode::~zwNode()
@ -56,23 +59,33 @@ uint32_t zwNode::homeId()
void zwNode::addValueID(ValueID vid)
{
// We need to use insert since ValueID's default ctor is private
m_values.insert(std::pair<int, ValueID>(m_vindex++, vid));
m_list.push_back(vid);
if (m_autoUpdate)
updateVIDMap();
}
void zwNode::removeValueID(ValueID vid)
{
//we have to get a little complicated here since we need to delete
//the value id, but the map is indexed by m_vindex
for (valueMap_t::iterator it = m_values.begin();
it != m_values.end(); ++it)
m_list.remove(vid);
if (m_autoUpdate)
updateVIDMap();
}
void zwNode::updateVIDMap()
{
m_values.clear();
m_vindex = 0;
m_list.sort();
for (auto it = m_list.cbegin(); it != m_list.cend(); ++it)
{
if ((*it).second == vid)
{
m_values.erase((*it).first);
break;
}
// We need to use insert since ValueID's default ctor is private
m_values.insert(std::pair<int, ValueID>(m_vindex++, *it));
}
}
bool zwNode::indexToValueID(int index, ValueID *vid)
@ -94,17 +107,25 @@ bool zwNode::indexToValueID(int index, ValueID *vid)
void zwNode::dumpNode(bool all)
{
for (valueMap_t::iterator it = m_values.begin();
it != m_values.end(); ++it)
for (auto it = m_values.cbegin();
it != m_values.cend(); ++it)
{
int vindex = (*it).first;
ValueID vid = (*it).second;
int vindex = it->first;
ValueID vid = it->second;
string label = Manager::Get()->GetValueLabel(vid);
string valueAsStr;
Manager::Get()->GetValueAsString(vid, &valueAsStr);
string valueUnits = Manager::Get()->GetValueUnits(vid);
ValueID::ValueType vType = vid.GetType();
string vTypeStr;
string perms;
if (Manager::Get()->IsValueWriteOnly(vid))
perms = "WO";
else if (Manager::Get()->IsValueReadOnly(vid))
perms = "RO";
else
perms = "RW";
switch (vType)
{
@ -155,12 +176,18 @@ void zwNode::dumpNode(bool all)
// by default we only want user values, unless 'all' is true
if (all || (vid.GetGenre() == ValueID::ValueGenre_User))
fprintf(stderr, "\t Index: %2d, Type: %s, Label: %s, Value: %s %s\n",
{
fprintf(stderr, "\t Index: %d, Type: %s, Label: %s, Value: %s %s (%s)\n",
vindex,
vTypeStr.c_str(),
label.c_str(),
valueAsStr.c_str(),
valueUnits.c_str());
valueUnits.c_str(),
perms.c_str());
fprintf(stderr, "\t\t VID: %016x\n",
vid.GetId());
}
}
}

View File

@ -1,6 +1,6 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016l Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -24,14 +24,28 @@
#pragma once
#include <map>
#include <list>
#include "Manager.h"
namespace upm {
/**
* @library ozw
*
* @brief Node management for ozw
*
* This class is used by ozw to manage valueids for a node (device).
* No user-servicable parts inside. It is not exposed to the end
* user.
*/
class zwNode {
public:
// valueid map
typedef std::map<int, OpenZWave::ValueID> valueMap_t;
// valueid list, used for sorting
typedef std::list<OpenZWave::ValueID> valueList_t;
/**
* zwNode contructor.
@ -90,15 +104,38 @@ namespace upm {
*/
void dumpNode(bool all=false);
/**
* Clear the VID map, sort the list containing registered VID's,
* and re-create the VID map. The goal is to ensure that the Map
* is always sorted in acsending order by VID.
*/
void updateVIDMap();
/**
* When enabled, updateVIDMap() will be called every time a new
* VID is inserted or removed. This is disabled by default for
* performance reasons during init() time. Once the driver is
* initialized, then this option is, by default enabled so that
* the VID map is always kept in a sorted order.
*
* @param enable true to enable, false to disable.
*/
void setAutoUpdate(bool enable)
{
m_autoUpdate = enable;
}
protected:
private:
bool m_autoUpdate;
uint32_t m_homeId;
uint8_t m_nodeId;
valueMap_t m_values;
valueList_t m_list;
// we increment this index for every ValueID we add
// we increment this index for every ValueID we add into the map
unsigned int m_vindex;
};