Hi - is it possible to set a variable in HomeKit and pass it to Habitat?
What I want to do is read an NFC tag with my phone, allow me to choose an 'alarm' time and pass it in to a Hubitat variable.
Thanks
Chris
Hi - is it possible to set a variable in HomeKit and pass it to Habitat?
What I want to do is read an NFC tag with my phone, allow me to choose an 'alarm' time and pass it in to a Hubitat variable.
Thanks
Chris
I was impressed by some methods suggested by Gemini AI (which I've been playing with lately):
To pass a variable from HomeKit to Hubitat—specifically for an NFC-triggered "alarm time" workflow—the most effective method is using the Maker API combined with an Apple Shortcut.
Since HomeKit's native bridge only shares device states (on/off, temperature), it doesn't allow you to push arbitrary text or numbers (like a specific time) back to Hubitat easily. A Shortcut can bridge this gap by sending a direct web request to Hubitat.
alarmTime ) of type String or DateTime .alarmTime variable.http://[YourHubIP]/apps/api/[AppID]/hubvariables/[VariableName]/[Value]?access_token=[Token][Value] part of the URL with the Provided Input variable from the previous step.If you prefer not to use web URLs, you can create a Hub Variable Connector (a virtual device tied to your variable).
| Method | Best For | Complexity | Reliability |
|---|---|---|---|
| Shortcut + Maker API | Specific values (Time/Text) | Medium | High (requires LAN/Cloud) |
| Virtual Connector | Simple numbers/percentages | Low | High (native HomeKit) |
| Rule Machine Endpoint | Triggering specific logic | Medium | High |
You could use two virtual dimmers. One is for hours, the other is for minutes, in 24 hour time. Have Hubitat not respond to the the hour dimmer changing, but get its set value when the minute dimmer value is changed. Set the hour dimmer, then set the minute dimmer to get Hubitat to trigger off of it, and then on Hubitat side combine the two values into a time.
How do you format the time sent via MakerAPI so it is recognized as a DateTime variable by Hubitat? Nothing I've tried seems to work.
If you're trying to set an alarm time via Apple Home / Homekit, one way I have used for the last couple of years is to:
It should also be possible to use a prompt from a Shortcut to turn on the switch at the time obtained from input, but I haven't tried this.
While I couldn't get a DateTime variable to be passed from Homekit to Hubitat, I did get this to work using a combination of String and DateTime variables.
Create two variables. One of them is a String variable (timeString below) and exposed to MakerAPI. The second is a DateTime variable (testTime below)
Pass time from the Shortcut to the string variable via MakerAPI. Select a custom format of "hh:mm" for the time input.
Create a Rule (or other Hubitat automation) that sets the DateTime variable to the value of the String variable
(the 99.999 should be replaced with 00.000 )
The shortcut itself looks like this:
Would be nice if someone could post a way to do this directly with a DateTime variable, instead of using a String variable as an intermediate.
I found this:
Hub variables can also use a
DateTimevariable to represent only a date or only a time. In such cases, the "missing" components should be substituted with the digit9(as many times as needed to ensure the format is still correct). For example, a time-only variable with a blank date could look like:9999-99-99T14:25:09.009-0700. If the variable contains only a date with blank time, the string is like2022-10-13T99:99:99:999-9999. Built-in app UIs would display these as only times or only dates, respectively. Your apps should also gracefully handle all three possibilities: date, time, or date and time and display appropriate presentation (and provide appropriate values back to the hub). Generally you can test for the two special cases above withstartsWith("9999")orendsWith("9999").
I was unable to pass an input string like that from the Shortcuts app directly to MakerAPI and have it set a DateTime variable, while the same format clearly works from Rule Machine (in my example above).
Be interested in knowing if you can get that to work directly from the Shortcuts app.
I've managed to get it to work as a URL - struggling to get the shortcuts app to work with any URL at the moment. Will let you know!
This part is easy. Can you create a shortcut like the one I've shown above?
THIS solves a problem I've been facing - conveniently scheduling a virtual switch through Siri. I wish I knew this earlier! THANK YOU!
Any ideas on how to get Siri to look at my calendar and schedule "Prepare the Car" (pre-warm the car) for all the times I will need to go somewhere and return? Or is that asking for too much? ![]()
Got it:
I've not done much with Shortcuts, so it took be a bit of head scratching.
I hadn't realised that URL simply creates a URL.
The shortcut then is
Ask for Time
Format date (ask for input). Another thing that confused me is you can't have a custom format of a time, so even though I just want the time, I had to choose date, custom format and HH:MM
That result is then pasted into the following URL
http://192.168.0.XX/apps/api/20/hubvariables/AlarmTime/9999-99-99T[Formatted Time]:00.000-0600?access_token=[TOKEN]
And finally it's opened.
Just need to find out now if it's possible to open the URL without opening the browser!
Yes, make the final part of the shortcut “Get contents from URL”