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