Querying EasyDAQ Relay States from Python Script

Posted on
Mon Dec 27, 2021 12:17 pm
BlaineM offline
Posts: 36
Joined: Jan 13, 2012

Querying EasyDAQ Relay States from Python Script

I'm clearly missing something. I'm attempting to query relay states on an EasyDAQ USB board from a Python script. Every relay state shows "off" within the scripting shell despite turning on relays and seeing them as on within Indigo.

My simple test looks like:
Code: Select all
dev_easydaq = indigo.devices[5143497]
print unicode(dev_easydaq)

This results in the following excerpt:
states : States : (dict)
allChannels : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 (string)
channel01 : off (on/off bool)
channel02 : off (on/off bool)
channel03 : off (on/off bool)
channel04 : off (on/off bool)
channel05 : off (on/off bool)
channel06 : off (on/off bool)
channel07 : off (on/off bool)
channel08 : off (on/off bool)
channel09 : off (on/off bool)
channel10 : off (on/off bool)
channel11 : off (on/off bool)
channel12 : off (on/off bool)
channel13 : off (on/off bool)
channel14 : off (on/off bool)
channel15 : off (on/off bool)
channel16 : off (on/off bool)
channel17 : off (on/off bool)
channel18 : off (on/off bool)
channel19 : off (on/off bool)
channel20 : off (on/off bool)
channel21 : off (on/off bool)
channel22 : off (on/off bool)
channel23 : off (on/off bool)
channel24 : off (on/off bool)

I clearly have relays in the "on" state within Indigo.

Any suggestions?

Thanks,
Blaine

Posted on
Mon Dec 27, 2021 12:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Querying EasyDAQ Relay States from Python Script

When you get the device instance from the Indigo Server, it's a snapshot of the device status. So, if you turn on/off any of the relays after doing that, you have to refresh the device instance to see the effects:

Code: Select all
# Get the initial snapshot
dev_easydaq = indigo.devices[5143497]
print unicode(dev_easydaq)
# Make some changes in the UI to turn on/off relays
dev_easydaq.refreshFromServer()
print unicode(dev_easydaq)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 27, 2021 1:01 pm
BlaineM offline
Posts: 36
Joined: Jan 13, 2012

Re: Querying EasyDAQ Relay States from Python Script

Thanks for the quick response. It also explains why I was getting accurate states with no understanding of what I did to make that happen... I had turned on the relay prior to opening the scripting shell.

--Blaine

Posted on
Mon Dec 27, 2021 1:11 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Querying EasyDAQ Relay States from Python Script

You might want to read through the Indigo Object Model Reference - there are a few other gotchas outlined in that doc that might help you better understand what's going on when scripting Indigo.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 27, 2021 1:13 pm
BlaineM offline
Posts: 36
Joined: Jan 13, 2012

Re: Querying EasyDAQ Relay States from Python Script

Great tip... I was looking through a bunch of documentation, but didn't stumble across this. Probably exactly what I needed to research.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 11 guests