I want to reflect the current mode state to the condition. How should I make it?

name: '외출'
actions:
  - if:
      changes:
        left:
          location:
            locationID: ID
            attribute: "Mode"
            trigger: "Home"
        right:
          string: ID
      then:
        - command:
            devices:
              - ID
            commands:
              - component: main
                capability: switch
                command: off

I looked online and tried to make it, but it couldn’t be uploaded. what’s the problem?

Hi,

I’m not sure if I correctly got your question, but if you are looking at how to make a condition based on the mode state, you can do it like this.

{
   "name": "Turn the plug on when mode is home",
   "actions": [
       {
           "if": {
               "equals": {
                   "left": {
                       "location": {
                           "attribute": "Mode",
                           "trigger": "Always"
                       }
                   },
                   "right": {
                       "string": "xxxxxxx-xxxxx-4xx8-xxxx-37xx5xxxxxx" // Home mode id
                   }
               }
           },
           "then": [
               {
                   "command": {
                       "devices": [
                           "AC-PLUG-ID"
                       ],
                       "commands": [
                           {
                               "component": "main",
                               "capability": "switch",
                               "command": "on",
                               "arguments": []
                           }
                       ]
                   }
               }
           ]
       }
   ]
}

Here are the samples of how to do Rules with different conditionals

Assuming that you have set the right of the equals to the ID of the particular mode you are comparing against, I would imagine it is the trigger that is the problem. That property can only be set to Auto, Always or Never.

In the terminology of Routines, Always would mean the mode is a ‘condition’ and Never would mean it is a ‘pre-condition’. The default is Auto which means that which one it is will depend on what else is in the Rule. As there doesn’t seem to any information on exactly how this is determined I prefer to use Always or Never.

In webCoRE terminology, the end result is similar to setting a condition to ‘always subscribe’ or ‘never subscribe’. However in webCoRE we know for sure what the default automatic behaviour will be.