Jump to content

How to - ISY access over LAN


salex319
Go to solution Solved by hart2hart,

Recommended Posts

Posted

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.

Posted

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?

Posted (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 by larryllix
Posted

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.

Posted

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?

image.thumb.png.fb333a73b96abaeed2ed4c6864ba0e94.png

 

image.png.c758061d1742e37b93ed67cf0a352cb6.png

Posted

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!

  • Like 4

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...