The ActionProvider
The base class for all Action Providers. If you want to provide actions in your plugin then
you should create a sub class that implements the parseAction
function.
parseAction()
This function should parse the given input string input
and return a ActionHandler if
it can handle the by the input described action else it should return null
.
The Action Handler
The base class for all Action Handler. If you want to provide actions in your plugin then
you should create a sub class that implements a executeAction
function.
executeAction()
Ìt should return a promise that gets fulfilled with describing string, that explains what was done or would be done.
If simulate
is true
the Action Handler should not execute the action. It should just
return a promise fulfilled with a descrbing string like "would ...".
Take a look at the Log Action Handler for a simple example.
The Log Action Provider
Provides log action, so that rules can use log "some string"
in the actions part. It just prints
the given string to the logger.
just return a promise fulfilled with a description about what we would do.
else we should log the string. But we don't do this because the framework logs the description anyway. So we would doubly log it.
The SetVariable ActionProvider
Provides log action, so that rules can use log "some string"
in the actions part. It just prints
the given string to the logger.
just return a promise fulfilled with a description about what we would do.
The Switch Action Provider
Provides the ability to switch devices on or off. Currently it handles the following actions:
- switch [the] device on|off
- turn [the] device on|off
- switch on|off [the] device
- turn on|off [the] device
where device is the name or id of a device and "the" is optional.
parseAction()
Parses the above actions.
The result the function will return:
Try to match the input string with: turn|switch ->
device name -> on|off
Already had a match with another device?
on|off -> deviceName
Already had a match with another device?
Handles the above actions.
The Toggle Action Provider
Provides the ability to toggle switch devices on or off. Currently it handles the following actions:
- toggle the state of device
- toggle the state of [the] device
- toggle device state
- toggle [the] device state
where device is the name or id of a device and "the" is optional.
parseAction()
Parses the above actions.
The result the function will return:
The Shutter Action Provider
Provides the ability to raise or lower a shutter
- lower [the] device [down]
- raise [the] device [up]
- move [the] device up|down
where device is the name or id of a device and "the" is optional.
parseAction()
Parses the above actions.
Try to match the input string with: raise|up ->
device name -> up|down
Already had a match with another device?
The Shutter Stop Action Provider
Provides the ability to stop a shutter
- stop [the] device
where device is the name or id of a device and "the" is optional.
parseAction()
Parses the above actions.
Try to match the input string with: stop ->
device name -> up|down
Already had a match with another device?
The Dimmer Action Provider
Provides the ability to change the dim level of dimmer devices. Currently it handles the following actions:
- dim [the] device to value%
where device is the name or id of a device and "the" is optional.
parseAction()
Parses the above actions.
The result the function will return:
Try to match the input string with:
Handles the above actions.
Export the classes so that they can be accessed by the framework
Action Provider
A Action Provider can parse a action of a rule string and returns an Action Handler for that. The Action Handler offers a
executeAction
method to execute the action. For actions and rule explenations take a look at the rules file.