Best Practice Development

MIN VV kode

Dette er koden for standard rele i pakken fra FH, som jeg bruker.
Fordi denne er stille til den blir spurt , har jeg først en time trigger som ber om rapport, og så en trigger som ber om verdier.

Her leser jeg av slik at min “en gang i timen rutine” finner ut om VV er mett …

KODE :

{
  "Id": "IVBI3zEMh2FwDGz",
  "ClassId": "IVBI3zEMh2FwDGz",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2022-11-08T13:21:35.065544508+01:00",
  "UpdatedAt": "2022-11-11T15:57:53.856610318+01:00",
  "Name": "Status VV",
  "Group": "",
  "Description": "",
  "Nodes": [
    {
      "Id": "1",
      "Type": "time_trigger",
      "Label": "",
      "SuccessTransition": "2",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultMsg": {
          "Value": "",
          "ValueType": ""
        },
        "Expressions": [
          {
            "Comments": "",
            "Expression": "@every 0h10m00s",
            "Name": ""
          }
        ],
        "GenerateAstroTimeEvents": false,
        "Latitude": 0,
        "Longitude": 0,
        "SunriseTimeOffset": 0,
        "SunsetTimeOffset": 0
      },
      "Ui": {
        "nodeType": "",
        "x": 16,
        "y": 212
      },
      "TypeAlias": "Time trigger"
    },
    {
      "Id": "2",
      "Type": "action",
      "Label": "",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:zigbee/ad:1/sv:meter_elec/ad:11_1",
      "Service": "meter_elec",
      "ServiceInterface": "cmd.meter.get_report",
      "Config": {
        "DefaultValue": {
          "Value": "",
          "ValueType": "string"
        },
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 19,
        "y": 367
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "3",
      "Type": "trigger",
      "Label": "Les VV",
      "SuccessTransition": "4",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:zigbee/ad:1/sv:meter_elec/ad:11_1",
      "Service": "meter_elec",
      "ServiceInterface": "evt.meter.report",
      "Config": {
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": "",
          "ValueType": "float"
        },
        "VirtualServiceGroup": "ch_0",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 284,
        "y": 213
      },
      "TypeAlias": "Trigger"
    },
    {
      "Id": "4",
      "Type": "set_variable",
      "Label": "PowerVV",
      "SuccessTransition": "8",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": 0,
          "ValueType": ""
        },
        "IsVariableInMemory": false,
        "Name": "PowerVV",
        "UpdateGlobal": true,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 275,
        "y": 402
      },
      "TypeAlias": "Set variable"
    },
    {
      "Id": "5",
      "Type": "transform",
      "Label": "VVTodayTotal",
      "SuccessTransition": "9",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "PowerVV - PowerVVLastDay",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": true,
        "IsTargetVariableInMemory": false,
        "LVariableName": "PowerVV",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "PowerVVToday",
        "TargetVariableType": "float",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 267,
        "y": 756
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "8",
      "Type": "transform",
      "Label": "VVON",
      "SuccessTransition": "5",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "(PowerVV - PowerVVToday - PowerVVLastDay)*6",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": true,
        "IsTargetVariableInMemory": false,
        "LVariableName": "PowerVV",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "PowerVVLastHour",
        "TargetVariableType": "float",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [
          {
            "LValue": {
              "Value": 0,
              "ValueType": "float"
            },
            "RValue": {
              "Value": 0,
              "ValueType": "int"
            }
          }
        ],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 272,
        "y": 575
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "9",
      "Type": "transform",
      "Label": "desimaler",
      "SuccessTransition": "10",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "((PowerVVToday*100)-(PowerVVToday*100)%1)/100",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": true,
        "IsTargetVariableInMemory": false,
        "LVariableName": "PowerVVToday",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "PowerVVToday",
        "TargetVariableType": "float",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 260,
        "y": 917
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "10",
      "Type": "transform",
      "Label": "desimaler",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "((PowerVVLastHour*100)-(PowerVVLastHour*100)%1)/100",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": true,
        "IsTargetVariableInMemory": false,
        "LVariableName": "PowerVVLastHour",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "PowerVVLastHour",
        "TargetVariableType": "float",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 256,
        "y": 1073
      },
      "TypeAlias": "Transform"
    }
  ],
  "Settings": null,
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "keep_last"
}type or paste code here