Controlling dimming with Rules API

I want to control dimming of an Ikea Tradfri light using Rules API without affecting it’s on/off state.

I have some code I wrote but I’m getting “Malformed body on line 27” error.

{
    "name": "Set brightness to 20%",
    "actions": [
        {
            "every": {
                "specific": {
                    "reference": "Sunset",
                    "offset": {
                        "value": {
                            "integer": 30
                        },
                        "unit": "Minute"
                    }
                },
                "actions": [
                    {
                        "command": {
                            "devices": [
                                "39199c4f-fe77-4ec4-ad5d-5ec62076edf8"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switchLevel",
                                    "command": "setLevel",
                                    "arguments": [
                                        20
                                    ]
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

Appreciate any help.

Tagging @erickv

1 Like

Hello @Adrenalin,

We’ve been able to replicate this issue and we have escalated it to our development team. I’ll keep updating you about the progress.

1 Like

Thanks guys, so I wasn’t doing anything wrong?

Also, is it possible to get the app to tell me a list of available commands I can send a device?

That would be super helpful.

Hello @Adrenalin,
Below, you can find the structure to use the switchLevel capability. The argument error is because you need to specify the data type, for example, boolean, integer or string.

{
    "name": "Set brightness to 20%",
    "actions": [
        {
            "every": {
                "specific": {
                    "reference": "Sunset",
                    "offset": {
                        "value": {
                            "integer": 30
                        },
                        "unit": "Minute"
                    }
                },
                "actions": [
                    {
                        "command": {
                            "devices": [
                                "deviceID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switchLevel",
                                    "command": "setLevel",
                                    "arguments": [{
                                        "integer": 20
									}]
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

About which commands can you send, it depends on the capabilities available for the device, you can query the device list to see their capabilities and then, check this document to see the commands of each one of them.
If this answers your question, can you mark it as Solved, please? If not, let me know what’s going on and we can dig in further.