Skip to content

Instantly share code, notes, and snippets.

@BenediktNiehues
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenediktNiehues/712138deab15aa695a2c to your computer and use it in GitHub Desktop.
Save BenediktNiehues/712138deab15aa695a2c to your computer and use it in GitHub Desktop.
Module Templates
//following is a ModuleTemplate to combine two conditions
{
"id": "MotionOn_And_Brightness",
"name": "Motion and Brightness",
"tags": ["Brightness", "Motion", "ON"],
"description": "Checks if a motion state is ON and the brightness is less than X.",
"input" : [
{
"name": "motionItem",
"type": "String",
"label": "Motion Item",
"description": "Name of motion detector item",
"required": true
},
{
"name":"brightnessItem",
"type": "String",
"label": "Brightness Item",
"description": "Name of the brightness item",
"required": true
},
{
"name":"brightnessThreshold",
"type": "number",
"label": "Brightness Threshold",
"description": "Maximal brightness",
"required": true
}
],
//configuration of Modules (must all be of type Condition)
"modules" : [
{
"id" : "brightnessLess1",
"type": "Compare",
"config": {
"operator": "<",
"left:": "$brightnessItem",
"right": "$brightness"
}
},
{
"id" : "motionOn1",
"type" : "Compare",
"config" : {
"operator" : "=",
"left": "$motionItem",
"right": "ON"
}
}
]
}
"thenTemplate":{
"id":"LightOnAndColor",
"description":"switches on a light and sets its color",
"config":[
{
"name":"colorItem",
"type":"String",
"label":"ColorItem",
"description":"Name of the colorItme",
"required":true
},
{
"name":"color",
"type":"String",
"label":"Color",
"description":"Color in HSB",
"required":true
}
],
"modules" : [
{
"type": "SendCommand",
"config": {
"item": "$colorItem",
"command": "ON"
}
},
{
"type": "SendCommand",
"config": {
"item": "$colorItem",
"command": "$color"
}
}
]
}
"triggerTemplate":{
"id": "MotionDetection",
"description": "Activates a rule if a motion was detected.",
"config" : [
{
"name":"motionItem",
"type": "item",
"label": "Motion Item",
"description": "Name of motion detector item",
"required": true
}
],
"modules": [
{
"type": "ItemUpdateEvent",
"config": {
"item": "$motionItem"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment