HOA Script

Is there a quick way to run different scripts from an HOA Button? Pretty simple-- I want to run one script for ON and a totally different script for OFF, then a another separate script for AUTO. I removed AUTO so for my use, I have ON/OFF. But the concept is the same for the question.

Yes, you can add a propertyChange script that will fire whenever the control value property changes. Here is an example:if event.propertyName == "controlValue": value = event.newValue if value == 0: # do something when the control is 0 elif value == 1: # do something when the control is 1 else: # do something when the control is not 0 or 1

Well I have another question relative to this.

if event.propertyName == “controlValue”:
value = event.source.controlValue
[color=#BF0000]address = event.source.Address[/color]
if value == 0:
import xmlrpclib
server=(‘http://10.213.135.22:80/soap’)
#put together the elements into a message payload and send
message = “<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap=‘http://schemas.xmlsoap.org/soap/envelope/’><soap:Body xmlns=‘urn:hisolutions’><n:sii>2</n:sii><n:execute xmlns:n=‘urn:HISolutions’>[color=#BF0000]‘address’[/color] OFF</n:execute></soap:Body></soap:Envelope>”
response = system.net.httpPost(“http://10.213.135.22:80/soap”, “text/xml”, message)
system.tag.writeToTag(“WSDL Test Tags/response for 13B”,response)

else:
import xmlrpclib
server=(‘http://10.213.135.22:80/soap’)
#put together the elements into a message payload and send
message = “<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap=‘http://schemas.xmlsoap.org/soap/envelope/’><soap:Body xmlns=‘urn:hisolutions’><n:sii>2</n:sii><n:execute xmlns:n=‘urn:HISolutions’>[color=#BF0000]‘address’[/color] ON</n:execute></soap:Body></soap:Envelope>”
response = system.net.httpPost(“http://10.213.135.22:80/soap”, “text/xml”, message)
system.tag.writeToTag(“WSDL Test Tags/response for 13B”,response)

As in the above script which I know is wrong; I would like to replace the ‘address’ with my actual custom property WITHOUT it ending up in my xml message. The controller will respond with an error if anything but an address is in there. I have hand-hard coded about 50 of these and that method works but i got about 800 to go so I would like to figure out some quicker methods to do this. The multi-state function also seems to function but I dont think it is quite as efficient as it could be. I also modified the indentation which I am not certain was the best thing to do. When I hard code the address the HOA style does in fact work.
Thank you for your help/comments!

You can stick in the address like this:if event.propertyName == "controlValue": value = event.source.controlValue address = event.source.Address if value == 0: import xmlrpclib server=('http://10.213.135.22:80/soap') #put together the elements into a message payload and send message = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body xmlns='urn:hisolutions'><n:sii>2</n:sii><n:execute xmlns:n='urn:HISolutions'><commands xsi:type='n:StatusList'><command>'" + address + "' OFF</command></commands></n:execute></soap:Body></soap:Envelope>" response = system.net.httpPost("http://10.213.135.22:80/soap", "text/xml", message) system.tag.writeToTag("WSDL Test Tags/response for 13B",response) else: import xmlrpclib server=('http://10.213.135.22:80/soap') #put together the elements into a message payload and send message = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body xmlns='urn:hisolutions'><n:sii>2</n:sii><n:execute xmlns:n='urn:HISolutions'><commands xsi:type='n:StatusList'><command>'" + address + "' ON</command></commands></n:execute></soap:Body></soap:Envelope>" response = system.net.httpPost("http://10.213.135.22:80/soap", "text/xml", message) system.tag.writeToTag("WSDL Test Tags/response for 13B",response)

AWESOME