ahwman Posted December 4, 2019 Posted December 4, 2019 Hello, I’m trying to get the value of a state variable for use in a Siri Shortcut. That said, I need to authenticate with my ISY within the get statement but I’m unsure how to structure it. This is what I have so far, minus the authentication: https://my.isy.io/rest/vars/get/2/29
pdarbonne Posted August 14, 2021 Posted August 14, 2021 Were you able to figure this out? You have to add 'Basic Authorization' via as a header to the get request. I'd like to know how you parse the result returned in XML. Can't seem to get that part to work.
ahwman Posted August 15, 2021 Author Posted August 15, 2021 18 hours ago, pdarbonne said: Were you able to figure this out? You have to add 'Basic Authorization' via as a header to the get request. I'd like to know how you parse the result returned in XML. Can't seem to get that part to work. Unfortunately not. If you find a working solution, please pass it on. Maybe someone smarter than me has figured this out… ?
pdarbonne Posted August 16, 2021 Posted August 16, 2021 (edited) On 8/15/2021 at 8:14 AM, ahwman said: Unfortunately not. If you find a working solution, please pass it on. Maybe someone smarter than me has figured this out… ? Ok then this might help. BTW - my use case is to ask Siri if we closed the garage door. I have a garagelinc controlling the main door via an ISY and its REST interface. In the shortcut I do the following: 1. create a URL (this is the long URL you can grab from the 'Information' tab on my.isy.io. In my case, that URL is the command to 'query' the garagelinc device (/rest/status/[device id]. 2. create a text file that contains username:password (don't forget the colon) 3. Encode that text file with base64 4. Get contents of URL. In the 'headers' section add an 'Authorization' header key and then 'Basic' in the text section. After the word 'Basic' add your Base64 Encoded file 5. Set the name of 'Contents of URL' to output.txt (or something to your preference). If you 'play' the shortcut right here - you will see the XML file output. Progress! Now you have a text response from your query to the ISY REST API. The same format by the way is what you use to issue commands to devices or run programs. Its pretty straightforward from here. If anyone else has some guidance on how you can take a value from the resulting XML/text file please share that. I'd like to know if the status of my GarageLinc is ON or OFF so I then might have Siri respond accordingly. BTW - thanks to the other posters on this topic as its been via those that I've cobbled together the above. Edited August 16, 2021 by pdarbonne
ahwman Posted August 18, 2021 Author Posted August 18, 2021 On 8/16/2021 at 3:37 PM, pdarbonne said: Ok then this might help. BTW - my use case is to ask Siri if we closed the garage door. I have a garagelinc controlling the main door via an ISY and its REST interface. In the shortcut I do the following: 1. create a URL (this is the long URL you can grab from the 'Information' tab on my.isy.io. In my case, that URL is the command to 'query' the garagelinc device (/rest/status/[device id]. 2. create a text file that contains username:password (don't forget the colon) 3. Encode that text file with base64 4. Get contents of URL. In the 'headers' section add an 'Authorization' header key and then 'Basic' in the text section. After the word 'Basic' add your Base64 Encoded file 5. Set the name of 'Contents of URL' to output.txt (or something to your preference). If you 'play' the shortcut right here - you will see the XML file output. Progress! Now you have a text response from your query to the ISY REST API. The same format by the way is what you use to issue commands to devices or run programs. Its pretty straightforward from here. If anyone else has some guidance on how you can take a value from the resulting XML/text file please share that. I'd like to know if the status of my GarageLinc is ON or OFF so I then might have Siri respond accordingly. BTW - thanks to the other posters on this topic as its been via those that I've cobbled together the above. Thanks for sharing. Do you happen to use Homebridge? If so, you might consider using the ISY Maker plugin which will expose ISY state variables as devices to HomeKit. This is what I use for my Insteon devices and it works very reliably without all of the hassles of trying to do it manually using other methods. The best part is that Siri recognizes these virtual devices like any other HomeKit devices…
maxnorth Posted September 1, 2021 Posted September 1, 2021 This process for retrieving a variable's value works for me. In my case, I simply want to know the value; I am not doing anything programmatically with it. 1. Create a network resource in ISY that will send a notification with the variable's value contained in the body of the notification. I use Pushover for all of my notifications and I include ${var.1.x} in the body of the notification, which will pull in the value of the variable (you will replace 1.x with your particulars, which I can see you already know how to do). 2. Create an ISY program that will activate the network resource. In my case, it has no IF or ELSE clause, just a THEN. 3. Go to ISY Portal and create an entry that will call the THEN clause of the program. 4. Write an IOS Shortcut that will call the ISY portal entry. 5. For my garage door, I want to know if the state is 1 or 0, and here is the text of my pushover message (without the API or user keys): "The garage door state is ${var.1.7} where 0 is closed" My implementation for my entire house uses a single Shortcut, but that's is a more complicated discussion. Also, @ahwman I've got a question for you about ISY Maker, but I will post that in another reply.
ahwman Posted September 1, 2021 Author Posted September 1, 2021 1 hour ago, maxnorth said: This process for retrieving a variable's value works for me. In my case, I simply want to know the value; I am not doing anything programmatically with it. 1. Create a network resource in ISY that will send a notification with the variable's value contained in the body of the notification. I use Pushover for all of my notifications and I include ${var.1.x} in the body of the notification, which will pull in the value of the variable (you will replace 1.x with your particulars, which I can see you already know how to do). 2. Create an ISY program that will activate the network resource. In my case, it has no IF or ELSE clause, just a THEN. 3. Go to ISY Portal and create an entry that will call the THEN clause of the program. 4. Write an IOS Shortcut that will call the ISY portal entry. 5. For my garage door, I want to know if the state is 1 or 0, and here is the text of my pushover message (without the API or user keys): "The garage door state is ${var.1.7} where 0 is closed" My implementation for my entire house uses a single Shortcut, but that's is a more complicated discussion. Also, @ahwman I've got a question for you about ISY Maker, but I will post that in another reply. That makes sense.
maxnorth Posted September 1, 2021 Posted September 1, 2021 So, with ISY Maker. I'm trying to understand how it might benefit me. My use cases: - when the ambient temperature of my Nest thermostat changes, update an ISY variable with the value of that temp. -- This does not work because temp changes can't be used as trigger in HomeKit. (And if I can't get a native trigger, then I can't leverage the power of Shortcuts). - when Nest thermostat is changed from Off to Heat or Cool, update a ISY variable. -- This does not work because Heat or Cool are not recognized as triggers, only Eco On or Off. What am I missing? Even if ISY Maker enables me to create a variable with a "temp" service type, I cannot update it automatically, because the Nest temp change will not act as a trigger within HomeKit.
maxnorth Posted September 1, 2021 Posted September 1, 2021 Related: Does anyone know if Home Assistant will accommodate these use cases natively?
ahwman Posted September 1, 2021 Author Posted September 1, 2021 9 hours ago, maxnorth said: So, with ISY Maker. I'm trying to understand how it might benefit me. My use cases: - when the ambient temperature of my Nest thermostat changes, update an ISY variable with the value of that temp. -- This does not work because temp changes can't be used as trigger in HomeKit. (And if I can't get a native trigger, then I can't leverage the power of Shortcuts). - when Nest thermostat is changed from Off to Heat or Cool, update a ISY variable. -- This does not work because Heat or Cool are not recognized as triggers, only Eco On or Off. What am I missing? Even if ISY Maker enables me to create a variable with a "temp" service type, I cannot update it automatically, because the Nest temp change will not act as a trigger within HomeKit. Have you tried the Home+ or Eve app to see if you can set up an automation trigger for your needs? I use several temperature automations using these apps which simply aren’t available in the native Home app…
maxnorth Posted September 1, 2021 Posted September 1, 2021 I have not tried to those apps. I'll check them out. Thanks!
ahwman Posted September 1, 2021 Author Posted September 1, 2021 5 hours ago, maxnorth said: I have not tried to those apps. I'll check them out. Thanks! Hope it works out for you… ?
dbwarner5 Posted January 7, 2022 Posted January 7, 2022 On 8/31/2021 at 9:00 PM, maxnorth said: This process for retrieving a variable's value works for me. In my case, I simply want to know the value; I am not doing anything programmatically with it. 1. Create a network resource in ISY that will send a notification with the variable's value contained in the body of the notification. I use Pushover for all of my notifications and I include ${var.1.x} in the body of the notification, which will pull in the value of the variable (you will replace 1.x with your particulars, which I can see you already know how to do). 2. Create an ISY program that will activate the network resource. In my case, it has no IF or ELSE clause, just a THEN. 3. Go to ISY Portal and create an entry that will call the THEN clause of the program. 4. Write an IOS Shortcut that will call the ISY portal entry. 5. For my garage door, I want to know if the state is 1 or 0, and here is the text of my pushover message (without the API or user keys): "The garage door state is ${var.1.7} where 0 is closed" My implementation for my entire house uses a single Shortcut, but that's is a more complicated discussion. Also, @ahwman I've got a question for you about ISY Maker, but I will post that in another reply. @maxnorth Hi, I just saw this post and am wondering how you do step 4? I am interested in taking this in. a few directions, similar to yours, but also, to be able to ask Alexa "what is the wind", which I have a local station that the isy, knows the answer and I would like to eventually have Alexa answer it. Thanks
maxnorth Posted January 7, 2022 Posted January 7, 2022 I'll respond, but first some updates that relate to this thread more broadly: 1. I am now using HomeBridge (on Docker) with ISY Maker and exposing ISY variables to Homekit where they can be accessed by Siri shortcuts. Just "Get" the value of a variable in a Siri Automation. It has been completely reliable. 2. I am using the Nest plugin for Homebridge to integrate my thermostats into ISY. 3. Thermostat/Sensor changes can't be used as triggers in Homekit, so how to tell ISY that a temperature has changed? I use the Controller IOS app. It allows you to create shortcuts that use these things as triggers. But Controller does not play well with the Siri Shortcuts app, so... Create a dummy switch in Homebridge (Dummy plugin). Use a Controller automation to turn the switch on when the tstat temp changes. Then, create a Siri Automation that runs when the switch turns on and retrieves the current temp from the tstat and updates an ISY variable (via a set command) with the current temp. From there, you can use ISY programs to do whatever you want to with the variable, including having a network resource send a notification. Because Siri automations can be triggered remotely but run locally (local Homekit devices, like Apple TV, function as servers), I am able to use a local address (192.168.1.xxx) for the Siri GET/SET statements. I do not need to go through the UDI portal. Example: https://username:password@192.168.1.xxx/rest/vars/set/2/29 (where xxx is the local address of my ISY) 4. For ambient weather issues, I use nearby PurpleAir sensors and Polyglot, so that's a different workflow, which does not depend on HomeBridge or Homekit. 5. As to your question about "how" to write an IOS Shortcut that will call an ISY Portal entry, a couple of clarifications. I won't address the Alexa question (I would use Siri instead since it is always on my wrist). And I won't get into the details of writing Siri shortcuts, since that's a deep dive. But basically you first create a webhook at the UDI portal (Select Tools->Connectivity->IFTTT Webhooks) and set up an ISY scene, device or program to trigger on receiving a GET command. (For clarity, this does not rely on the IFTTT service at all). You might create one called "garage_open". Then, create a Siri Shortcut called "open garage door" that will send a REST statement to the Portal to trigger the command. That assembled command would look something like this: https://my.isy.io/api/ifttt/garage_open/key/your_portal_api_key 1
dbwarner5 Posted January 7, 2022 Posted January 7, 2022 @maxnorth Hmm.. ok. I will have to think through that a bit. Currently I use Voice-in-a-Can on my apple watch to access Alexa for things like shut the garage door etc. using voice. So from an initiation standpoint I have a way albeit its not completely handsfree when I am out and about. Is hands free only when near an Alexa-dot type of device. ( I have to touch the Voice in a can complication on my watch to initiate) Primarily I am looking for ways to get data verbally out of my ISY, from a verbal command in via Alexa. I need to go find other posts on this as well. ie: ask Alexa what is the wind doing and have it respond with my ISY data. Thanks for the response!
Recommended Posts