ST app ways to cause one dimmer to do what another dimmer does?

I finally changed my over kitchen sink can light so it is now on a Jasco Zwave 700 dimmer. It matches the dimmer that controls 3 other can lights in the kitchen.

Is there a way in ST to do this:

If the kitchen dimmer is on at X% already, and I click to turn on the sink dimmer, it will automatically check the kitchen dimmer % and then match it at the sink?

Thanks!

No easy way to do this in ST Routines because there is no way to read the value of the kitchen dimmer and apply it to the sink dimmer (no variables). There are some ways to synchronize behaviors using either association groups or the Smartlighting app, but that might not be what you are really wanting.

You could probably achieve what you want if you install the Aplicaciones Virtuales Mc driver Applications: Number Fields and Basic Calculations which allows for storing values (and doing simple calculations on them) and using the Rules API. After installing this driver, you would create a rule that writes the dimmer value to a field when the kitchen light is turned on. Then when the sink is turned on, you could set the sink dimmer to the value you wrote into the field. I’m personally not well versed in using the Rules API, but someone like @TapioX might be able to give you an example.

Alternatively, you could pick some pre-defined dimmer values and set the kitchen and the sink dimmers to come on to those values based on time of day or some other criteria using Routines.

3 Likes

Yes, you can sync dimmers with Smart lighting. It just said switch, but is syncing dimmer too




I don’t think that’s not quite the same thing as what he asked for. It will sync/mirror the sink dimmer to the kitchen dimmer every time the kitchen dimmer is turned on. He wants to match the dim level only when the sink dimmer is manually turned on.

2 Likes

Also worth noting: Smart lighting may not be available in all regions.

2 Likes

Right. And a quick look at the Smartlighting recipe in the ST Advanced Web App confirms that when the control device is turned on, it will also turn on the sync device and set the dimmer level vs only setting the dimmer level for the sync device if it is turned on manually.

Thinking a bit more about this after looking at the Smartlighting recipe and looking at some of the JSON for my other Routines, you should be able to write a Rules API rule something like this:

If Kitchen Light is on (pre-condition)
Sink light turns on
Then
Set Sink light dim level to the dim level of the Kitchen Light deviceId

Take then part from this RulesAPI example:

Thanks for the replies all, esp @h0ckeysk8er and @TapioX

I’m going to spend some time getting smart on the RulesAPI and report back

Anyone willing to skim this code and see if you can spot why it won’t even save?

The Rules API gives me this error: ā€œError adding rule ā€œKitchen Sink Dimmers Syncā€. 422 The request is malformed. Unknown target: Malformed body on line 1:47ā€

{
    "name": "Sync Kitchen and Sink Lights",
        "actions": [
        {
            "if": {
                "and": [
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "deviceId": "6shortened-kitchendimmer",
                                    "component": "main",
                                    "capability": "switch",
                                    "attribute": "switch"
                                }
                            },
                            "right": {
                                    "value": "on"
                            }
                        }
                    },
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "deviceId": "8shortened-sinkdimmer",
                                    "component": "main",
                                    "capability": "switch",
                                    "attribute": "switch"
                                }
                            },
                            "right": {
                                    "value": "on"
                            }
                        }
                    }
                ],
                "then": [
                    {
                        "command": {
                            "deviceId": "8shortened-sinkdimmer",
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switchLevel",
                                    "command": "setLevel",
                                    "arguments": [
                                        {
                                            "device": {
                                                "deviceId": "6shortened-kitchendimmer",
                                                "component": "main",
                                                "capability": "switchLevel",
                                                "attribute": "level"
                                            }
                                        }
                                    ]
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}
  

What are you using to create the Rule? Only a common ā€˜gotcha’ is that the Advanced Web App rather unnecessarily and unhelpfully separates the name and actions out so it only wants the value of the actions from (and including) the opening [ to the closing ā€˜]’.

When you see something like 1:47 count 47 characters into the Rule, perhaps allowing one or two characters for each line ending in your source. That will get you to the problem spot. The Rule is being seen as a single line.

1 Like

I’ve read this twice, and I’m sorry, I don’t understand. Can you explain it like I’m 5? :slight_smile:

I was mentioning a couple of common issues. One was that the error message is pointing you at 1:47, meaning line 1 character 47. When you see that and there aren’t that many characters on your first line it is because your rule has been read as a single line. So you need to count 47 characters into your rule, perhaps counting one for each new line. It seems to be getting unhappy on your second line.

The other issue is that many users are using the Advanced Web App (https://my.smartthings.com/advanced) to create their rules, and for some reason rather than you just entering your whole rule it expects you to pick out the name and the actions values. So if you look at the rule as having the structure:

{
    "name": "The name of the rule",
    "actions": [
        ...
    ]
}

you are expected to enter

The name of the rule

for the name and

[
    ...
]

for the actions. That trips many users up. I wish they wouldn’t do it like that as it means you don’t get to see exactly what is being submitted to the API.

Looking at the rule itself. The device operand actually takes an array of device UUIDs. So the format is:

"device": {
    "devices": [
        "UUID1"
    ],
    "component": "main",
    "capability": "switch",
    "attribute": "switch"
}

The comparison needs to be explicit about the type of value you are comparing.

"right": {
    "string": "on"
}

At the top of command actions you should have an array of device UUIDs.

"command": {
    "devices": [
        "UUID1"
    ],
    "commands": []
}
3 Likes

Thank you so much. I’ll tinker with this again this weekend. Thank you!