• Welcome back Guest!

    MARSH is a private reefing group. Comments and suggestions are encouraged, but please keep them positive and constructive. Negative threads, posts, or attacks will be removed from view and reviewed by the staff. Continually disruptive, argumentative, or flagrant rule breakers may be suspended or banned.

Pulling XML data from APEX (1 Viewer)

Users who are viewing this thread

steveb

Staff member
Administrator
Moderator
Board Member
Build Thread Contributor
Joined
Jun 24, 2009
Messages
11,953
Reaction score
2,856
Location
Spring
Hey Programming geniuses -- anyone have php/python/perl code for this? -- mostly concerned with getting the xml data into a variable or array that I can then use.

Basically I want to pull real time probe data from status.xml and parse out the temperature probe data. In particular the Tmp probe below. I then want to use this to talk to my sensibo sky to turn the A/C on in the room.

Sensibo API's
Sensibo Python client

I have a raspberry pi 2 with apache and php installed on it that I want to have do the pulling/pushing.


status.xml info
1565456795832.png
 
Last edited:
OP
OP
steveb

steveb

Staff member
Administrator
Moderator
Board Member
Build Thread Contributor
Joined
Jun 24, 2009
Messages
11,953
Reaction score
2,856
Location
Spring
so some non php/perl/python progress... using what I know...

I'm sure I can refine it more.. this is just playing around on the command line..

wget -q -O status.xml - http://myapex:80/cgi-bin/status.xml <-- Query the Apex


so yeah I got the file...
raspberrypi-1 { ~ }-> more status.xml
<?xml version="1.0"?>
<status software="5.05_7C19" hardware="1.0">
<hostname>StevesReef</hostname>
<serial>AC5:57025</serial>
<timezone>-5.00</timezone>
<date>08/10/2019 13:39:36</date>
<power><failed>08/03/2019 13:39:58</failed>
<restored>08/03/2019 13:40:13</restored></power>
<probes>
<probe>
<name>Tmp</name> <value>78.7 </value>
<type>Temp</type></probe><probe>
<name>TankpH</name> <value>1.58 </value>
<type>pH</type></probe><probe>


Now I need the temp value..
raspberrypi-1 { ~ }-> grep Tmp status.xml|sed 's/<value>//'|sed 's/<name>//'|sed 's/<\/name>//
'|sed 's/<\/value>//'
Tmp 78.7


raspberrypi-1 { ~ }-> grep Tmp status.xml|sed 's/<value>//'|sed 's/<name>//'|sed 's/<\/name>//
'|sed 's/<\/value>//'|awk '{print $2}'
78.7
 
Last edited:
OP
OP
steveb

steveb

Staff member
Administrator
Moderator
Board Member
Build Thread Contributor
Joined
Jun 24, 2009
Messages
11,953
Reaction score
2,856
Location
Spring
raspberrypi-1 { ~ }-> curl http://myapex:80/cgi-bin/status.xml|grep Tmp|sed 's/<value>//'|sed 's/<name>//'|sed 's/<\/name>// '|sed 's/<\/value>//'|awk '{print $2}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4581 0 4581 0 0 96271 0 --:--:-- --:--:-- --:--:-- 120
78.6

so good.. now with silent option
raspberrypi-1 { ~ }-> curl -s http://myapex:80/cgi-bin/status.xml|grep Tmp|sed 's/<value>//'|sed 's/<name>//'|sed 's/<\/name>//
'|sed 's/<\/value>//'|awk '{print $2}'

78.6
 
OP
OP
steveb

steveb

Staff member
Administrator
Moderator
Board Member
Build Thread Contributor
Joined
Jun 24, 2009
Messages
11,953
Reaction score
2,856
Location
Spring
Thanks to some help from the sensibo api facebook group I can now at least see the sensibo!

1565572414421.png

Now my plan is to see if I can turn this sucker on/off using curl. :typing:

Assuming that is successful then I can just throw a bash script together and run a cron job every 10 minutes or so to check tank temp and then act on it.
 
OP
OP
steveb

steveb

Staff member
Administrator
Moderator
Board Member
Build Thread Contributor
Joined
Jun 24, 2009
Messages
11,953
Reaction score
2,856
Location
Spring
Thanks. I don’t know php or xml really but I use shell scripts all the time at work to perform repetitive actions.


Sent from my iPhone using Tapatalk Pro
 
OP
OP
steveb

steveb

Staff member
Administrator
Moderator
Board Member
Build Thread Contributor
Joined
Jun 24, 2009
Messages
11,953
Reaction score
2,856
Location
Spring
Top