# Script functions questions

**URL:** <https://forum.inductiveautomation.com/t/script-functions-questions/12105>\
**Category:** Ignition\
**Created:** [September 7, 2016, 12:14pm UTC](https://forum.inductiveautomation.com/t/script-functions-questions/12105 "2016-09-07T12:14:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanfomin1977](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@ivanfomin1977](https://forum.inductiveautomation.com/u/ivanfomin1977)\
**Post date:** [September 7, 2016, 12:14pm UTC](https://forum.inductiveautomation.com/t/script-functions-questions/12105/1 "2016-09-07T12:14:11Z")

</div>

Hi everybody.  
I need to make an OPC DA connection to a redundant pair. I have found a suitable function system.device.setDeviceHostname(DevName, HostName)  
But it returns with error:“Caused by: java.lang.Exception: Device ‘CCR0’ doesn’t exist”  
When I try to get device list with function “system.device.listDevices” I receive a dataset with 4 columns and 0 rows.  
I defensively have divices. They are shown in web page and “[System]Gateway/OPC/Connections/” tags.

Can you tell me what is wrong?

Here is the code

[quote]PrimaryIP = “192.168.11.120” #Имя основного сервера  
SecondaryIP = “192.168.11.121”#Имя резервного сервера  
ConnactionName = “CCR0” #Имя подключения  
val = system.opc.getServerState(ConnactionName);#Текущее состояние подключения  
if val != u’CONNECTED’:#Если НЕ подключено, то выключаем соеденение, переключаем контент и включаем соединение  
print "Device " + ConnactionName + "connaction status = " + val  
RedundanceStatus = system.tag.read(“conf/Redundancy/” + ConnactionName)  
if RedundanceStatus:#Состояние резервированя  
print “Redundance state is PRIMARY”  
print “Switching OFF the " + ConnactionName + " device”  
system.device.setDeviceEnabled(ConnactionName, 0)#Выключаем устройсво  
#SLEEP 5000   
system.device.setDeviceHostname(ConnactionName,SecondaryIP)#Меняем IP на устройстве  
#SLEEP 5000  
system.device.setDeviceEnabled(ConnactionName, 1)#Включаем устройсво  
#SLEEP 15000   
else:  
print “Redundance state is SECONDARY”[/quote]

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 7, 2016, 1:26pm UTC](https://forum.inductiveautomation.com/t/script-functions-questions/12105/2 "2016-09-07T13:26:07Z")

</div>

setDeviceHostname and listDevices are functions for modifying and listing devices on Ignition’s OPC-UA server. They don’t have anything to do with creating a new OPC DA connection. There are no scripting functions for that.

---

<div class="post-metadata">

**Author:** ![ivanfomin1977](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@ivanfomin1977](https://forum.inductiveautomation.com/u/ivanfomin1977)\
**Post date:** [September 8, 2016, 5:09am UTC](https://forum.inductiveautomation.com/t/script-functions-questions/12105/3 "2016-09-08T05:09:48Z")

</div>

Thanks, That is too bad.
