upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Types | Public Member Functions

UPM API for Aeotec Smart Dimmer Gen 2. More...

Detailed Description

This module allows for controlling and monitoring certain elements of an Aeotec Smart Dimmer Gen 2.

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(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 upm_delaying for 5 secs" << endl;
sensor.on();
upm_delay(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;
upm_delay(5);
}
cout << "Turning switch off and upm_delaying for 5 seconds..." << endl;
sensor.off();
upm_delay(5);
cout << "Exiting..." << endl;

Public Types

enum  INDEX_VALUES_T : int {
  INDEX_Level = 0, INDEX_Energy_kWh = 3, INDEX_Power_Watts = 6, INDEX_Volts = 9,
  INDEX_Current = 12
}
 

Public Member Functions

 AeotecSDG2 (int nodeID)
 
 ~AeotecSDG2 ()
 
void setLevel (int level)
 
int getLevel ()
 
void on ()
 
void off ()
 
bool isOn ()
 
void update ()
 
float getEnergy ()
 
float getWatts ()
 
float getVolts ()
 
float getCurrent ()
 
- Public Member Functions inherited from ozwInterface
 ozwInterface (int nodeID)
 
virtual ~ozwInterface ()
 
virtual void setDebug (bool enable)
 
virtual void optionsCreate (std::string configPath="/etc/openzwave", std::string userConfigDir="", std::string cmdLine="")
 
virtual void optionAddInt (std::string name, int val)
 
virtual void optionAddBool (std::string name, bool val)
 
virtual void optionAddString (std::string name, std::string val, bool append)
 
virtual void optionsLock ()
 
virtual void init (std::string devicePath, bool isHID=false)
 
virtual void dumpNodes (bool all=false)
 
virtual std::string getValueUnits (int index)
 
virtual std::string getValueLabel (int index)
 

Additional Inherited Members

- Protected Attributes inherited from ozwInterface
bool m_debugging
 
uint32_t m_nodeID
 
OZWm_instance
 
bool m_initialized
 

Member Enumeration Documentation

enum INDEX_VALUES_T : int

These values correspond to the index values of the given node

Constructor & Destructor Documentation

AeotecSDG2 ( int  nodeID)

AeotecSDG2 constructor

Parameters
nodeIDThe ZWave node number of the device we are interested in. Use the ozwdump example to see what nodes you have available.
~AeotecSDG2 ( )

AeotecSDG2 Destructor

Member Function Documentation

void setLevel ( int  level)

Set the output level of the dimmer switch. This is a value between 0 (fully off) and 99 (fully on).

Parameters
levelThe desired output level of the dimmer switch. Valid values are between 0-99.

Here is the call graph for this function:

Here is the caller graph for this function:

int getLevel ( )

Return the current output level of the dimmer switch. This will be a number between 0 (fully off) and 99 (fully on).

Returns
the current dimmer output level.

Here is the call graph for this function:

void on ( )
inline

Turn the switch fully on by setting the highest level (99). This is equivalent to calling setLevel(99).

Here is the call graph for this function:

void off ( )
inline

Turn the switch off by setting the lowest level (0). This is equivalent to calling setLevel(0).

Here is the call graph for this function:

bool isOn ( )

Check to see if the switch is on or off. Any dimmer level greater that 0 is considered 'on'.

Returns
true if the dimmer switch is on, false otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

void update ( void  )

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.

Here is the call graph for this function:

Here is the caller graph for this function:

float getEnergy ( )

Return the device's accumulated energy usage in kilo-watt-hours (kWh).

Returns
The energy usage in kWh.

Here is the call graph for this function:

Here is the caller graph for this function:

float getWatts ( )

Return the device's current power consumption in Watts.

Returns
The current power consumption in Watts.

Here is the call graph for this function:

Here is the caller graph for this function:

float getVolts ( )

Return the device's current voltage measurement in Volts.

Returns
The volts measurement.

Here is the call graph for this function:

Here is the caller graph for this function:

float getCurrent ( )

Return the device's current consumption in Amps.

Returns
The current consumption measurement in Amps.

Here is the call graph for this function:

Here is the caller graph for this function:

Inheritance diagram for AeotecSDG2:
Inheritance graph
[legend]
Collaboration diagram for AeotecSDG2:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: