Stegvis neddimming

Hei.

Planen er å dimme ned lyset på kvelden stegvis over tid.
For å oppnå dette hadde jeg en plan om å hente nåverdi fra et lys, sette variabel, dimme lys, trekke fra feks 5 fra variabel, vente 3 sek også kjøre loop, dette fungerer ikke helt.

Noen kloke hoder som ser hva som blir feil?

{
  "Id": "CuMpCx5GmRPAdlO",
  "ClassId": "CuMpCx5GmRPAdlO",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2020-11-21T22:17:55.288598648+01:00",
  "UpdatedAt": "2020-11-21T22:53:28.674374114+01:00",
  "Name": "Dimme lys",
  "Group": "",
  "Description": "Dimme lys kveld",
  "Nodes": [
    {
      "Id": "2",
      "Type": "vinc_trigger",
      "Label": "Home event trigger",
      "SuccessTransition": "9",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "EventType": "mode",
        "IsValueFilterEnabled": false,
        "Timeout": 0,
        "ValueFilter": "home"
      },
      "Ui": {
        "nodeType": "",
        "x": 595,
        "y": 220
      },
      "TypeAlias": "Home event"
    },
    {
      "Id": "4",
      "Type": "action",
      "Label": "set lys",
      "SuccessTransition": "11",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:basic/ad:7_0",
      "Service": "basic",
      "ServiceInterface": "cmd.lvl.set",
      "Config": {
        "DefaultValue": {
          "Value": null,
          "ValueType": ""
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "light_level",
        "VariableType": "int",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 592,
        "y": 808
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "6",
      "Type": "wait",
      "Label": "Vent 2 sek",
      "SuccessTransition": "4",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": 2000,
      "Ui": {
        "nodeType": "",
        "x": 596,
        "y": 644
      },
      "TypeAlias": "Delay"
    },
    {
      "Id": "9",
      "Type": "set_variable",
      "Label": "set 50%(inntil videre)",
      "SuccessTransition": "6",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": "50",
          "ValueType": "int"
        },
        "Name": "light_level",
        "UpdateGlobal": false,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 617,
        "y": 414
      },
      "TypeAlias": "Set variable"
    },
    {
      "Id": "10",
      "Type": "transform",
      "Label": "trekke fra 10",
      "SuccessTransition": "6",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "(light_level-10)",
        "IsLVariableGlobal": false,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "LVariableName": "light_level",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "light_level",
        "TargetVariableType": "int",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 292,
        "y": 681
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "11",
      "Type": "if",
      "Label": "",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "light_level",
            "Operand": "lt",
            "RightVariable": {
              "Value": 0,
              "ValueType": "int"
            }
          }
        ],
        "FalseTransition": "10",
        "TrueTransition": ""
      },
      "Ui": {
        "nodeType": "",
        "x": 309,
        "y": 897
      },
      "TypeAlias": "If condition"
    }
  ],
  "Settings": null,
  "IsDisabled": true,
  "IsDefault": false,
  "ParallelExecution": "parallel"
}

I spotted something here :

{
      "Id": "9",
      "Type": "set_variable",
      "Label": "set 50%(inntil videre)",
      "SuccessTransition": "6",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": "50",
          "ValueType": "int"
        },
        "Name": "light_level",
        "UpdateGlobal": false,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 617,
        "y": 414
      },
      "TypeAlias": "Set variable"
    }

The line "Value": "50" - change it to "Value": 50, and it should work . The final node should be :

{
      "Id": "9",
      "Type": "set_variable",
      "Label": "set 50%(inntil videre)",
      "SuccessTransition": "6",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": 50,
          "ValueType": "int"
        },
        "Name": "light_level",
        "UpdateGlobal": false,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 617,
        "y": 414
      },
      "TypeAlias": "Set variable"
    }

I will check if it’s a bug in Thingsplex UI that generated the code or something else.

Hi.

The problem is that the code run only once, so I am able to set the variable, set output, wait 10 sec, subtract 10 from value and set new value, and then it stops there after running 1 time.
Would like it to run in a loop to the value is 0 (therefore the if node).

Is there a reason for why the instance only run once?

Also, I can see from the log that it`s running multiple times. But it only subtracts the value from variable one time?

020-12-07 20:59:21.383 info fnode Executing Node . Name = trekke fra 10
2020-12-07 20:59:21.383 info fnode Transform type = calc
2020-12-07 20:59:21.391 info fnode Executing Node . Name = Set lys
2020-12-07 20:59:25.398 info fnode Executing Node . Name = trekke fra 10
2020-12-07 20:59:25.398 info fnode Transform type = calc
2020-12-07 20:59:25.408 info fnode Executing Node . Name = Set lys
2020-12-07 20:59:29.41 info fnode Executing Node . Name = trekke fra 10
2020-12-07 20:59:29.411 info fnode Transform type = calc

Current code

{
  "Id": "CuMpCx5GmRPAdlO",
  "ClassId": "CuMpCx5GmRPAdlO",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2020-11-21T22:17:55.288598648+01:00",
  "UpdatedAt": "2020-12-07T20:23:33.01189251+01:00",
  "Name": "Dimme lys",
  "Group": "",
  "Description": "Dimme lys kveld",
  "Nodes": [
    {
      "Id": "2",
      "Type": "vinc_trigger",
      "Label": "Home event trigger",
      "SuccessTransition": "9",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "EventType": "shortcut",
        "IsValueFilterEnabled": false,
        "Timeout": 0,
        "ValueFilter": "3"
      },
      "Ui": {
        "nodeType": "",
        "x": 595,
        "y": 220
      },
      "TypeAlias": "Home event"
    },
    {
      "Id": "6",
      "Type": "wait",
      "Label": "wait 10 sec",
      "SuccessTransition": "13",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": 4000,
      "Ui": {
        "nodeType": "",
        "x": 575,
        "y": 911
      },
      "TypeAlias": "Delay"
    },
    {
      "Id": "9",
      "Type": "set_variable",
      "Label": "set 70%",
      "SuccessTransition": "12",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": 70,
          "ValueType": "int"
        },
        "Name": "light_level",
        "UpdateGlobal": false,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 577,
        "y": 407
      },
      "TypeAlias": "Set variable"
    },
    {
      "Id": "10",
      "Type": "transform",
      "Label": "trekke fra 10",
      "SuccessTransition": "12",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "light_level-10",
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "LVariableName": "",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "light_level",
        "TargetVariableType": "int",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 332,
        "y": 663
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "12",
      "Type": "action",
      "Label": "Set lys",
      "SuccessTransition": "6",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_lvl_switch/ad:7_0",
      "Service": "out_lvl_switch",
      "ServiceInterface": "cmd.lvl.set",
      "Config": {
        "DefaultValue": {
          "Value": "",
          "ValueType": "int"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "light_level",
        "VariableType": "int",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 591,
        "y": 662
      },
      "TypeAlias": "Action",
      "LastValue": 60
    },
    {
      "Id": "13",
      "Type": "if",
      "Label": "",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "light_level",
            "Operand": "gt",
            "RightVariable": {
              "Value": 0,
              "ValueType": "int"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "10"
      },
      "Ui": {
        "nodeType": "",
        "x": 307,
        "y": 896
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "15",
      "Type": "vinc_trigger",
      "Label": "Home event trigger",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "SuccessTransition": "16",
      "ErrorTransition": "",
      "Config": {
        "Timeout": 0,
        "ValueFilter": "3",
        "IsValueFilterEnabled": false,
        "EventType": "shortcut"
      },
      "Ui": {
        "x": 958,
        "y": 204,
        "nodeType": ""
      },
      "TypeAlias": "Home event"
    },
    {
      "Id": "16",
      "Type": "action",
      "Label": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:zigbee/ad:1/sv:out_lvl_switch/ad:12_1",
      "Service": "out_lvl_switch",
      "ServiceInterface": "cmd.lvl.get_report",
      "SuccessTransition": "17",
      "ErrorTransition": "",
      "Config": {
        "VariableName": "",
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {},
        "ResponseToTopic": "",
        "DefaultValue": {
          "Value": "",
          "ValueType": "null"
        }
      },
      "Ui": {
        "x": 960,
        "y": 441,
        "nodeType": ""
      },
      "TypeAlias": "Action",
      "LastValue": "3"
    },
    {
      "Id": "17",
      "Type": "set_variable",
      "Label": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "SuccessTransition": "",
      "ErrorTransition": "",
      "Config": {
        "Name": "start_value",
        "UpdateGlobal": false,
        "UpdateInputMsg": false,
        "DefaultValue": {
          "Value": 0,
          "ValueType": ""
        }
      },
      "Ui": {
        "x": 957,
        "y": 685,
        "nodeType": ""
      },
      "TypeAlias": "Set variable"
    }
  ],
  "Settings": null,
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "parallel"
}```