Page 1 of 1

extract old value with json

Posted: Sunday 12 February 2017 15:21
by sillicius
Hello,

i try to extract with json old value from gps sensor. The data is a text string (idx 1 -> latitude and idx 3 -> longitude).

i receive only the last value, but i would get all the values between two date. I don't understand how i can do that :? .

Thank for your help

Code: Select all

root@raspberrypi:/home/pi/domoticz/scripts# cat extract.php
#!/usr/bin/php
<?php
$json_string = file_get_contents("http://192.168.1.17:8080/json.htm?type=devices&rid=3");
$parsed_json = json_decode($json_string, true);
$test_link = "/home/pi/domoticz/scripts/test_1.txt";
$test_data = fopen ($test_link, "w+");
fwrite ($test_data, print_R($parsed_json, TRUE));
fclose ($test_data);
?>

root@raspberrypi:/home/pi/domoticz/scripts# ./extract.php
root@raspberrypi:/home/pi/domoticz/scripts# cat test_1.txt
Array
(
    [ActTime] => 1486907791
    [ServerTime] => 2017-02-12 13:56:31
    [Sunrise] => 06:41
    [Sunset] => 17:03
    [result] => Array
        (
            [0] => Array
                (
                    [AddjMulti] => 1
                    [AddjMulti2] => 1
                    [AddjValue] => 0
                    [AddjValue2] => 0
                    [BatteryLevel] => 255
                    [CustomImage] => 0
                    [Data] => 5.440743
                    [Description] =>
                    [Favorite] => 0
                    [HardwareID] => 3
                    [HardwareName] => GATEWAY
                    [HardwareType] => MySensors Gateway USB
                    [HardwareTypeVal] => 41
                    [HaveTimeout] =>
                    [ID] => 00000302
                    [LastUpdate] => 2017-02-04 12:06:42
                    [Name] => Longitude
                    [Notifications] => false
                    [PlanID] => 0
                    [PlanIDs] => Array
                        (
                            [0] => 0
                        )

                    [Protected] =>
                    [ShowNotifications] =>
                    [SignalLevel] => -
                    [SubType] => Text
                    [Timers] => false
                    [Type] => General
                    [TypeImg] => text
                    [Unit] => 1
                    [Used] => 1
                    [XOffset] => 0
                    [YOffset] => 0
                    [idx] => 3
                )

        )

    [status] => OK
    [title] => Devices
)

Re: extract old value with json

Posted: Monday 13 March 2017 16:41
by Egregius