Looking for a way to control a virtual Contact from two temperature sensors

I love the way vEdge Creator allows us to control a Virtual Contact based on a fixed temperature.

Is there a way to control a Virtual Contact when one sensor’s temperature exceed another’s? To compare two sensor values?

I want an Alexa announcement when my porch temp drops below my inside temp, so I can open windows :grinning_face:

Yes it can done and I have exact same us. But the setup is quite complicated. It requires a special Edge Driver and the use of API rules to input the temperature data into the virtual device you create. The following is a link the Driver and set up instructions.

You can compare device attributes by using the ‘Rules API’ rather than the mobile app Routines. There is a bit of a learning curve.

Very interesting. Do you use that in combination with a vEdge Virtual Contact to integrate with Alexa routines?

How does the Rules API integrate with Driver-Mc? I don’t see any mention of them in that thread. Do you write external code e.g. in Python or JS?

Are there any tutorials or example code to look at to get started down this path? I’m a retired SW dev who knows JSON and several programming languages, and have written cloud-based apps before.

Or am I over-thinking this? Is there a simpler approach?

Thanks for any guidance.

Here’s my code. One block is for the outside sensor, and one block is for the inside sensor.

You would need to substitute your device id’s for mine. Device 9572……… is the virtual device I created to do the math. The other 2 devices are my indoor and outdoor temperature sensors.

You need to get the Advanced Web App (AWS) up and running to enter this code.

I think the 1st [ and last ] are automatically added by the AWA, so delete them before pasting the code.

[
  {
    "if": {
      "changes": {
        "operand": {
          "device": {
            "devices": [
              "91180498-b2f5-435e-b457-8a20ca3d8557"
            ],
            "component": "main",
            "capability": "temperatureMeasurement",
            "attribute": "temperature",
            "trigger": "Always"
          }
        }
      },
      "then": [
        {
          "command": {
            "devices": [
              "9572aa6f-561b-4df3-a5da-16e473a46510"
            ],
            "commands": [
              {
                "component": "main",
                "capability": "legendabsolute60149.numberFieldOne",
                "command": "setNumberFieldOne",
                "arguments": [
                  {
                    "device": {
                      "devices": [
                        "91180498-b2f5-435e-b457-8a20ca3d8557"
                      ],
                      "component": "main",
                      "capability": "temperatureMeasurement",
                      "attribute": "temperature"
                    }
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  },
  {
    "if": {
      "changes": {
        "operand": {
          "device": {
            "devices": [
              "8fa2def5-e293-496a-bd52-ee087ea18feb"
            ],
            "component": "main",
            "capability": "temperatureMeasurement",
            "attribute": "temperature",
            "trigger": "Always"
          }
        }
      },
      "then": [
        {
          "command": {
            "devices": [
              "9572aa6f-561b-4df3-a5da-16e473a46510"
            ],
            "commands": [
              {
                "component": "main",
                "capability": "legendabsolute60149.numberFieldTwo",
                "command": "setNumberFieldTwo",
                "arguments": [
                  {
                    "device": {
                      "devices": [
                        "8fa2def5-e293-496a-bd52-ee087ea18feb"
                      ],
                      "component": "main",
                      "capability": "temperatureMeasurement",
                      "attribute": "temperature"
                    }
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  }
]