extract old value with json

sillicius
Posts: 1
Joined: Sunday 12 February 2017 16:11
Target OS: Raspberry Pi
Domoticz version:
Contact:

extract old value with json

Postby sillicius » Sunday 12 February 2017 16:21

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

[email protected]:/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);
?>

[email protected]:/home/pi/domoticz/scripts# ./extract.php
[email protected]:/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
)

Return to “PHP and all others”

Who is online

Users browsing this forum: No registered users and 1 guest