Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to read multiple status stored in .xml file? #75

Open
githubberboy opened this issue Oct 12, 2017 · 2 comments
Open

Possible to read multiple status stored in .xml file? #75

githubberboy opened this issue Oct 12, 2017 · 2 comments

Comments

@githubberboy
Copy link

githubberboy commented Oct 12, 2017

I've a status.xml file that contain multiple status values, like this:

<response>
<natOut1>1</natOut1>`
<natOut2>0</natOut2>
<natOut3>1</natOut3>
<natOut4>1</natOut4>
<natIn1>1</natIn1>
<natIn2>0</natIn2>
<natIn3>1</natIn3>
<natIn4>0</natIn4>
</response>

It is possible to read the 1|0 inside <natOut> <natIn> ?

Thanks.

@arlettazm
Copy link

I i have the same request? any solution?
Thanks

@troystanway
Copy link

troystanway commented Jan 21, 2018

I've had a similar need trying to read status from my OpenSprinkler. The best way I could think up was to use a PHP script to read the values. If the output is always the same, except for the 1/0 variables you could use substr to interpret the values.

It outputs like this {"sn":[0,0,0,0,0,0,0,0],"nstations":8}

Then this script looks for the 8th character, length 1. And returns that value when you go to this php file on your web server:

<?php $ctx=stream_context_create(array('http'=> array( 'timeout' => 1 // 1 sec ) )); $url = file_get_contents('<URL HERE>', false, $ctx); $output = substr(".$url.", 8, 1); echo $output; ?>

I know this solution requires lots of counting, but as long as the output doesn't change its structure this does work. You would need 1 PHP script per http device, 1 status per device. And you would need to alter the value 8 to which ever position value you are looking for, count it out and then put in that number. But its just a suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants