salex319 Posted Monday at 06:33 PM Posted Monday at 06:33 PM I have an ISY-994 with lots of Insteon devices. I also have another system of my own design with sensors and devices that communicate via Wi-Fi. This other system is implemented with Python code on Raspberry Pi's and ESP32 processors. How easily could I access/change ISY variables by accessing the ISY over the LAN from my devices? It appears Polisy might provide this kind of capability but it looks very complex unless there's already an existng node(?) available that supports that kind of functionality. Quote
Solution hart2hart Posted Monday at 07:12 PM Solution Posted Monday at 07:12 PM You can update variables via REST interface. 2 Quote
paulbates Posted Monday at 10:06 PM Posted Monday at 10:06 PM Here is the link for the specs. Scroll down or search for Variables https://wiki.universal-devices.com/ISY_Developers:API:REST_Interface 2 Quote
salex319 Posted Tuesday at 10:09 PM Author Posted Tuesday at 10:09 PM This is really terrific. I've wanted to do this for a long time never realizing how simple it is. So I've been able to access variables using REST. But can't get Node info. This: url = 'https://192.168.4.40/rest/vars/get/1/1' Produces: <?xml version="1.0" encoding="UTF-8"?><var type="1" id="1"><init>0</init><prec>0</prec><val>0</val><ts>20250806 16:38:55</ts></var> But this: url = 'https://192.168.4.40/rest/nodes/SM-GM-Fan' Produces: <?xml version="1.0" encoding="UTF-8"?><RestResponse succeeded="false"><status>404</status></RestResponse> I suppose my node ID field is not coded properly. If this is true what's the correct format? Quote
larryllix Posted Tuesday at 10:55 PM Posted Tuesday at 10:55 PM (edited) @salex319 It seems the REST interface information has gotten worse over the years. A few years back the security information technique was removed from the wiki and now it reads like a bunch of gooble-dee-gook IMHO, with no clear method exposed to actually use the REST interface. Here is the python code I use to talk to ISY to set STATE variables. Note the security encryption needed to authorise ISY to accept the REST commands. NOTE: Most browsers will not allow this style of password encryption anymore but programming coding these URLs works fine with ISY REST interface. -------------------------------------------------------------------------------- # Python3 program to stuff four ISY variables with your external polisy IP Address # by larryllix @ UDI forum, Last updated January 2, 2022 import base64 # polisy parameters needing to be setup username = 'xxxxxx' password = 'yyyyy' ISY_IP = "localhost:8080" # ISY variable location to be defined by user # ISY varPage: 1=Integer, 2=State ISYvarPage = 2 ISYvarAdd = 72 def send_ISY_var(page, address, value): authorize = base64.b64encode((username + ":" + password).encode('utf-8')) url = "http://%s/rest/vars/set/%s/%s/%s" % (ISY_IP, page, address, value) try: request = urllib.request.Request(url) request.add_header("Authorization", "Basic %s" % authorize.decode('utf-8')) r = urllib.request.urlopen(request) bak_msg = r.read() except: print("*** IPscraper: ISY send failed!") r.close() return # accessing IP address code removed (here) for clarity of REST send code # Send the variables to the ISY variables via ISY rest send_ISY_var(ISYvarPage, ISYvarAdd + 0, urlBytes[0]) send_ISY_var(ISYvarPage, ISYvarAdd + 1, urlBytes[1]) send_ISY_var(ISYvarPage, ISYvarAdd + 2, urlBytes[2]) send_ISY_var(ISYvarPage, ISYvarAdd + 3, urlBytes[3]) Edited Tuesday at 10:59 PM by larryllix Quote
salex319 Posted Tuesday at 11:13 PM Author Posted Tuesday at 11:13 PM The REST API suggests I should be able to access NODES as well as variables. I've successfully read and modified variables but was unable to access a particular NODE(i.e. SM-GM-Fan). My URL for the fan NODE was: url = 'https://192.168.4.40/rest/nodes/SM-GM-Fan' But I get the indicated error (previous post). I tried single and double quotes around the NODE ID with the same error result. There doesn't seem to be any numerical value for the NODE available in the Admin console as there is with variables. So either the NODE stuff isn't actually functional or I'm specifying the node improperly. Quote
hart2hart Posted Tuesday at 11:29 PM Posted Tuesday at 11:29 PM Take a look in admin console its node address will be something link n02_99 and what you show is its name. Quote
salex319 Posted yesterday at 01:03 AM Author Posted yesterday at 01:03 AM I don't see the number you're suggesting in Admin Console(AC) or in the Node interrogation I did from my browser. You're not talking about the device Intseon address are you (40 1B C5 1)? Is there somewhere else to look in AC? Quote
hart2hart Posted yesterday at 01:16 AM Posted yesterday at 01:16 AM Yes, It’s 401BC51 Insteon address. Those starting my with n are nodes created by plugins. Quote
salex319 Posted yesterday at 01:44 AM Author Posted yesterday at 01:44 AM I tried: http://192.168.4.40/rest/nodes/n401BC51 http://192.168.4.40/rest/nodes/n40_1B_C5_1 http://192.168.4.40/rest/nodes/n_40_1B_C5_1 http://192.168.4.40/rest/nodes/n_40_1B_C5 http://192.168.4.40/rest/nodes/40_1B_C5 and several more... None worked. Finally I tried : http://192.168.4.40/rest/nodes/40%201B%20C5%201 And that worked! Thank you all very much! 4 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.