[ST Edge] Virtual Dimmer Device Driver

Using these Rules API rules Virtual Dimmer operates as master Light and
every time Master Light is operated rules copies the master light state to slave Light(s).

Using AWA for adding Rules API rules.

Copy and paste Device IDs from AWA Devices to template rule

Keep quotation marks at the beginning and end of Device ID

Paste new rule json to yellow marked area in Add a Rule.

Rule: Virtual Dimmer Level Changes or On > Copy Level

	   {
		 "if": {
		  "or": [
		  {
			  "changes": {
				"operand": {
				  "device": {
					"devices": [
					  "-- ID Virtual Dimmer Device --"
					],
					"component": "main",
					"capability": "switchLevel",
					"attribute": "level",
					"trigger": "Always"
				  }
				}
			  }
		  },
		  {
			  "equals": {
				 "left": {
					"device": {
						"devices": [
							"-- ID Virtual Dimmer Device --"
						],
						"component": "main",
						"capability": "switch",
						"attribute": "switch",
						"trigger": "Always"
					},
				 },
				 "right": {
					"string": "on",
				 }
			   }
           }
		  ],
		   "then": [
			  {
				"command": {
				  "devices": [
					"-- ID Real Lamp Dimmer Device --"
				  ],
				  "commands": [
					{
					  "component": "main",
					  "capability": "switchLevel",
					  "command": "setLevel",
					  "arguments": [
						{
						  "device": {
							"devices": [
							  "-- ID Virtual Dimmer Device --"
							],
							"component": "main",
							"capability": "switchLevel",
							"attribute": "level"
						  }
						}
					  ]
					}					
				  ]
				}
			  }
			]
		}
	   }

Rule: Virtual Dimmer Off > Real Lamp Off

        {
            "if": {
				"equals": {
					"left": {
						"device": {
							"devices": [
								"-- ID Virtual Dimmer Device --"
							],
							"component": "main",
							"capability": "switch",
							"attribute": "switch",
						    "trigger": "Always"
						}
					},
					"right": {
						"string": "off"
					}
                },
                "then": [
				{
					"command": {
						"devices": [
							"-- ID Real Lamp Dimmer Device --"
						],
						"commands": [
							{
								"component": "main",
								"capability": "switch",
								"command": "off"
							}
						]
					}
				}
                ]
            }
        }


To devices list is possible to add multiple Lights IDs (comma separated).

3 Likes