If value changes by x or % or range to trigger routine

This.

The generated JSON Rule for the test I did the other day, a brightness Range between 40% and 60%, looks like this:

    "if": {
      "between": {
        "value": {
          "device": {
            "devices": [
              "c7808b59-76c9-42b7-9053-612203f769ae"
            ],
            "component": "main",
            "capability": "switchLevel",
            "attribute": "level",
            "trigger": "Always"
          },
          "type": "device"
        },
        "start": {
          "integer": 40,
          "type": "integer"
        },
        "end": {
          "integer": 60,
          "type": "integer"
        },
        "changesOnly": true
      },
      "type": "between",
      "then":

Mind the "changesOnly": true, in other words, it will only trigger when the condition changes from false to true. Once inside the range, the condition doesn’t change, it’s still true. For it to trigger again it has to evaluate to false (going outside the range) and then evaluate to true (going inside again).

Looks like the Rules API supports both ways to handle the ranges depending on how you write the rule, as a “don’t trigger again while in the range” or “trigger for every value in the range”.

I’ve just tested it, if you remove the "changesOnly": true then the range will trigger for every value change that falls into the range, without needing to go outside the range and re-enter. So you have the choice of what behaviour you want when using Rules API. If you use the app, the behaviour is not retriggering again while in the range.

Again, I don’t use ranges in my day to day so I can’t tell about the reliability, but the feature is there and should execute locally too.

2 Likes