Create routine with dynamic condition value

Hi All,

I’m trying to find a way to create a routine with dynamic condition value, or the value should refer to another capability of the same device or another device.

Let me explain the use case.
I have a Google Nest Thermostat (GNT), but I use it just like a temperature sensor.
I have AC(not smart, pretty stupid) which is connected to a smart plug, once a plug turns on AC starts cooling.
Right now I have a routine - if the temp is equal to or above 26C (hardcoded) it will turn a plug on.
GNT has also set the cooling temperature capability, and I would like to create a routine where
If the GNT temp sensor is equal to or above the GNT cooling temperature then trigger routine action.

What is the benefit, in that case, I can set the threshold when to turn on the AC on the GNT physical device itself, it will be a dynamic value if I set the cooling temp on the GNT device to 25, and routing will be triggered once the temp will be equal to or above 25C if I set 27 then it will be triggered once indoor temp is 27.

I guess this is a pretty useful feature to have, not only hardcode condition value but also the ability to refer to another capability value, at least in the scope of the same device, but would be better to refer to other devices as well.

Maybe somebody has some solution using raspberrypi, it will also work for me.

Many thanks

Using Rules API, it is possible to compare temperature measurements. Maybe it is also possible to compare the measurement to setpoint.

More about Rules API
Rules | SmartThings Developers

1 Like

Hi @TapioX ,

Thank you very much for pointing to that Rules API page.

I’ve checked it and it doesn’t look like there is that possibility to do.

What I want to do is something like this

{
    "name": "If indoor temp equals coolingSetpoint - turn off AC",
    "actions": [
        {
            "if":{
                "equals": {
                    "left":{
                        "device":{
                            "devices":["Google-Nest-Therm-Id"],
                            "component": "main",
                            "capability": "temperatureMeasurement",
                            "attribute": "temperatureMeasurement",
                            "trigger":"Always"
                        }
                    },
                    "right":{
                        "device":{
                            "devices":["Google-Nest-Therm-Id"],
                            "component": "main",
                            "capability": "thermostatCoolingSetpoint",
                            "attribute": "thermostatCoolingSetpoint"
                        }
                    }
                },
                "then":[
                    {
                        "command": {
                                    "devices": [
                                        "smart-plug-for-AC-Id"
                                    ],
                                    "commands": [
                                        {
                                            "component": "main",
                                            "capability": "switch",
                                            "command": "off",
                                            "arguments": []
                                        }
                                    ]
                                }
                    }
                ]
            }
        }
    ]
}

That would be great if @SmartThings would provide such possibility, In this case, it’s possible to interact with values from other devices and make rules smarter.

Hi @TapioX

Just update,
I’ve tried it again, and it works, I had some issues with attributes and because of that, I couldn’t successfully execute the create Rule request.

Right now I managed to do it, Thanks a lot.

BTW:
Here is the Rule that I’ve created, maybe for somebody it can be helpful

{
    "name": "Controll Living Room AC via Google Nest Thermostat",
    "actions": [
        {
            "if": {
                "and": [
                    {
                        "equals": {
                            "left": {
                                "location": {
                                    "attribute": "Mode",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "string": "xxxxxxx-xxxxx-4xx8-xxxx-37xx5xxxxxx" // Home mode id
                            }
                        }
                    },
                    {
                        "greaterThanOrEquals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "temperatureMeasurement",
                                    "attribute": "temperature",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "thermostatCoolingSetpoint",
                                    "attribute": "coolingSetpoint",
                                    "trigger": "Always"
                                }
                            }
                        }
                    },
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "thermostatMode",
                                    "attribute": "thermostatMode",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "string": "auto"
                            }
                        }
                    },
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "AC-PLUG-ID"
                                    ],
                                    "component": "main",
                                    "capability": "switch",
                                    "attribute": "switch"
                                }
                            },
                            "right": {
                                "string": "off"
                            }
                        }
                    }
                ],
                "then": [
                    {
                        "command": {
                            "devices": [
                                "AC-PLUG-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "on",
                                    "arguments": []
                                }
                            ]
                        }
                    }
                ]
            }
        },
        {
            "if": {
                "and": [
                    {
                        "lessThanOrEquals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "temperatureMeasurement",
                                    "attribute": "temperature",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "thermostatHeatingSetpoint",
                                    "attribute": "heatingSetpoint",
                                    "trigger": "Always"
                                }
                            }
                        }
                    },
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "thermostatMode",
                                    "attribute": "thermostatMode",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "string": "auto"
                            }
                        }
                    },
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "AC-PLUG-ID"
                                    ],
                                    "component": "main",
                                    "capability": "switch",
                                    "attribute": "switch"
                                }
                            },
                            "right": {
                                "string": "on"
                            }
                        }
                    }
                ],
                "then": [
                    {
                        "command": {
                            "devices": [
                                "AC-PLUG-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off",
                                    "arguments": []
                                }
                            ]
                        }
                    }
                ]
            }
        },
        {
            "if": {
                "equals": {
                    "left": {
                        "device": {
                            "devices": [
                                "GNT-ID"
                            ],
                            "component": "main",
                            "capability": "thermostatMode",
                            "attribute": "thermostatMode",
                            "trigger": "Always"
                        }
                    },
                    "right": {
                        "string": "off"
                    }
                },
                "then": [
                    {
                        "command": {
                            "devices": [
                                "AC-PLUG-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off",
                                    "arguments": []
                                }
                            ]
                        }
                    }
                ]
            }
        },
        {
            "if": {
                "equals": {
                    "left": {
                        "device": {
                            "devices": [
                                "AC-PLUG-ID"
                            ],
                            "component": "main",
                            "capability": "switch",
                            "attribute": "switch",
                            "trigger": "Always"
                        }
                    },
                    "right": {
                        "string": "on"
                    }
                },
                "then": [
                    {
                        "command": {
                            "devices": [
                                "GNT-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "thermostatMode",
                                    "command": "auto",
                                    "arguments": []
                                }
                            ]
                        }
                    }
                ]
            }
        },
        {
            "if": {
                "or": [
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "thermostatMode",
                                    "attribute": "thermostatMode",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "string": "cool"
                            }
                        }
                    },
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "GNT-ID"
                                    ],
                                    "component": "main",
                                    "capability": "thermostatMode",
                                    "attribute": "thermostatMode",
                                    "trigger": "Always"
                                }
                            },
                            "right": {
                                "string": "heat"
                            }
                        }
                    }
                ],
                "then": [
                    {
                        "command": {
                            "devices": [
                                "GNT-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "thermostatMode",
                                    "command": "auto",
                                    "arguments": []
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}
1 Like