Here is my long-awaited follow-up to an old tutorial, where I demonstrate a simple method for pulling data out of one or more cells in a Google Spreadsheet, using Rule Machine 5.1.
(Will flesh it out with illustrations ASAP, I promise.)
STEP ONE
Create or select an existing Google spreadsheet containing static or dynamic data you would like to extract into Rule Machine.
For this exercise, assume cells A1:B2 contain "Animal", "Age", "Cat", "6" and that we only want to import the cat's age (namely, the contents of cell B2) into our HE workflow.
STEP TWO
File > Share > Publish to Web > Sheet 1 > Comma-separated Values (.csv) > Start Publishing
and leave "Automatically republish" checked.
Copy long link.
STEP THREE
On Hubitat, create or select a rule in RM for which you would like to import data.
Create two new local variables of type String, "Import"and "Extract".
Create a new action as follows:
Set Variable > Set Variable > select variable name: Import > Set from HTTP GET response > paste link into "Enter URL" box
Create a second action:
Set Variable > Set Variable > select variable name: Extract > Token > check "Use variable to get token from" > select Import > Delimiter: \n > Index: 1 (Row 1 = 0, Row 2 = 1, etc.)
Create a third action:
Set Variable > Set Variable > select variable name: Extract > Token > check "Use variable to get token from" > select Extract > Delimiter: , (comma) > Index: 1 (Col A = 0, Col B = 1, etc.)
STEP FOUR
Install rule (if new) and Run Actions to test it out.
The desired cell value should now appear in Extract.
Q.E.D.
- Libra
P.S. Surely there are more efficient methods for doing this type of data extraction, but I enjoy rolling my own without writing (or borrowing) apps.