FH vs Tibber: Automatisering av klima og strøm

Jeg har en flow for dette i Thingsplex.
Står noe om denne og en mulig forbedring her: Hente inn pris og prisdato fra tibber til en map of floats (eller Object)

Se koden jeg bruker nedenfor.

{
  "Id": "6CSKL7ssAXI3pOP",
  "ClassId": "hf1Ysemo50f5Fam",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2021-08-23T22:02:03.755877004+02:00",
  "UpdatedAt": "2021-11-28T00:19:23.01432227+01:00",
  "Name": "Tibber: Hente prisinfo, hver time",
  "Group": "variables",
  "Description": "Kaller Tibber API og henter stømpris og prisnivå hver hele time.",
  "Nodes": [
    {
      "Id": "1",
      "Type": "time_trigger",
      "Label": "1min past each our",
      "SuccessTransition": "2",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultMsg": {
          "Value": "",
          "ValueType": ""
        },
        "Expressions": [
          {
            "Comment": "1 * * * *",
            "Comments": "",
            "Expression": "1 * * * *",
            "Name": ""
          }
        ],
        "GenerateAstroTimeEvents": false,
        "Latitude": 0,
        "Longitude": 0,
        "SunriseTimeOffset": 0,
        "SunsetTimeOffset": 0
      },
      "Ui": {
        "nodeType": "",
        "x": 43,
        "y": 226
      },
      "TypeAlias": "Time trigger"
    },
    {
      "Id": "2",
      "Type": "rest_action",
      "Label": "Get Energy Price Level from Tibber",
      "SuccessTransition": "25",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Auth": {
          "ClientID": "",
          "ClientSecret": "",
          "Enabled": false,
          "GrantType": "password",
          "Password": "",
          "Scope": "",
          "Url": "http://",
          "Username": ""
        },
        "Headers": [
          {
            "Name": "Content-type",
            "Value": "application/json"
          },
          {
            "Name": "Authorization",
            "Value": "TIBBER_TOKEN"
          }
        ],
        "LogResponse": true,
        "Method": "POST",
        "RequestPayloadType": "json",
        "RequestTemplate": "{ \"query\": \"{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt level}}}}}}\" }\n",
        "ResponseMapping": [
          {
            "IsVariableGlobal": true,
            "Name": "Level",
            "Path": "$.data.viewer.homes[0].currentSubscription.priceInfo.current.level",
            "PathType": "json",
            "TargetVariableName": "energy_level",
            "TargetVariableType": "string",
            "UpdateTriggerMessage": false
          }
        ],
        "Url": "https://api.tibber.com/v1-beta/gql"
      },
      "Ui": {
        "nodeType": "",
        "x": 109,
        "y": 417
      },
      "TypeAlias": "HTTP msg"
    },
    {
      "Id": "25",
      "Type": "transform",
      "Label": "transform tibber",
      "SuccessTransition": "26",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": true,
        "LVariableName": "energy_level",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "energylevel_output",
        "TargetVariableType": "str_map",
        "Template": "    {\n      \"message_en\": \"Tibber pricelevel is now: {{ .Variable }}\",\n      \"message_no\": \"Tibber prisnivå er nå: {{ .Variable }}\",\n      \"sender\": \"flow\"\n    }",
        "TransformType": "template",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 214,
        "y": 599
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "26",
      "Type": "action",
      "Label": "Publish timeline",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:app/rn:time_owl/ad:1",
      "Service": "time_owl",
      "ServiceInterface": "cmd.timeline.set",
      "Config": {
        "DefaultValue": {
          "Value": {
            "message_en": "--",
            "message_no": "--",
            "sender": "flow"
          },
          "ValueType": "str_map"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "VariableName": "energylevel_output",
        "VariableType": "str_map",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "timeline_action",
        "x": 305,
        "y": 812
      },
      "TypeAlias": "Timeline"
    },
    {
      "Id": "27",
      "Type": "time_trigger",
      "Label": "2min past each our",
      "SuccessTransition": "28",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultMsg": {
          "Value": "",
          "ValueType": ""
        },
        "Expressions": [
          {
            "Comment": "2 * * * *",
            "Comments": "",
            "Expression": "4 * * * *",
            "Name": ""
          }
        ],
        "GenerateAstroTimeEvents": false,
        "Latitude": 0,
        "Longitude": 0,
        "SunriseTimeOffset": 0,
        "SunsetTimeOffset": 0
      },
      "Ui": {
        "nodeType": "",
        "x": 375,
        "y": 239
      },
      "TypeAlias": "Time trigger"
    },
    {
      "Id": "28",
      "Type": "rest_action",
      "Label": "Get Energy Price from Tibber",
      "SuccessTransition": "31",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Auth": {
          "ClientID": "",
          "ClientSecret": "",
          "Enabled": false,
          "GrantType": "password",
          "Password": "",
          "Scope": "",
          "Url": "http://",
          "Username": ""
        },
        "Headers": [
          {
            "Name": "Content-type",
            "Value": "application/json"
          },
          {
            "Name": "Authorization",
            "Value": "TIBBER_TOKEN"
          }
        ],
        "LogResponse": true,
        "Method": "POST",
        "RequestPayloadType": "json",
        "RequestTemplate": "{ \"query\": \"{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt level}}}}}}\" }\n",
        "ResponseMapping": [
          {
            "IsVariableGlobal": true,
            "Name": "price_level",
            "Path": "$.data.viewer.homes[0].currentSubscription.priceInfo.current.total",
            "PathType": "json",
            "TargetVariableName": "price_level",
            "TargetVariableType": "float"
          }
        ],
        "Url": "https://api.tibber.com/v1-beta/gql"
      },
      "Ui": {
        "nodeType": "",
        "x": 417,
        "y": 427
      },
      "TypeAlias": "HTTP msg"
    },
    {
      "Id": "30",
      "Type": "action",
      "Label": "Publish timeline",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:app/rn:time_owl/ad:1",
      "Service": "time_owl",
      "ServiceInterface": "cmd.timeline.set",
      "Config": {
        "DefaultValue": {
          "Value": {
            "message_en": "--",
            "message_no": "--",
            "sender": "flow"
          },
          "ValueType": "str_map"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "VariableName": "energyprice_output",
        "VariableType": "string",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "timeline_action",
        "x": 584,
        "y": 815
      },
      "TypeAlias": "Timeline"
    },
    {
      "Id": "31",
      "Type": "transform",
      "Label": "transform tibber price",
      "SuccessTransition": "30",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": true,
        "LVariableName": "price_level",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "energyprice_output",
        "TargetVariableType": "str_map",
        "Template": "    {\n      \"message_en\": \"Tibber price is now: {{ .Variable }} NOK\",\n      \"message_no\": \"Tibber pris er nå: {{ .Variable }} NOK\",\n      \"sender\": \"flow\"\n    }",
        "TransformType": "template",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 486,
        "y": 601
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "34",
      "Type": "transform",
      "Label": "Write price request to Influx",
      "SuccessTransition": "35",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "",
        "IsLVariableGlobal": true,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": true,
        "LVariableName": "price_level",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "price_request_output",
        "TargetVariableType": "object",
        "Template": "{\n    \"proc_id\": 2,\n    \"bucket\": \"gen_default\",\n    \"dp\": [\n      {\n        \"name\": \"current_price\",\n        \"tags\": {},\n        \"fields\": {\n          \"val\": {{ .Variable }}\n        }\n      }\n    ]\n}",
        "TransformType": "template",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 758,
        "y": 511
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "35",
      "Type": "action",
      "Label": "Write price to Influx",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:app/rn:ecollector/ad:1",
      "Service": "ecollector",
      "ServiceInterface": "cmd.tsdb.write_data_points",
      "Config": {
        "DefaultValue": {
          "Value": "",
          "ValueType": "object"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "price_request_output",
        "VariableType": "object",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 837,
        "y": 820
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "36",
      "Type": "time_trigger",
      "Label": "Every 3 min past hour",
      "SuccessTransition": "34",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultMsg": {
          "Value": "",
          "ValueType": ""
        },
        "Expressions": [
          {
            "Comments": "",
            "Expression": "3 * * * *",
            "Name": ""
          }
        ],
        "GenerateAstroTimeEvents": false,
        "Latitude": 0,
        "Longitude": 0,
        "SunriseTimeOffset": 0,
        "SunsetTimeOffset": 0
      },
      "Ui": {
        "nodeType": "",
        "x": 660,
        "y": 237
      },
      "TypeAlias": "Time trigger"
    }
  ],
  "Settings": null,
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "parallel"
}
1 Like