Helper Class Reference  1.3
HomeGenie - Automation Programs' Engine API
Public Member Functions | Properties | List of all members
ModulesManager Class Reference

Modules Manager Helper class.
Offers methods for filtering, selecting and operate on a group of modules.
Class instance accessor: Modules More...

Inheritance diagram for ModulesManager:
ModuleHelper

Public Member Functions

ModulesManager InDomain (string domains)
 Select modules belonging to specified domains. More...
 
ModulesManager WithAddress (string addresses)
 Select modules with specified address. More...
 
ModulesManager WithName (string moduleNames)
 Select modules matching specified names. More...
 
ModulesManager OfDeviceType (string deviceTypes)
 Select modules of specified device types. More...
 
ModulesManager InGroup (string groups)
 Select modules included in specified groups. More...
 
ModulesManager WithParameter (string parameters)
 Select all modules having specified parameters. More...
 
ModulesManager WithFeature (string features)
 Select all modules having specified features. More...
 
ModulesManager WithoutFeature (string features)
 Select all modules NOT having specified features. More...
 
ModulesManager Each (Func< ModuleHelper, bool > callback)
 Iterate through each module in the current selection and pass it to the specified callback. To break the iteration, the callback must return true, otherwise false. More...
 
ModuleHelper Get ()
 Returns the module in the current selection. If the current selection contains more than one element, the first element will be returned. More...
 
ModulesManager Command (string command)
 Select an API command to be executed for selected modules. To perform the selected command, Execute or Set method must be invoked. More...
 
ModulesManager IterationDelay (double delaySeconds)
 Used before a command (Set, Execute, On, Off, Toggle, ...), it will put a pause after performing the command for each module in the current selection. More...
 
object GetValue (string options="")
 Execute current command on first selected module and return the response value. More...
 
ModulesManager Execute ()
 Execute current command for all selected modules. More...
 
ModulesManager Execute (string options)
 Execute current command with specified options. More...
 
ModulesManager Set ()
 Alias for Execute() More...
 
ModulesManager Set (string options)
 Alias for Execute(options) More...
 
ModulesManager On ()
 Turn on all selected modules. More...
 
ModulesManager Off ()
 Turn off all selected modules. More...
 
ModulesManager Toggle ()
 Toggle all selected modules. More...
 
ModulesManager Copy ()
 Creates a copy of the actual modules selection. More...
 
ModulesManager Reset ()
 Resets all selection filters. More...
 

Properties

Func< ModulesManager, TsList< Module > > ModulesListCallback [get, set]
 Gets or sets the modules list on which this helper class will be working on. More...
 
TsList< ModuleModules [get]
 Gets the complete modules list. More...
 
virtual TsList< ModuleSelectedModules [get]
 Return the list of selected modules. More...
 
List< string > Groups [get]
 Return the list of control groups. More...
 
double Level [get, set]
 Gets or sets "Status.Level" parameter of selected modules. If more than one module is selected, when reading this property the average level value is returned. More...
 
bool IsOn [get]
 Gets "on" status ("Status.Level" > 0). More...
 
bool IsOff [get]
 Gets "off" status ("Status.Level" == 0). More...
 
bool Alarmed [get]
 Gets "alarm" status ("Sensor.Alarm" > 0). More...
 
bool MotionDetected [get]
 Gets "motion detection" status ("Sensor.MotionDetect" > 0). More...
 
double Temperature [get]
 Gets temperature value ("Sensor.Temperature"). More...
 
double Luminance [get]
 Gets luminance value ("Sensor.Luminance"). More...
 
double Humidity [get]
 Gets humidity value ("Sensor.Humidity"). More...
 

Detailed Description

Modules Manager Helper class.
Offers methods for filtering, selecting and operate on a group of modules.
Class instance accessor: Modules

Member Function Documentation

◆ InDomain()

ModulesManager InDomain ( string  domains)

Select modules belonging to specified domains.

Returns
ModulesManager
Parameters
domainsA string containing comma seperated domain names.

Example:

// turn off all z-wave lights
.InDomain("HomeAutomation.ZWave")
.OfDeviceType("Light,Dimmer")
.Off();

◆ WithAddress()

ModulesManager WithAddress ( string  addresses)

Select modules with specified address.

Returns
ModulesManager
Parameters
addressesA string containing comma seperated address values.

Example:

// turn on X10 units A2 and B5
Modules.WithAddress("A2,B5").On();

◆ WithName()

ModulesManager WithName ( string  moduleNames)

Select modules matching specified names.

Returns
ModulesManager
Parameters
moduleNamesA string containing comma seperated module names.

Example:

// turn off ceiling light
Modules.WithName("Ceiling Light").Off();

◆ OfDeviceType()

ModulesManager OfDeviceType ( string  deviceTypes)

Select modules of specified device types.

Returns
ModulesManager
Parameters
deviceTypesA string containing comma seperated type names.

Example:

// turn on all lights and appliances
Modules.OfDeviceType("Light,Dimmer,Switch").On();

◆ InGroup()

ModulesManager InGroup ( string  groups)

Select modules included in specified groups.

Returns
ModulesManager
Parameters
groupsA string containing comma seperated group names.

Example:

Modules.InGroup("Living Room,Kitchen").Off();

◆ WithParameter()

ModulesManager WithParameter ( string  parameters)

Select all modules having specified parameters.

Returns
ModulesManager
Parameters
parametersA string containing comma seperated parameter names.

Example:

// select all modules with Sensor.Temperature parameter and get the average temperature value
var averagetemperature = Modules.WithParameter("Sensor.Temperature").Temperature;
Program.Notify("Average Temperature", averagetemperature);

◆ WithFeature()

ModulesManager WithFeature ( string  features)

Select all modules having specified features.

Returns
ModulesManager
Parameters
featuresA string containing comma separated feature names.

Example:

// Turn on all Security System sirens
Modules.WithFeature("HomeGenie.SecurityAlarm").On();

◆ WithoutFeature()

ModulesManager WithoutFeature ( string  features)

Select all modules NOT having specified features.

Returns
ModulesManager
Parameters
featuresA string containing comma seperated feature names.

Example:

// Turn off all modules not having the "EnergySavingMode" feature
Modules.WithoutFeature("EnergyManagement.EnergySavingMode").Off();

◆ Each()

ModulesManager Each ( Func< ModuleHelper, bool >  callback)

Iterate through each module in the current selection and pass it to the specified callback. To break the iteration, the callback must return true, otherwise false.

Parameters
callbackCallback function to call for each iteration.
Returns
ModulesManager

Example:

var total_watts_load = 0D;
Modules.WithParameter("Meter.Watts").Each( (module) => {
total_watts_load += module.Parameter("Meter.Watts").DecimalValue;
return false; // continue iterating
});
Program.Notify("Current power load", total_watts_load + " watts");

◆ Get()

ModuleHelper Get ( )

Returns the module in the current selection. If the current selection contains more than one element, the first element will be returned.

Returns
ModuleHelper

Example:

var strobeAlarm = Modules.WithName("Strobe Alarm").Get();
<br>

◆ Command()

ModulesManager Command ( string  command)

Select an API command to be executed for selected modules. To perform the selected command, Execute or Set method must be invoked.

Returns
ModulesManager
Parameters
commandAPI command to be performed.

Example:

// turn on all modues of "Light" type
Modules.OfDeviceType("Light").Command("Control.On").Execute();
// set all dimmers to 50%
Modules.OfDeviceType("Dimmer").Command("Control.Level").Set("50");

◆ IterationDelay()

ModulesManager IterationDelay ( double  delaySeconds)

Used before a command (Set, Execute, On, Off, Toggle, ...), it will put a pause after performing the command for each module in the current selection.

Returns
ModulesManager
Parameters
delaySecondsDelay seconds.

Example:

// Set the level of all dimmer type modules to 40%,
// putting a 100ms delay between each command
.OfDeviceType("Dimmer")
.Command("Control.Level")
.IterationDelay(0.1)
.Set(40);

◆ GetValue()

object GetValue ( string  options = "")

Execute current command on first selected module and return the response value.

Parameters
optionsOptions.

◆ Execute() [1/2]

ModulesManager Execute ( )

Execute current command for all selected modules.

Returns
ModulesManager

◆ Execute() [2/2]

ModulesManager Execute ( string  options)

Execute current command with specified options.

Parameters
optionsA string containing options to be passed to the selected command.
Returns
ModulesManager

◆ Set() [1/2]

ModulesManager Set ( )

Alias for Execute()

Returns
ModulesManager

◆ Set() [2/2]

ModulesManager Set ( string  options)

Alias for Execute(options)

Parameters
optionsA string containing options to be passed to the selected command.
Returns
ModulesManager

◆ On()

Turn on all selected modules.

Returns
ModulesManager

◆ Off()

ModulesManager Off ( )

Turn off all selected modules.

Returns
ModulesManager

◆ Toggle()

ModulesManager Toggle ( )

Toggle all selected modules.

Returns
ModulesManager

◆ Copy()

ModulesManager Copy ( )

Creates a copy of the actual modules selection.

Returns
ModulesManager

◆ Reset()

ModulesManager Reset ( )

Resets all selection filters.

Returns
ModulesManager

Property Documentation

◆ ModulesListCallback

Func<ModulesManager,TsList<Module> > ModulesListCallback
getset

Gets or sets the modules list on which this helper class will be working on.

The modules list callback.

◆ Modules

TsList<Module> Modules
get

Gets the complete modules list.

The modules.

◆ SelectedModules

virtual TsList<Module> SelectedModules
get

Return the list of selected modules.

Returns
List<Module>

◆ Groups

List<string> Groups
get

Return the list of control groups.

Returns
List<string>

◆ Level

double Level
getset

Gets or sets "Status.Level" parameter of selected modules. If more than one module is selected, when reading this property the average level value is returned.

The level (percentage value 0-100).

Example:

// Set the level of all modules with EnergySavingMode flag enabled to 40%
Modules.WithFeature("EnergyManagement.EnergySavingMode").Level = 40;

◆ IsOn

bool IsOn
get

Gets "on" status ("Status.Level" > 0).

true if at least one module in the current selection is on; otherwise, false.

◆ IsOff

bool IsOff
get

Gets "off" status ("Status.Level" == 0).

true if at least one module in the current selection is off; otherwise, false.

◆ Alarmed

bool Alarmed
get

Gets "alarm" status ("Sensor.Alarm" > 0).

true if at least one module in the current is alarmed; otherwise, false.

◆ MotionDetected

bool MotionDetected
get

Gets "motion detection" status ("Sensor.MotionDetect" > 0).

true if at least one module in the current detected motion; otherwise, false.

◆ Temperature

double Temperature
get

Gets temperature value ("Sensor.Temperature").

The temperature parameter of selected module (average value is returned when more than one module is selected).

◆ Luminance

double Luminance
get

Gets luminance value ("Sensor.Luminance").

The luminance parameter of selected module (average value is returned when more than one module is selected).

◆ Humidity

double Humidity
get

Gets humidity value ("Sensor.Humidity").

The humidity parameter of selected module (average value is returned when more than one module is selected).


The documentation for this class was generated from the following file:
HomeGenie.Automation.Scripting.ModulesManager.Modules
TsList< Module > Modules
Gets the complete modules list.
Definition: ModulesManager.cs:290