Sync SharpTools Variable TO Hubitat

I have seen several posts about “Sync Hubitat Variable to SharpTools” but not the Opposite.

Everyday at 5:30 AM SharpTools will set a bunch of Variables using my Open Weather account.

I would like to create a few Hubitat variables and have them set with whatever the value they are in SharpTools, maybe at 5:15 AM.

Is it possible to do this?

Yes. If you are already using Hubitat Variable Connectors (the devices that mirror your Hubitat Variables), those devices also expose commands to update the variables like setVariable(value)

Alternatively Hubitat’s Rule Machine has an HTTP API for setting hub variables:

http://cloud.hubitat.com/api/<hub-id>/apps/<rule-app-id>/trigger/setHubVariable=<variable-name>:<variable-value>?access_token=<access-token>

Rule Machine - Cloud Endpoints

Rule Machine Cloud Endpoint Install Steps (tap to expand)

From what I recall, you would:

  1. Create a Hubitat Rule Machine rule
  2. Tap Select Trigger Events
  3. Click the + icon to add a trigger
  4. In the capability dropdown, select ‘Cloud end point
  5. Copy the Cloud End Point URL link and record it somewhere
  6. Save the trigger and the rule
    1. Tap Done with this Trigger Event
    2. Tap Done with Trigger Events
    3. Tap Done (which auto ‘installs’ the rule)

That gives you a URL like:

http://cloud.hubitat.com/api/<hub-id>/apps/<rule-app-id>/trigger?access_token=<access-token>

So you need to add the /setHubVariable=<variable-name>:<variable-value> part:

http://cloud.hubitat.com/api/<hub-id>/apps/<rule-app-id>/trigger/setHubVariable=<variable-name>:<variable-value>?access_token=<access-token>
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
👉--------------------------------------------------------------👆

You could use this with an HTTP Action in a SharpTools Rule.

I am, but don’t see where it exposes commands to update the variable. (this “seems” like the simplest approach of the options you listed…

It sems like that connector variable (Day High Temp) “should” be listed in my SharpTools “Things” after a reauthorization, (like a device), but it is not.

Yeah, a Connector is basically just a ‘Thing’ that mirrors the specific Hubitat Variable’s state bidirectionally.

So you have to explicitly ensure the variable has a matching Connector ‘Thing’, then you have to explicitly authorize that Connector ‘Thing’ to the associated app (SharpTools in this case). Usually that involves going through the authorization flow again and making sure that new Connector device has the box checked next to it so it will be authorized.

For use-cases where you want to expose the Hubitat Variable to another app, especially for read access, I would agree.

If you only ever want to write to the Hubitat variables, then the Rule Machine setHubVariable approach is probably more efficient as you don’t have the extra work of setting up the Connectors (assuming you don’t need them elsewhere) and can just update any Hubitat variable you want without additional Connectors, authorizations, etc.