Created
August 13, 2022 08:06
-
-
Save prombouts/7fa11d4af56516db45ef0d4d2bea1942 to your computer and use it in GitHub Desktop.
Receive temperature from Node-RED and evaluate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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