Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Receive temperature from Node-RED and evaluate
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Condition": {
"actions": {
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Body": "<p>Warning: RaspberryPi Temperature reached @{variables('Temperature')}</p>",
"Importance": "High",
"Subject": "Temperature alert!",
"To": "your@email.local"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"expression": {
"and": [
{
"greater": [
"@variables('Temperature')",
70
]
}
]
},
"runAfter": {
"Insert_Entity": [
"Succeeded"
]
},
"type": "If"
},
"Initialize_variable_from_input": {
"inputs": {
"variables": [
{
"name": "Temperature",
"type": "float",
"value": "@float(base64ToString(triggerBody()?['$content']))"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Insert_Entity": {
"inputs": {
"body": {
"PartitionKey": "pihome",
"RowKey": "@{utcNow()}",
"Temperature": "@variables('Temperature')"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azuretables']['connectionId']"
}
},
"method": "post",
"path": "/Tables/@{encodeURIComponent('pitemperature')}/entities"
},
"runAfter": {
"Initialize_variable_from_input": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"$content": {
"type": "string"
},
"$content-type": {
"type": "string"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"azuretables": {
"connectionId": "/subscriptions/<yoursubscription>/resourceGroups/<yourresourcegroup>/providers/Microsoft.Web/connections/azuretables",
"connectionName": "azuretables",
"id": "/subscriptions/<yoursubscription>/providers/Microsoft.Web/locations/westeurope/managedApis/azuretables"
},
"office365": {
"connectionId": "/subscriptions/<yoursubscription>/resourceGroups/<yourresourcegroup>/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/<yoursubscription>/providers/Microsoft.Web/locations/westeurope/managedApis/office365"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment