Creating Device Type Updates Status From XML

I have thoroughly confused myself on this and need a little straightening out.

I am attempting to create a new device type that talks with the Autelis.

Referencing this post on the Autelis forum as a starting point.

http://www.autelis.com/forum/viewtopic.php?f=13&t=561

Using the URI handler, I can successfully turn things on/off with smartthings, however if I do so outside of smartthings then the status is out of sync.

Through the autelis system I can pull a status.xml from ip.address/status.xml

<response>
<system>
<runstate>50</runstate>
<model>13</model>
<haddr>1</haddr>
<opmode>0</opmode>
<freeze>0</freeze>
<sensor1>0</sensor1>
<sensor2>0</sensor2>
<sensor3>0</sensor3>
<sensor4>0</sensor4>
<sensor5>0</sensor5>
<version>1.6.7</version>
<time>1507093135</time>
</system>
<equipment>
<circuit1>0</circuit1>
<circuit2>0</circuit2>
<circuit3>0</circuit3>
<circuit4>0</circuit4>
<circuit5>0</circuit5>
<circuit6>0</circuit6>
<circuit7>0</circuit7>
<circuit8>0</circuit8>
<circuit9>0</circuit9>
<circuit10/>
<circuit11/>
<circuit12/>
<circuit13/>
<circuit14/>
<circuit15/>
<circuit16/>
<circuit17/>
<circuit18/>
<circuit19/>
<circuit20>0</circuit20>
<feature1>0</feature1>
<feature2>0</feature2>
<feature3>0</feature3>
<feature4>0</feature4>
<feature5>0</feature5>
<feature6>0</feature6>
<feature7>0</feature7>
<feature8>0</feature8>
<feature9/>
<feature10/>
</equipment>
<temp>
<poolht>1</poolht>
<spaht>0</spaht>
<htstatus>0</htstatus>
<poolsp>78</poolsp>
<spasp>90</spasp>
<maxplsp/>
<pooltemp>65</pooltemp>
<spatemp>65</spatemp>
<airtemp>74</airtemp>
<soltemp/>
<tempunits>F</tempunits>
<htpump>0</htpump>
</temp>
</response>

Where I am stuck - I guess I am barking up the wrong tree with creating a device type? Should I be making a service manager? In which the service manager parses the status of the switch? EX circuit5?

Pointing me at something I could reference would also be greatly appreciated.

Thanks!

I am doing a similar job with a parallel structure. See

I am going out for a while. But I can help later this afternoon (after 3PM Texas, USA time).

Dave

OK, had some time. I hope this helps (I think you are asking how to receive and parse XML returns).

I have a command similar to the below:

Def GetRadioInfo () {
	sendCmd("/CPM?cmd=%3Cname%3EGetRadioInfo%3C/name%3E")
}

Sent via the command sendCmd:

private sendCmd(command){
	def cmdStr = new physicalgraph.device.HubAction([
		method: "GET",
		path: command,
		headers: [
			HOST: "${deviceIP}:55001",
		]],
		null,
		[callback: parseResponse]
	)
	sendHubCommand(cmdStr)
}

The raw output is:

<?xml version="1.0" encoding="UTF-8">
<CPM>
	<method>RadioInfo</method>
	<version>0.1</version>
	<speakerip>192.111.0.111</speakerip>
	<user_identifier>public</user_identifier>
	<response result="ok">
		<cpname>TuneIn</cpname>
		<root>Favorites</root>
		<presetindex>2</presetindex>
		<title>Country Hits (Americana and Alt. Country)</title>
		<description>Little Big Town - Tornado</description>
		<thumbnail>http://cdn-profiles.tunein.com/s249981/images/logod.png</thumbnail>
		<mediaid>s249981</mediaid>
		<allowfeedback>0</allowfeedback>
		<timestamp>2017-10-04T21:26:49Z</timestamp>
		<no_queue>1</no_queue>
		<playstatus>play</playstatus>
	</response>
</CPM>

The parse method looks like the below (shortened)

void parseResponse(resp) {
	def respMethod = (new XmlSlurper().parseText(resp.body)).method
	def respData = (new XmlSlurper().parseText(resp.body)).response
}

Some variables:

def title = respData.title
def mediaid = respData.mediaid
def description = respData.description

Key is the “new XMSlurper()” That really makes the string sing.

Hope this is what you are looking for.

I also have an autelis controller and I am looking to do the same things. Any luck with this with project? If so, would you mind sharing what you did?

Thanks

Unfortunately I havent had enough time to really mess with it.

However, I didnt really make a ton of progress.

Basically I kept running into the same issue which was how to get smartthings to poll/get the status of a given switch by looking at a given xml file at a given IP address.

My confusion kept stemming from my understanding or lack there of - of the structure/hierarchy of how smartthings handles things. Hence my note above about am I creating a device type or a service manager?

I looked for something that was simple that I could reference that would be atleast a starting point and I remember finding a sprinkler controller or something that I thought I would be able to use. However I didnt bookmark it and couldnt find it again.

Im definitely willing to work together to get everything up and running and making things public, but I lost myself in confusion lol.

Check this out somebody might have beat you to it. I tried to get it running yesterday but I ran into a few problems. Post your results on this thread.