Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Actions are the way to configure automated tasks based on time (like sunset or sunrise), or based on device attribute states or commands emitted by them. The most typical example is to use this resource to schedule irrigation programs for the garden or to use sunset for lighting. For more details about this resource schema, refer to Action. Please keep in mind that Actions are termed as Automation Rules for Smartenit App end users.

...

Code Block
languagejs
// True at 8:05pm everyday using local TZ
var condition = {
	"name": "Absolute time",
	"enabled": true,
	"path": "/devices/507f191e810c19729de860ea/time",
	"value": "8:05pm"
};

// True between Sunrise to Sunset
var condition1 = {
	"name": "Sunrise to sunset",
	"enabled": true,
	"path": "/devices/507f191e810c19729de860ea/time",
	"value": {
		"#from": "sunrise",
		"#to": "sunset"
	}
};

// True between Sunrise to 3:10pm
var condition2 = {
	"name": "Sunrise to absolute time",
	"enabled": true,
	"path": "/devices/507f191e810c19729de860ea/time",
	"value": {
		"#from": "sunrise",
		"#to": "3:10pm"
	}
};

// Trigger once randomly between 6pm and 830pm
var condition3 = {
	"name": "Random condition",
	"enabled": true,
	"path": "/devices/507f191e810c19729de860ea/time",
	"value": {
		"#from": "6:00pm",
		"#to": "8:30pm",
		"#random": true
	}
};

// Interval with 60secs as period
var condition4 = {
	"name": "Periodic condition",
	"enabled": true,
	"path": "/devices/507f191e810c19729de860ea/time",
	"value": {
		"#period":"60"
	}
};

// Temp > 10.54 && Temp < 23.45 
var condition5 = {
	"name": "Temperature in range",
	"path": "/devices/507f191e810c19729de860ea/1/TemperatureMeasurement/aMeasurementValue",
	"value": {
		"#from": "10.54",
		"#to": "23.45"
	}
};

// Temp > 23.45C && Temp < 10.54C
var condition6 = {
  "name": "Temperature out range",
  "path": "/devices/507f191e810c19729de860ea/1/TemperatureMeasurement/aMeasurementValue",
  "operation": "NotEqual"
  "value": {
	"#lt": "10.54",
	"#gt": "23.45"
  }
};
 
// Instantaneous Demand > 60W
var condition7 = {
  "name": "High Instantaneous Demand",
  "path": "/devices/507f191e810c19729de860ea/1/SimpleMetering/aInstantaneousDemandInstantaneousDemand",
  "value": {
    "#gt": 0.060
  }
};

// Motion sensor detected, bitmask using 0x03 for checking if bit 0 or 1 is set
var condition7 = {
  "name": "Motion sensor detected",
  "path": "/devices/507f191e810c19729de860ea/1/IASZone/ZoneStatusChangeNotification.ZoneStatus",
  "value": {
    "#bitmask": 3
  }
};

// Regular expression condition
var meter_message = {
  "name": "publish message",
  "path": "/devices/507f191e810c19729de860ea/1/Messaging/PublishMessage.Message",
  "value": {
    "#regexp": "(\bSaving\b|\bOpportunity\b)"
  }
};

// Weather in a custom latitude-longitude using pseudo devices
// 1. Create a weather device and set latitude and longitude accordingly
// 2. Configure attribute to read and periodically
// 3. Create action using this condition
var weather_condition = {
  "name": "publish message",
  "path": "/devices/507f191e810c19729de860ea/1/YahooWeather/WindSpeed",
  "value": {
    "#gt": 11.57
  }
};