Sunrise-Sunset and Calendar functions for edge

Hi @nayelyz

A precondition still fails when combined with multiple OR conditions in the same routine.
The precondition behaves like an OR condition more within the routine instead of a precondition.

If the precondition is combined with several AND confitions then it works well as a precondition.

I think this would be worth solving.
Thank you

Hi, I just pinged the team again. Once we get more info, or in case we need your help with something, we’ll let you know.

Hi @nayelyz
In case it can help in your report.
I have been looking at the routines in @TAustin Browser+ API in JSON format and I think the error is only in the routines that use a precondition with a Interval condition and multiple conditions with an OR condition.
If the precondition has a condition it is: equal, greater or equal or less than or equal everything works fine.

Here is an example of a routine with a temperature interval precondition combined with two switch conditions = on with AND. Everything works fine Fine.

  • The precondition is distinguished by the value “trigger”: “Never”

  • The trigger conditions have the value “trigger”: “Always”

  • The IF: { AND: [ 
 ] condition affects the precondition and the two AND conditions.
    The precondition has “trigger”: “Never” and therefore never triggers the execution of the Then part until the two conditions that have “trigger”: “Always” are met.

{
  "if": {
    "and": [
      {
        "between": {
          "value": {
            "device": {
              "devices": [
                "16fa2ff4-00ca-4b65-b1db-5af142511d65"
              ],
              "component": "main",
              "capability": "temperatureMeasurement",
              "attribute": "temperature",
              "trigger": "Never"
            },
            "type": "device"
          },
          "start": {
            "decimal": 23,
            "type": "decimal"
          },
          "end": {
            "decimal": 26,
            "type": "decimal"
          },
          "changesOnly": false
        },
        "type": "between"
      },
      {
        "equals": {
          "left": {
            "device": {
              "devices": [
                "01caa709-9547-4bd2-b833-1aedeaa57d8d"
              ],
              "component": "main",
              "capability": "switch",
              "attribute": "switch",
              "trigger": "Always"
            },
            "type": "device"
          },
          "right": {
            "string": "on",
            "type": "string"
          },
          "changesOnly": false
        },
        "type": "equals"
      },
      {
        "equals": {
          "left": {
            "device": {
              "devices": [
                "1d33051b-2218-4f82-a81b-911d6a46c9a9"
              ],
              "component": "main",
              "capability": "switch",
              "attribute": "switch",
              "trigger": "Always"
            },
            "type": "device"
          },
          "right": {
            "string": "on",
            "type": "string"
          },
          "changesOnly": false
        },
        "type": "equals"
      }
    ],
    "type": "and",
    "then": [
      {
        "notification": {
          "push": {
            "title": "Termostato, Temperatura: 23~26°C",
            "message": "Temperature interval 23° to 26°"
          },
          "type": "push"
        },
        "type": "notification"
      }
    ],
    "sequence": {
      "then": "Parallel",
      "else": "Parallel"
    }
  },
  "type": "if"
}

Here is an example of a routine with a temperature Interval precondition, combined with two switch conditions = on with OR. It is fired when any of the OR conditions even if the precondition does not meet:

  • The IF: { OR: [ 
 ] condition affects the precondition and the two OR conditions. the precondition has “trigger”: “Never” and therefore does not trigger.
    It never triggers the execution of the Then part, but it should prevent any of the conditions that have “trigger”: “Always” from triggering the execution if its interval precondition is not fulfilled. Then part However is triggered because it is all included within the same IF: { OR: [ 
 ]
{
  "if": {
    "or": [
      {
        "between": {
          "value": {
            "device": {
              "devices": [
                "16fa2ff4-00ca-4b65-b1db-5af142511d65"
              ],
              "component": "main",
              "capability": "temperatureMeasurement",
              "attribute": "temperature",
              "trigger": "Never"
            },
            "type": "device"
          },
          "start": {
            "decimal": 23,
            "type": "decimal"
          },
          "end": {
            "decimal": 26,
            "type": "decimal"
          },
          "changesOnly": false
        },
        "type": "between"
      },
      {
        "equals": {
          "left": {
            "device": {
              "devices": [
                "01caa709-9547-4bd2-b833-1aedeaa57d8d"
              ],
              "component": "main",
              "capability": "switch",
              "attribute": "switch",
              "trigger": "Always"
            },
            "type": "device"
          },
          "right": {
            "string": "on",
            "type": "string"
          },
          "changesOnly": false
        },
        "type": "equals"
      },
      {
        "equals": {
          "left": {
            "device": {
              "devices": [
                "1d33051b-2218-4f82-a81b-911d6a46c9a9"
              ],
              "component": "main",
              "capability": "switch",
              "attribute": "switch",
              "trigger": "Always"
            },
            "type": "device"
          },
          "right": {
            "string": "on",
            "type": "string"
          },
          "changesOnly": false
        },
        "type": "equals"
      }
    ],
    "type": "or",
    "then": [
      {
        "notification": {
          "push": {
            "title": "Termostato, Temperatura: 23~26°C",
            "message": "Temperature interval 23° to 26°"
          },
          "type": "push"
        },
        "type": "notification"
      }
    ],
    "sequence": {
      "then": "Parallel",
      "else": "Parallel"
    }
  },
  "type": "if"
}

Here is an example of a routine with precondition with temperature <= at 18ÂșC, combined with two switch conditions = on with OR. It is triggered only when any of the OR conditions and the precondition of temperature <= 18ÂșC are fulfilled:

  • The condition IF: { AND: [ 
 ] affects the precondition of temperature <= 18ÂșC. The precondition has “trigger”: “Never” and therefore never triggers execution of the Then part.
    The IF: { OR: [ 
 ] condition only affects the switch = on conditions and therefore prevents any of the conditions that have “trigger”: “Always” from firing Then part if it does not meet precondition temperature <= 18ÂșC, since its relationship with the precondition is an IF: { AND: [ 
 ]
{
  "if": {
    "and": [
      {
        "lessThanOrEquals": {
          "left": {
            "device": {
              "devices": [
                "16fa2ff4-00ca-4b65-b1db-5af142511d65"
              ],
              "component": "main",
              "capability": "temperatureMeasurement",
              "attribute": "temperature",
              "trigger": "Never"
            },
            "type": "device"
          },
          "right": {
            "decimal": 18,
            "type": "decimal"
          },
          "changesOnly": false
        },
        "type": "lessThanOrEquals"
      },
      {
        "or": [
          {
            "equals": {
              "left": {
                "device": {
                  "devices": [
                    "01caa709-9547-4bd2-b833-1aedeaa57d8d"
                  ],
                  "component": "main",
                  "capability": "switch",
                  "attribute": "switch",
                  "trigger": "Always"
                },
                "type": "device"
              },
              "right": {
                "string": "on",
                "type": "string"
              },
              "changesOnly": false
            },
            "type": "equals"
          },
          {
            "equals": {
              "left": {
                "device": {
                  "devices": [
                    "1d33051b-2218-4f82-a81b-911d6a46c9a9"
                  ],
                  "component": "main",
                  "capability": "switch",
                  "attribute": "switch",
                  "trigger": "Always"
                },
                "type": "device"
              },
              "right": {
                "string": "on",
                "type": "string"
              },
              "changesOnly": false
            },
            "type": "equals"
          }
        ],
        "type": "or"
      }
    ],
    "type": "and",
    "then": [
      {
        "notification": {
          "push": {
            "title": "Termostato, Temperatura: entre 18°C y 22°c",
            "message": "Temperature interval 18° to 22°"
          },
          "type": "push"
        },
        "type": "notification"
      }
    ],
    "sequence": {
      "then": "Parallel",
      "else": "Parallel"
    }
  },
  "type": "if"
}

So this is how it should be done also for preconditions with intervals of values and combined with other OR conditions to works fine.

Hi @nayelyz

Please, could you ask again tomorrow, Monday, about this error in the construction of routines that have an interval of values as a precondition and two or more OR conditions?

It is clear that the construction of the JSON has an error by putting the entire If part inside an OR condition.
This only happens when using a range of values as a precondition, if you use another condition the JSON is built and works fine.

I’m on it, I’ll let you know the updates as soon as the team shares them with me

Hi, @Mariano_Colmenarejo

This is expected behavior, both items in the OR section act as triggers, however, the routine will only process fully if the precondition is met which is checked during execution

Following up, here’s the feedback from the team

This is not how it works. The precondition will not act as some sort of blocker to a device triggering the routine, however, it will prevent the routine from running as it’s checked (This means it won’t execute the “then” section).
If it’s triggering in your case, the team needs to make a further analysis of that specific routine, for that, they need the following:

  1. Support access to your account
  2. The name of the routine to look for it
  3. Last time it was executed but the conditions weren’t met properly. Eg. 15:00 DST

Thank you for your effort @nayelyz

Please tell them to be a little more serious, we’re not that stupid and we don’t like to be treated as such.

Have they bothered to test the routine to see what is triggered even if the precondition is not met?

If they had tried it, they wouldn’t say such nonsense!

I don’t know why we bothered to report anything, it’s a pity!

If that’s how smartthings say
the routine has to work, leave it like that!!!

I don’t use it at all, it’s other users who complained. So whoever needs it, open a report.

4 Likes

@nayelyz

I don’t use ‘Likes’, but I totally agree with @Mariano_Colmenarejo there. He’s discovered a problem, isolated the conditions under which it occurs, diagnosed what the problem actually is, and basically handed it over gift-wrapped. And for his trouble he is basically being told they aren’t interested because he didn’t tie a bow on it.

3 Likes

The team shared new comments about this, they did make tests with a similar configuration to yours:

We understand your frustration and we can create a report for the team that handles the app.

2 Likes

I really don’t think there is any room for interpretation. If we add a precondition we do it because we expect it to achieve something, not for decoration.

If a Routine that allows a precondition that can’t possibly do anything is working as designed then I suggest the design sucks.

Yes, I’ve been saying for years how nice it would be to be able to use the public API for everything.

3 Likes

Wow! This is such a weird thread, given all the inconsistencies in edge development and lack of design documentation, suddenly everyone is getting excited!!!

So strange


Thanks to @nayelyz who does a great job in difficult circumstances

4 Likes

Hi @nayelyz

In the previous posts, I think it’s quite clear that routines with a different precondition than an interval check work perfectly and the json created is understandable and perfectly represents the operation of the routine created in the app by user

For the intervals in a precondition they just have to implement the same structure in the created json:

  1. An “and” condition with “trigger”: “Never” for the interval check.(precondition)
  2. An “or” condition with “trigger”: “Always” for the all trigger conditions.

I put back the json, from @TAustin API Browser+ menu Automations, Routines, Details, of a routine with precondition <= 18° and two OR conditions that works perfectly

{
  "if": {
    "and": [
      {
        "lessThanOrEquals": {
          "left": {
            "device": {
              "devices": [
                "16fa2ff4-00ca-4b65-b1db-5af142511d65"
              ],
              "component": "main",
              "capability": "temperatureMeasurement",
              "attribute": "temperature",
              "trigger": "Never"
            },
            "type": "device"
          },
          "right": {
            "decimal": 18,
            "type": "decimal"
          },
          "changesOnly": false
        },
        "type": "lessThanOrEquals"
      },
      {
        "or": [
          {
            "equals": {
              "left": {
                "device": {
                  "devices": [
                    "01caa709-9547-4bd2-b833-1aedeaa57d8d"
                  ],
                  "component": "main",
                  "capability": "switch",
                  "attribute": "switch",
                  "trigger": "Always"
                },
                "type": "device"
              },
              "right": {
                "string": "on",
                "type": "string"
              },
              "changesOnly": false
            },
            "type": "equals"
          },
          {
            "equals": {
              "left": {
                "device": {
                  "devices": [
                    "1d33051b-2218-4f82-a81b-911d6a46c9a9"
                  ],
                  "component": "main",
                  "capability": "switch",
                  "attribute": "switch",
                  "trigger": "Always"
                },
                "type": "device"
              },
              "right": {
                "string": "on",
                "type": "string"
              },
              "changesOnly": false
            },
            "type": "equals"
          }
        ],
        "type": "or"
      }
    ],
    "type": "and",
    "then": [
      {
        "notification": {
          "push": {
            "title": "Termostato, Temperatura: entre 18°C y 22°c",
            "message": "Temperature interval 18° to 22°"
          },
          "type": "push"
        },
        "type": "notification"
      }
    ],
    "sequence": {
      "then": "Parallel",
      "else": "Parallel"
    }
  },
  "type": "if"
}

Thanks again

1 Like

Hi @AlejandroPadilla

I see that Nayely says to contact you.

Do you know if there is anything new on this topic?

It is still impossible to make routines with preconditions that have an interval and others OR conditions.
Simple OR conditions behave, without precondition

Thank you

Hi @Mariano_Colmenarejo yes, @nayelyz will be off for a while.

Let me catch up with this case and check for updates, so please give me some time to do it.

1 Like

Hola @nayelyz, @AlejandroPadilla

This issue still does not work and prevents doing certain types of routines with intervals as a precondition.

Now that my.smartthings.com advanced users shows the routines how they are actually executed, I am going to explain it again by comparing how the routines look in the APP and how they look in my.smartthings.com, advanced users, what is going on to execute.

- This is a routine that works well. It has a precondition that compares a temperature if it is greater than or equal to 25ÂșC and two others OR conditions:
View in App:

View on my.smartthings.com

- This is a malfunctioning routine. It has a precondition that compares a temperature interval 25ÂșC to 27ÂșC and two OR conditions:
View in App:

View on my.smartthings.com

It is clear that the conversion that the Rules engine makes from routines to executable code is incorrect when uses intervals conditions

The precondition disappears and behaves like three simple OR conditions

Thanks

7 Likes

Hi, @Mariano_Colmenarejo.

I added this information to the report, it is very useful, thank you for taking the time to collect it.
We’ll ping the team again to see if they have any feedback about this and let you know.

5 Likes

Hi, @Mariano_Colmenarejo
Just following up, the engineering team found the bug in the Android app, in iOS, there are no issues with range preconditions + OR conditions. So, once the new version of the app gets released (there is no ETA available yet), you’ll have to re-create the routine so it gets translated correctly.

2 Likes