HTTP request og Response mapping

Jeg holder på med en Panasonic Comfort Cloud virtuell termostat, men sliter litt med å behandle responsen.

Jeg bruker responsemapping, men det er en av disse variablene jeg må utføre en Map på (f.eks. 0 = Auto), samtidig vil jeg ta vare på temperaturen og eventuell andre verdier.

Disse to resultatene skal til slutt havne i en template

 {
    "temp": "{{ variable "device_temp" false }}",
    "type": "{{ variable "device_mode_index_but_mapped" false }}",
    "unit": "C"
}

Hvordan få til det på en vettug måte? Hvis jeg legger til en “Transform” med Map så er det vel kun 1 av variablene jeg får mappet?

For oversikten sin del, så ser min Flow slik ut, hvor responsemappingen fra Panasonic Comfort Cloud gjøres i den røde sirkelen.

Der har jeg da to variabler; device_temp(string) og device_mode_index(int). Jeg ønsker å konvertere device_mode_index(int) til en string før jeg lager en template av den og sender en setpoint-Action.

That looks correct. Do you want to convert int -> string for using in template or for something else? Int can be used in templates the same way as strings .

What I really want is to set these two variables (temp and mode) that I’ll get from the HTTP request. The transformation will only read the mode but I haven’t figured that out yet, since “Left variable” device_mode_index doesn’t exist? It only exists as a {{ variable "device_mode_index" false}}, right?`

I’m getting this error for the Transform Map routine;

Executing Node.Name = transform device_mode_index
info fnode Transform type = map
warning fnode Error 2 : Not Found
error flow Node executed with error . Doing error transition to 28. Error : Not Found

My transform is like this;

    {
      "Id": "29",
      "Type": "transform",
      "Label": "transform device_mode_index",
      "SuccessTransition": "28",
      "TimeoutTransition": "",
      "ErrorTransition": "28",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "",
        "IsLVariableGlobal": false,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "LVariableName": "device_mode_index",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "{{ variable \"device_mode_index\" false}}",
        "Rtype": "var",
        "TargetVariableName": "device_mode",
        "TargetVariableType": "string",
        "Template": "",
        "TransformType": "map",
        "ValueMapping": [
          {
            "LValue": {
              "Value": 0,
              "ValueType": "int"
            },
            "RValue": {
              "Value": "auto",
              "ValueType": "string"
            }
          },
          {
            "LValue": {
              "Value": 1,
              "ValueType": "int"
            },
            "RValue": {
              "Value": "dry",
              "ValueType": "string"
            }
          },
          {
            "LValue": {
              "Value": 2,
              "ValueType": "int"
            },
            "RValue": {
              "Value": "cool",
              "ValueType": "string"
            }
          },
          {
            "LValue": {
              "Value": 3,
              "ValueType": "int"
            },
            "RValue": {
              "Value": "heat",
              "ValueType": "string"
            }
          },
          {
            "LValue": {
              "Value": 4,
              "ValueType": "int"
            },
            "RValue": {
              "Value": "fan",
              "ValueType": "string"
            }
          }
        ],
        "XPathMapping": [
          {
            "IsTargetVariableGlobal": false,
            "Path": "",
            "TargetVariableName": "",
            "TargetVariableType": "",
            "UpdateInputVariable": false
          }
        ]
      },
      "Ui": {
        "nodeType": "",
        "x": 1783,
        "y": 1207
      },
      "TypeAlias": "Transform"
    }

Looks like it can’t find device_mode_index ?

Looks like I made it when I removed the RVariableName. Good good.

Most of it works now, only missing the set routines and some cleanups for the temperature from the App vs the temperature from the air conditioner.

Is Air Conditioner supported? My virtual device is exposing service fan_ctrl, sensor_temp and thermostat but I’m unable to set the mode and fanspeed from the app. Only temperature is possible.