Forbruk over tid

Er det mulig å trigge på forbruk over tid? Eksempelvis om det har gått over 5kWh i mer en 10 minutter?

Holder på å forberede meg til effekttariffen gjør sitt inntog over nyttår, slik at jeg setter ned temperaturen på unødvendige varmekilder om forbruket er høyt (noen varmekabler som magasinerer bra, samt ovn på vaskerom og andre rom der vi ikke har opphold).

Den flowen jeg har laget nå fungerer bra, men den trigger det sekundet den er over 5kWh. Hadde vært greit at den heller trigget når det var høyt forbruk over tid.

Noen gode tips? Eller noen som alt har laget noe tilsvarende?

2 Likes

I guess the intent is to turn off certain devices if total power consumption (from AMS meter) is over 5kW stays over X min? 5 kW, not 5 kWh, right?

It is possible and there is even more than one option, most elegant is to “ask” these questions periodically (on a timer) to ecollector (historian) service, something like - “give me an average/mean power for the last X min” and if the result exceeds the limit, execute turn off commands. If the value goes back to normal, send reverse commands.

I will share examples shortly.

Uten å være sikker på at det er den beste løsningen så tenker jeg, hvis totalforbruk overskrider 5kW, sett variabel 1, vent 10min, hvis totalforbruk fortsatt er over 5kW, sett variabel 2.
Så.
Hvis variabel 1 og 2 er TRUE; sett net/slå av termostater etc

Så enten samme fremgangsmåte for totalforbruk under 5kW, eller rett tilbake til normal når totalforruket er under 5kW

1 Like

Here is the example, it gets average power usage for the last 10 min every 10min, compares the result against set threshold, and also filters time against peak hours (just an example). HAN device id is configurable via flow settings

{
  "Id": "k9cdj1GKQm2cH9i",
  "ClassId": "k9cdj1GKQm2cH9i",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2021-11-20T23:36:39.530778611+01:00",
  "UpdatedAt": "2021-11-20T23:58:41.399312807+01:00",
  "Name": "Total power monitor",
  "Group": "energy",
  "Description": "Continuously monitors power usage. ",
  "Nodes": [
    {
      "Id": "1",
      "Type": "trigger",
      "Label": "Test trigger",
      "SuccessTransition": "4",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:flow/ad:1/sv:out_bin_switch/ad:k9cdj1GKQm2cH9i_0",
      "Service": "out_bin_switch",
      "ServiceInterface": "cmd.binary.set",
      "Config": {
        "ConnectorID": "",
        "InputVariableType": "",
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "PropFilterName": "",
        "PropFilterValue": "",
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": null,
          "ValueType": "bool"
        },
        "ValueJPath": "",
        "ValueJPathResultType": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": null
      },
      "Ui": {
        "nodeType": "",
        "x": 363,
        "y": 194
      },
      "TypeAlias": "Trigger",
      "LastValue": true
    },
    {
      "Id": "2",
      "Type": "time_trigger",
      "Label": "Every 10 min",
      "SuccessTransition": "4",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultMsg": {
          "Value": "",
          "ValueType": ""
        },
        "Expressions": [
          {
            "Comments": "",
            "Expression": "@every 10m",
            "Name": ""
          }
        ],
        "GenerateAstroTimeEvents": false,
        "Latitude": 0,
        "Longitude": 0,
        "SunriseTimeOffset": 0,
        "SunsetTimeOffset": 0
      },
      "Ui": {
        "nodeType": "",
        "x": 622,
        "y": 188
      },
      "TypeAlias": "Time trigger"
    },
    {
      "Id": "3",
      "Type": "action",
      "Label": "Query average power usage ",
      "SuccessTransition": "9",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:app/rn:ecollector/ad:1",
      "Service": "ecollector",
      "ServiceInterface": "cmd.tsdb.query",
      "Config": {
        "DefaultValue": {
          "Value": "",
          "ValueType": ""
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "pt:j1/mt:rsp/rt:app/rn:tpflow/ad:power_monitor",
        "VariableName": "power_query",
        "VariableType": "str_map",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 496,
        "y": 633
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "4",
      "Type": "transform",
      "Label": "Create power query",
      "SuccessTransition": "3",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "",
        "IsLVariableGlobal": false,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": true,
        "LVariableName": "",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "power_query",
        "TargetVariableType": "str_map",
        "Template": "{\n    \"proc_id\": \"1\",\n    \"query\":\"SELECT mean(\\\"value\\\") AS \\\"mean_value\\\" FROM \\\"gen_raw\\\".\\\"electricity_meter_power\\\" WHERE time > now()-10m AND \\\"dev_id\\\"='{{ setting \"han.dev_id\"  }}'\"\n}",
        "TransformType": "template",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 512,
        "y": 404
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "6",
      "Type": "transform",
      "Label": "Extract average power",
      "SuccessTransition": "11",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "",
        "IsLVariableGlobal": false,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": true,
        "LVariableName": "",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "",
        "TargetVariableType": "",
        "Template": "",
        "TransformType": "jpath",
        "ValueMapping": [],
        "XPathMapping": [
          {
            "IsTargetVariableGlobal": false,
            "IsTargetVariableInMemory": true,
            "Path": "$Results[0].Series[0].values[0][1]",
            "TargetVariableName": "average_power",
            "TargetVariableType": "float",
            "UpdateInputVariable": false
          }
        ]
      },
      "Ui": {
        "nodeType": "",
        "x": 479,
        "y": 1066
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "9",
      "Type": "receive",
      "Label": "Wait for power report",
      "Address": "pt:j1/mt:rsp/rt:app/rn:tpflow/ad:power_monitor",
      "Service": "ecollector",
      "ServiceInterface": "evt.tsdb.query_report",
      "SuccessTransition": "6",
      "ErrorTransition": "",
      "Config": {
        "Timeout": 120,
        "VirtualServiceGroup": "ch_0",
        "VirtualServiceProps": {},
        "RegisterAsVirtualService": false,
        "LookupServiceNameAndLocation": false,
        "ValueFilter": {
          "Value": "",
          "ValueType": "bool"
        },
        "IsValueFilterEnabled": false
      },
      "Ui": {
        "x": 491,
        "y": 841,
        "nodeType": ""
      },
      "TypeAlias": "Wait event"
    },
    {
      "Id": "11",
      "Type": "iftime",
      "Label": "Define peek hours",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "SuccessTransition": "13",
      "ErrorTransition": "",
      "Config": {
        "Expression": [
          {
            "Weekday": "1",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          },
          {
            "Weekday": "2",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          },
          {
            "Weekday": "3",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          },
          {
            "Weekday": "4",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          },
          {
            "Weekday": "5",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          },
          {
            "Weekday": "6",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          },
          {
            "Weekday": "0",
            "From": "00:00",
            "To": "23:59",
            "Action": "a"
          }
        ]
      },
      "Ui": {
        "x": 456,
        "y": 1260,
        "nodeType": ""
      },
      "TypeAlias": "Time filter"
    },
    {
      "Id": "12",
      "Type": "action",
      "Label": "High power usage during peek hour ",
      "Address": "pt:j1/mt:evt/rt:app/rn:kind_owl/ad:1",
      "Service": "kind-owl",
      "ServiceInterface": "evt.notification.report",
      "SuccessTransition": "",
      "ErrorTransition": "",
      "Config": {
        "VariableName": "",
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {},
        "DefaultValue": {
          "Value": {
            "EventName": "custom",
            "MessageContent": "Reduce power usage",
            "SiteId": ""
          },
          "ValueType": "object"
        }
      },
      "Ui": {
        "x": 402,
        "y": 1664,
        "nodeType": "notification_action"
      },
      "TypeAlias": "Notification"
    },
    {
      "Id": "13",
      "Type": "if",
      "Label": "Set power limit",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "SuccessTransition": "",
      "ErrorTransition": "",
      "Config": {
        "TrueTransition": "12",
        "FalseTransition": "",
        "Expression": [
          {
            "Operand": "gt",
            "LeftVariableName": "average_power",
            "LeftVariableIsGlobal": false,
            "RightVariable": {
              "Value": 700,
              "ValueType": "float"
            },
            "BooleanOperator": ""
          }
        ]
      },
      "Ui": {
        "x": 425,
        "y": 1461,
        "nodeType": ""
      },
      "TypeAlias": "If condition"
    }
  ],
  "Settings": {
    "han.dev_id": {
      "Value": "100",
      "ValueType": "string",
      "Key": "han.dev_id",
      "Description": "Device Id of HAN adapter"
    }
  },
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "parallel"
}
2 Likes

Takk for fantastisk fine svar alle sammen, her er det nok mye jeg kan bruke!

2 Likes

I have tried your solution @alivinco And its working great.
I will implement this in my systwm and use it as a trigger to reduce temperature and turn off water heater when total power are high

1 Like

Anbefaler løsningen til Alivinco, funker som rakkern.
Så kan du bare legge på ulike actions i stedet for eller i tillegg til notification

Ja den var veldig fin, kommer til å lage noe med basis i denne. Mye bedre enn den løsningen jeg lagde selv. :joy:

1 Like

Eg slit litt med å få den til å ta HAN device ID. Kva la du inn der?

Først finner du ID til HAN ved å se på egenskaper på enheten i App.

Så legger du inn ID ved å trykke på redigeringskbappen (blyanten) øverst i flowen i ThingsPlex



Takk til begge :slight_smile:

Hei, Jeg har lekt litt med flowen her. Ønsker å sende med avlest verdi i Notification, men får ikke det til. Hvordan kan jeg legge med verdi av variablen average_power i Notification eller Timeline.

MVH
Are