artpics
New member
Hi everyone thanks for the great resources on this forum
i need a bit of help
i want to get my Apex XML into my home automation program.
so i can turn on my AC if the temp gets too high etc.
here is the code i am using.
currently the XML is saved to my desktop every 15 mins great.
the problem is matching this code to the outlet names of the apex.
if i create a variable in my home automation software and call it current_temp instead of current_power it should put the data into my HA software. but from the code above i do not know what to delete or what names to change.
Any help truly appreciated thanks.
here is the thread where i got the code from.
http://www.perceptiveautomation.com/userforum/viewtopic.php?t=5002
here is my XML from the Apex.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<status software="4.12L_2A12" hardware="1.0">
<hostname>apex</hostname>
<serial>AC4:04376</serial>
<timezone>-8</timezone>
<date>05/07/2012 10:27:05</date>
<power>
<failed>04/26/2012 08:55:46</failed>
<restored>04/26/2012 08:56:20</restored>
</power>
<probes>
<probe>
<name>Temp</name>
<value>78.2</value>
<type>Temp</type>
</probe>
<probe>
<name>pH</name>
<value>8.20</value>
<type>pH</type>
</probe>
<probe>
<name>Amp_3</name>
<value>0.0</value>
<type>Amps</type>
</probe>
</probes>
<outlets>
<outlet>
<name>zSndAlm_I6</name>
<outputID>0</outputID>
<state>AOF</state>
<deviceID>base_Alarm</deviceID>
</outlet>
<outlet>
<name>zSndWrn_I7</name>
<outputID>1</outputID>
<state>AOF</state>
<deviceID>base_Warn</deviceID>
</outlet>
<outlet>
<name>zEmailAlm_I5</name>
<outputID>2</outputID>
<state>AOF</state>
<deviceID>base_email</deviceID>
</outlet>
<outlet>
<name>HighPump</name>
<outputID>3</outputID>
<state>AON</state>
<deviceID>3_1</deviceID>
</outlet>
<outlet>
<name>Skimmer</name>
<outputID>4</outputID>
<state>ON</state>
<deviceID>3_2</deviceID>
</outlet>
<outlet>
<name>LowPump</name>
<outputID>5</outputID>
<state>ON</state>
<deviceID>3_3</deviceID>
</outlet>
<outlet>
<name>Heater</name>
<outputID>6</outputID>
<state>AON</state>
<deviceID>3_4</deviceID>
</outlet>
<outlet>
<name>Vortech</name>
<outputID>7</outputID>
<state>AON</state>
<deviceID>3_5</deviceID>
</outlet>
<outlet>
<name>Fan</name>
<outputID>8</outputID>
<state>AOF</state>
<deviceID>3_6</deviceID>
</outlet>
<outlet>
<name>Reactor</name>
<outputID>9</outputID>
<state>AON</state>
<deviceID>3_7</deviceID>
</outlet>
<outlet>
<name>Radion</name>
<outputID>10</outputID>
<state>AOF</state>
<deviceID>3_8</deviceID>
</outlet>
<outlet>
<name>Feed</name>
<outputID>11</outputID>
<state>OFF</state>
<deviceID>Cntl:A1</deviceID>
</outlet>
<outlet>
<name>Maintain</name>
<outputID>12</outputID>
<state>OFF</state>
<deviceID>Cntl:A2</deviceID>
</outlet>
<outlet>
<name>z----</name>
<outputID>13</outputID>
<state>OFF</state>
<deviceID>Cntl:A3</deviceID>
</outlet>
<outlet>
<name>z----------</name>
<outputID>14</outputID>
<state>OFF</state>
<deviceID>Cntl:A4</deviceID>
</outlet>
</outlets>
</status>
i need a bit of help
i want to get my Apex XML into my home automation program.
so i can turn on my AC if the temp gets too high etc.
here is the code i am using.
Code:
set gatewayAddress to "http://7x.1xx.9x.xxx"
set thePort to "1001"
set output_path to "~/Desktop/ApexData.xml"
set fileURL to gatewayAddress & ":" & thePort & "/cgi-bin/status.xml"
do shell script "curl " & fileURL & " -o " & output_path
set XMLfile to "~/Desktop/ApexData.xml"
tell application "System Events"
* *set xml_data to contents of XML file XMLfile
* *tell xml_data to set live_data to XML element "LiveData"
* *tell xml_data to set power to XML element "Power" of live_data
* *tell xml_data to set total to XML element "Total" of power
* *tell xml_data to set power_now to XML element "PowerNow" of total
* *set power to value of power_now
* *tell application "IndigoServer"
* ** *set value of variable "current_power" to power as integer
* *end tell
end tell
currently the XML is saved to my desktop every 15 mins great.
the problem is matching this code to the outlet names of the apex.
Code:
tell application "System Events"
* *set xml_data to contents of XML file XMLfile
* *tell xml_data to set live_data to XML element "LiveData"
* *tell xml_data to set power to XML element "Power" of live_data
* *tell xml_data to set total to XML element "Total" of power
* *tell xml_data to set power_now to XML element "PowerNow" of total
* *set power to value of power_now
* *tell application "IndigoServer"
* ** *set value of variable "current_power" to power as integer
* *end tell
end tell
if i create a variable in my home automation software and call it current_temp instead of current_power it should put the data into my HA software. but from the code above i do not know what to delete or what names to change.
Any help truly appreciated thanks.
here is the thread where i got the code from.
http://www.perceptiveautomation.com/userforum/viewtopic.php?t=5002
here is my XML from the Apex.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<status software="4.12L_2A12" hardware="1.0">
<hostname>apex</hostname>
<serial>AC4:04376</serial>
<timezone>-8</timezone>
<date>05/07/2012 10:27:05</date>
<power>
<failed>04/26/2012 08:55:46</failed>
<restored>04/26/2012 08:56:20</restored>
</power>
<probes>
<probe>
<name>Temp</name>
<value>78.2</value>
<type>Temp</type>
</probe>
<probe>
<name>pH</name>
<value>8.20</value>
<type>pH</type>
</probe>
<probe>
<name>Amp_3</name>
<value>0.0</value>
<type>Amps</type>
</probe>
</probes>
<outlets>
<outlet>
<name>zSndAlm_I6</name>
<outputID>0</outputID>
<state>AOF</state>
<deviceID>base_Alarm</deviceID>
</outlet>
<outlet>
<name>zSndWrn_I7</name>
<outputID>1</outputID>
<state>AOF</state>
<deviceID>base_Warn</deviceID>
</outlet>
<outlet>
<name>zEmailAlm_I5</name>
<outputID>2</outputID>
<state>AOF</state>
<deviceID>base_email</deviceID>
</outlet>
<outlet>
<name>HighPump</name>
<outputID>3</outputID>
<state>AON</state>
<deviceID>3_1</deviceID>
</outlet>
<outlet>
<name>Skimmer</name>
<outputID>4</outputID>
<state>ON</state>
<deviceID>3_2</deviceID>
</outlet>
<outlet>
<name>LowPump</name>
<outputID>5</outputID>
<state>ON</state>
<deviceID>3_3</deviceID>
</outlet>
<outlet>
<name>Heater</name>
<outputID>6</outputID>
<state>AON</state>
<deviceID>3_4</deviceID>
</outlet>
<outlet>
<name>Vortech</name>
<outputID>7</outputID>
<state>AON</state>
<deviceID>3_5</deviceID>
</outlet>
<outlet>
<name>Fan</name>
<outputID>8</outputID>
<state>AOF</state>
<deviceID>3_6</deviceID>
</outlet>
<outlet>
<name>Reactor</name>
<outputID>9</outputID>
<state>AON</state>
<deviceID>3_7</deviceID>
</outlet>
<outlet>
<name>Radion</name>
<outputID>10</outputID>
<state>AOF</state>
<deviceID>3_8</deviceID>
</outlet>
<outlet>
<name>Feed</name>
<outputID>11</outputID>
<state>OFF</state>
<deviceID>Cntl:A1</deviceID>
</outlet>
<outlet>
<name>Maintain</name>
<outputID>12</outputID>
<state>OFF</state>
<deviceID>Cntl:A2</deviceID>
</outlet>
<outlet>
<name>z----</name>
<outputID>13</outputID>
<state>OFF</state>
<deviceID>Cntl:A3</deviceID>
</outlet>
<outlet>
<name>z----------</name>
<outputID>14</outputID>
<state>OFF</state>
<deviceID>Cntl:A4</deviceID>
</outlet>
</outlets>
</status>