MIN HAN KODE
Jeg leser av W i venstre streng , setter variabel W , transformerer w til kW , Transformerer med enkelt filter for ikke å se peaker fra bla induksjonskomfyr, regner på desimaler , teller opp Målinger pr time (MID), summerer målinger pr time, og regner ut ett timesestimat i p1,p2,p3 basert på forrige times forbruk og målepunkter.
Som kuriosa kan nevnes at at om det hadde vært like mange målinger pr minutt fra HAN hadde faktor skulle vært 1. nå er den mello 0.8 og 1.2 , så snntidsprogramering er litt en utfordring når delta T er variabel. Men det er neglisjerbart for alle formål.
Så i Høyre streng gjør jeg noe av det samme med kWh avlesning .
Viktig å merke seg at MID og integral , med flere settes til null i en annen flow , som kjører en gang i timen .
{
"Id": "4b20ee00-5638-11ed-90a6-71cc296c8b9f",
"ClassId": "4b20ee00-5638-11ed-90a6-71cc296c8b9f",
"Author": "hytta@okbase.com",
"Version": 0,
"CreatedAt": "2022-10-27T20:45:29.696193Z",
"UpdatedAt": "2022-11-16T22:17:32.990298573+01:00",
"Name": "HAN",
"Group": "sensor_wattage",
"Description": "",
"Nodes": [
{
"Id": "58",
"Type": "trigger",
"Label": "Watt",
"SuccessTransition": "62",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "pt:j1/mt:evt/rt:dev/rn:zigbee/ad:1/sv:meter_elec/ad:12_2",
"Service": "meter_elec",
"ServiceInterface": "evt.meter.report",
"Config": {
"InputVariableType": null,
"IsValueFilterEnabled": false,
"LookupServiceNameAndLocation": false,
"PropFilterName": "unit",
"PropFilterValue": "W",
"RegisterAsVirtualService": false,
"Timeout": 0,
"ValueFilter": {
"Value": 0,
"ValueType": "float"
},
"ValueJPath": null,
"ValueJPathResultType": null,
"VirtualServiceGroup": "ch_0",
"VirtualServiceProps": {}
},
"Ui": {
"nodeType": "",
"papp": {
"customValues": null,
"nodeId": "16",
"nodeName": "wattage",
"nodeType": "wattage"
},
"x": 163,
"y": 203
},
"TypeAlias": "Trigger",
"LastValue": "1142 W"
},
{
"Id": "62",
"Type": "set_variable",
"Label": "W",
"SuccessTransition": "93",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"DefaultValue": {
"Value": 0,
"ValueType": ""
},
"IsVariableInMemory": false,
"Name": "W",
"UpdateGlobal": true,
"UpdateInputMsg": false
},
"Ui": {
"nodeType": "",
"x": 159,
"y": 395
},
"TypeAlias": "Set variable"
},
{
"Id": "68",
"Type": "transform",
"Label": "Filter",
"SuccessTransition": "70",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "kW*0.05+kWglatt*0.95",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kW",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "kWglatt",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 154,
"y": 741
},
"TypeAlias": "Transform"
},
{
"Id": "70",
"Type": "transform",
"Label": "desimaler",
"SuccessTransition": "71",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "((kWglatt * 100) - ( (kWglatt * 100) % 1 ) ) / 100",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kWglatt",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "kWglatt",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 154,
"y": 919
},
"TypeAlias": "Transform"
},
{
"Id": "71",
"Type": "transform",
"Label": "MID",
"SuccessTransition": "87",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "MID+1",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "MID",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "MID",
"TargetVariableType": "int",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 147,
"y": 1102
},
"TypeAlias": "Transform"
},
{
"Id": "80",
"Type": "trigger",
"Label": "kWh",
"SuccessTransition": "82",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "pt:j1/mt:evt/rt:dev/rn:zigbee/ad:1/sv:meter_elec/ad:12_2",
"Service": "meter_elec",
"ServiceInterface": "evt.meter.report",
"Config": {
"InputVariableType": null,
"IsValueFilterEnabled": false,
"LookupServiceNameAndLocation": false,
"PropFilterName": "unit",
"PropFilterValue": "kWh",
"RegisterAsVirtualService": false,
"Timeout": 0,
"ValueFilter": {
"Value": "kWh",
"ValueType": "float"
},
"ValueJPath": null,
"ValueJPathResultType": null,
"VirtualServiceGroup": "ch_0",
"VirtualServiceProps": {}
},
"Ui": {
"nodeType": "",
"x": 677,
"y": 213
},
"TypeAlias": "Trigger",
"LastValue": "1142 W"
},
{
"Id": "81",
"Type": "set_variable",
"Label": "kWh",
"SuccessTransition": "85",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"DefaultValue": {
"Value": 0,
"ValueType": ""
},
"IsVariableInMemory": false,
"Name": "kWh",
"UpdateGlobal": true,
"UpdateInputMsg": false
},
"Ui": {
"nodeType": "",
"papp": {
"customValues": null,
"nodeId": "16",
"nodeName": "wattage",
"nodeType": "wattage"
},
"x": 701,
"y": 923
},
"TypeAlias": "Set variable"
},
{
"Id": "82",
"Type": "set_variable",
"Label": "KWH_Temp",
"SuccessTransition": "84",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"DefaultValue": {
"Value": 0,
"ValueType": ""
},
"IsVariableInMemory": false,
"Name": "kWh_Temp",
"UpdateGlobal": true,
"UpdateInputMsg": false
},
"Ui": {
"nodeType": "",
"x": 682,
"y": 391
},
"TypeAlias": "Set variable"
},
{
"Id": "83",
"Type": "if",
"Label": "change",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": [
{
"BooleanOperator": "",
"LeftVariableIsGlobal": true,
"LeftVariableName": "kWh_Temp",
"Operand": "gt",
"RightVariable": {
"Value": 0,
"ValueType": "float"
}
}
],
"FalseTransition": "",
"TrueTransition": "81"
},
"Ui": {
"nodeType": "",
"x": 681,
"y": 748
},
"TypeAlias": "If condition"
},
{
"Id": "84",
"Type": "transform",
"Label": "KWH fra temp",
"SuccessTransition": "83",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "kWh_Temp - kWh",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kWh",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "kWh_Temp",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 680,
"y": 569
},
"TypeAlias": "Transform"
},
{
"Id": "85",
"Type": "transform",
"Label": "kWh_LastHour",
"SuccessTransition": "86",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "kWh_Temp - kWh_LastHour",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kWh_Temp",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "kWh_LastHour",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 713,
"y": 1100
},
"TypeAlias": "Transform"
},
{
"Id": "86",
"Type": "transform",
"Label": "kWh_LastHour",
"SuccessTransition": "88",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "kWh_Temp",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kWh_Temp",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "kWh_LastHour",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 721,
"y": 1255
},
"TypeAlias": "Transform"
},
{
"Id": "87",
"Type": "transform",
"Label": "WIntegral",
"SuccessTransition": "90",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "WIntegral + kW ",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kW",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "WIntegral",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 136,
"y": 1266
},
"TypeAlias": "Transform"
},
{
"Id": "88",
"Type": "transform",
"Label": "Faktor",
"SuccessTransition": "94",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "kWh_LastHour / (WIntegral / MID )",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "kWh_LastHour",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "Faktor",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 748,
"y": 1419
},
"TypeAlias": "Transform"
},
{
"Id": "90",
"Type": "transform",
"Label": "Estimate p1",
"SuccessTransition": "91",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "WIntegral ",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "WIntegral",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "Estimate",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 129,
"y": 1426
},
"TypeAlias": "Transform"
},
{
"Id": "91",
"Type": "transform",
"Label": "Estimate p2",
"SuccessTransition": "92",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "Estimate / MID ",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "MID",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "Estimate",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 135,
"y": 1575
},
"TypeAlias": "Transform"
},
{
"Id": "92",
"Type": "transform",
"Label": "Estimate p3",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "Estimate * Faktor ",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "Faktor",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "Estimate",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 126,
"y": 1740
},
"TypeAlias": "Transform"
},
{
"Id": "93",
"Type": "transform",
"Label": "kW = W /1000",
"SuccessTransition": "68",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "W / 1000.0",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "W",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "kW",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 146,
"y": 558
},
"TypeAlias": "Transform"
},
{
"Id": "94",
"Type": "transform",
"Label": "Calculate MID til 0",
"SuccessTransition": "95",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "MID - MID +1 ",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "MID",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "MID",
"TargetVariableType": "int",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 739,
"y": 1596
},
"TypeAlias": "Transform"
},
{
"Id": "95",
"Type": "transform",
"Label": "Null integral",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": "WIntegral - WIntegral",
"IsLVariableGlobal": true,
"IsRVariableGlobal": false,
"IsTargetVariableGlobal": true,
"IsTargetVariableInMemory": false,
"LVariableName": "WIntegral",
"RValue": {
"Value": 0,
"ValueType": "int"
},
"RVariableName": "",
"Rtype": "var",
"TargetVariableName": "WIntegral",
"TargetVariableType": "float",
"Template": "",
"TransformType": "calc",
"ValueMapping": [],
"XPathMapping": []
},
"Ui": {
"nodeType": "",
"x": 621,
"y": 1776
},
"TypeAlias": "Transform"
}
],
"Settings": null,
"IsDisabled": false,
"IsDefault": false,
"ParallelExecution": "keep_last"
}type or paste code here
```https://forum.futurehome.io/t/best-practice-development/3931/3