ICloud HC2 Bridge

Utvecklar du en smartphone-app? Datorprogramvara? Få hjälp av andra och bidra med dina egna erfaranheter.
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Hej Gott Folk.
Efter en tid har jag letat efter en (bra) lösning för att spåra telefoner (Iphone) och dess position.
Befintliga lösningar har inte fungerat tillfredställande.

Så här kommer min lösning. Fortfarande under arbete men bör fungera.
Metoden bygger på att hämta koordinaterna från iCloud (Hitta min iPhone).
Jag kör scriptet på min lokala server.

Senare kommer jag även lägga till batterinivå och annat gott.

Om nån vill vara med och bidra (finns instruktioner för att komma igång)
https://github.com/raess1/iCloud-HC2-Bridge




index.php

Code: Select all

<?PHP
	
    //Save data to Home Centar 2
	$url = 'http://user:password@dittip/api/globalVariables';

	function setGlobal($globalVariables, $value)
	{
		$curl = curl_init();

		curl_setopt_array($curl, array(
		  CURLOPT_URL => "http://dittip/api/globalVariables/".$globalVariables,
		  CURLOPT_RETURNTRANSFER => true,
		  CURLOPT_ENCODING => "",
		  CURLOPT_MAXREDIRS => 10,
		  CURLOPT_TIMEOUT => 30,
		  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		  CURLOPT_CUSTOMREQUEST => "PUT",
		  CURLOPT_POSTFIELDS => '{"value":"'.$value.'"}',
		  CURLOPT_HTTPHEADER => array(
		    "authorization: Basic asdagsdgsdfsfs=",
		    "cache-control: no-cache",
		    "content-type: application/json",
		    "postman-token: 60c9034f-7294-f178-a440-8d6d23d23ddc"
		  ),
		));

		$response = curl_exec($curl);
		$err = curl_error($curl);

		curl_close($curl);

		if ($err) {
		  echo "cURL Error #:" . $err;
		} else {
		  return $response;
		};
	}

	// This should properly display device names that contain special characters
	header("Content-type: text/html; charset=utf-8");

	// This will prevent any errors that occur from potentially displaying your username/password
	error_reporting(1);


	$phone_id = 'ID';
	

	// Include the FindMyiPhone class
	include ("class.findmyiphone.php");
	
	// This is where we log in to iCloud
	try {
		$fmi = new FindMyiPhone("iClouduser","password");
	} catch (Exception $e) {
		print "Error: ".$e->getMessage();
		exit;
	}

	$devices = $fmi->listDevices();
	/*
	foreach ($devices as $key => $device) {
		if($key == $phone_id){
			$latitude = $device->API['location']['latitude'];
			$longitude = $device->API['location']['longitude'];



			setGlobal('location_latitude',$latitude);
			setGlobal('location_longitude',$longitude);
		}
	}*/

	/*

	[latitude] => 58.2994802739
                    [horizontalAccuracy] => 8
                    [locationType] => 
                    [longitude] => 14.2716976115
                    */

	$delta = 0.001;//chnage this
	//centar of home
	$lat['min']=58.2994752034 - $delta;
	$lat['max']=58.2994802739 + $delta;
	$long['min']=14.2716976115 - $delta;
	$long['max']=14.2716976115 + $delta;

	$home = 0;

	foreach ($devices as $key => $device) {

		//debug
		$device_name = $device->displayName;
		$location = $device->API['location'];

		ddd('device', $device_name); ddd('location', $location);
		//end dubug

		$latitude = $device->API['location']['latitude'];
		$longitude = $device->API['location']['longitude'];

		if($latitude > $lat['min'] and $latitude < $lat['max'] and $longitude > $long['min'] and $longitude < $long['max'] )
		{
			$home = 1;
		}
	}

	$result = setGlobal('home',$home);
	ddd('result', $result);


	function ddd($context, $var){
		echo '<pre>';
		print_r($var);
		echo '</pre>';	
	}
class.findmyiphone.php

Code: Select all

<?PHP

/*
 Copyright (C) Alan Beebe (alan.beebe@gmail.com).
 
 Licensed under the Apache License, Version 2.0 (the "License");
 
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

  v1.0 - January 2, 2015
  
*/
 
class FindMyiPhone {

	private $client = array(
						"app-version" => "4.0",
						"user-agent" => "FindMyiPhone/472.1 CFNetwork/711.1.12 Darwin/14.0.0",
						"headers" => array(
							"X-Apple-Realm-Support" => "1.0",
							"X-Apple-Find-API-Ver" => "3.0",
							"X-Apple-AuthScheme" => "UserIdGuest"
						)
					  );
	private $debug;
	private $username;
	private $password;
	private $Apple_MMe_Host;
	private $Apple_MMe_Scope;
	public $devices = array();
	
	/**
     * This is where you initialize FindMyiPhone with your iCloud credentials
     * Example: $fmi = new FindMyiPhone("you@example.com", "MyPassWord123");
     *
     * @param username	iCloud username
     * @param password	iCloud password
     * @param debug		(Optional) Set to TRUE and all the API requests and responses will be printed out
     * @return          FindMyiPhone instance 
     */
	public function __construct($username, $password, $debug = false) {
		$this->username = $username;
		$this->password = $password;
		$this->debug = $debug;
		$this->authenticate();
	}
	
	/**
     * This method attempts to get the most current location of a device
     * Example: $fmi->locate("dCsaBcqBOdnNop4wvy2VfIk8+HlQ/DRuqrmiwpsLdLTuiCORQDJ9eHYVQSUzmWV", 30);
     *
     * @param deviceID	ID of the device you want to locate
     * @param timeout	(Optional) Maximum number of seconds to spend trying to locate the device
     * @return          FindMyiPhoneLocation object 
     */
	public function locate($deviceID, $timeout = 60) {
		$startTime = time();
		$initialTimestamp = $this->devices[$deviceID]->location->timestamp;
		while ($initialTimestamp == $this->devices[$deviceID]->location->timestamp) {
			if ((time() - $startTime) > $timeout) break;
			$this->refreshDevices($deviceID);
			sleep(5);
		}
		return $this->devices[$deviceID]->location;
	}
	
	/**
     * Play a sound and display a message on a device
     * Example: $fmi->playSound("dCsaBcqBOdnNop4wvy2VfIk8+HlQ/DRuqrmiwpsLdLTuiCORQDJ9eHYVQSUzmWV", "Whats up?");
     *
     * @param deviceID	ID of the device you want to play a sound
     * @param message	Message you want displayed on the device
     */
	public function playSound($deviceID, $message) {
		$url = "https://".$this->Apple_MMe_Host."/fmipservice/device/".$this->Apple_MMe_Scope."/playSound";
		$body = json_encode(array("device"=>$deviceID, "subject"=>$message)); 
		list($headers, $body) = $this->curlPOST($url, $body, $this->username.":".$this->password);
	}
	
	/**
     * Put a device into lost mode. The device will immediately lock until the user enters the correct passcode
     * Example: $fmi->lostMode("dCsaBcqBOdnNop4wvy2VfIk8+HlQ/DRuqrmiwpsLdLTuiCORQDJ9eHYVQSUzmWV", "You got locked out", "555-555-5555");
     *
     * @param deviceID		ID of the device you want to lock
     * @param message		Message you want displayed on the device
     * @param phoneNumber	(Optional) Phone number you want displayed on the lock screen
     */
	public function lostMode($deviceID, $message, $phoneNumber = "") {
		$url = "https://".$this->Apple_MMe_Host."/fmipservice/device/".$this->Apple_MMe_Scope."/lostDevice";
		$body = json_encode(array("device"=>$deviceID, "ownerNbr"=>$phoneNumber, "text"=>$message, "lostModeEnabled"=>true)); 
		list($headers, $body) = $this->curlPOST($url, $body, $this->username.":".$this->password);
	}


	public function listDevices(){
		if (sizeof($this->devices) == 0) $this->getDevices();

		return $this->devices;

	}

	/**
     * Print all the available information for every device on the users account.
     * This is really useful when you want to get the ID for a device.
     * Example: $fmi->printDevices();
     */
	public function printDevices() {
		if (sizeof($this->devices) == 0) $this->getDevices();
		print <<<TABLEHEADER
        		<PRE>
        		<TABLE BORDER="1" CELLPADDING="3">
        			<TR>
        				<TD VALIGN="top"><B>ID</B></TD>
        				<TD VALIGN="top"><B>name</B></TD>
        				<TD VALIGN="top"><B>displayName</B></TD>
        				<TD VALIGN="top"><B>location</B></TD>
        				<TD VALIGN="top"><B>class</B></TD>
        				<TD VALIGN="top"><B>model</B></TD>
        				<TD VALIGN="top"><B>modelDisplayName</B></TD>
        				<TD VALIGN="top"><B>batteryLevel</B></TD>
        				<TD VALIGN="top"><B>batteryStatus</B></TD>
        			</TR>
TABLEHEADER;
		foreach ($this->devices as $device) {
			$location = <<<LOCATION
			<TABLE BORDER="1">
				<TR>
					<TD VALIGN="top">timestamp</TD>
					<TD VALIGN="top">{$device->location->timestamp}</TD>
				</TR>
				<TR>
					<TD VALIGN="top">horizontalAccuracy</TD>
					<TD VALIGN="top">{$device->location->horizontalAccuracy}</TD>
				</TR>
				<TR>
					<TD VALIGN="top">positionType</TD>
					<TD VALIGN="top">{$device->location->positionType}</TD>
				</TR>
				<TR>
					<TD VALIGN="top">longitude</TD>
					<TD VALIGN="top">{$device->location->longitude}</TD>
				</TR>
				<TR>
					<TD VALIGN="top">latitude</TD>
					<TD VALIGN="top">{$device->location->latitude}</TD>
				</TR>
			</TABLE>
LOCATION;
			print <<<DEVICE
					<TR>
        				<TD VALIGN="top">{$device->ID}</TD>
        				<TD VALIGN="top">{$device->name}</TD>
        				<TD VALIGN="top">{$device->displayName}</TD>
        				<TD VALIGN="top">$location</TD>
        				<TD VALIGN="top">{$device->class}</TD>
        				<TD VALIGN="top">{$device->model}</TD>
        				<TD VALIGN="top">{$device->modelDisplayName}</TD>
        				<TD VALIGN="top">{$device->batteryLevel}</TD>
        				<TD VALIGN="top">{$device->batteryStatus}</TD>
        			</TR>
DEVICE;
		}
		print <<<TABLEFOOTER
        		</TABLE>
        		</PRE>
TABLEFOOTER;
	}
	
	/**
	 *  This is where the users credentials are authenticated.
	 *  The Apple_MMe_Host and Apple_MMe_Scope values are saved and used to generate the URL for all subsequent API calls
	 */
	private function authenticate() {
		$url = "https://fmipmobile.icloud.com/fmipservice/device/".$this->username."/initClient";
		list($headers, $body) = $this->curlPOST($url, "", $this->username.":".$this->password);
		$this->Apple_MMe_Host = $headers["X-Apple-MMe-Host"];
		$this->Apple_MMe_Scope = $headers["X-Apple-MMe-Scope"];
		if ($headers["http_code"] == 401) {
			throw new Exception('Your iCloud username and/or password are invalid');
		}
	}
	
	/**
     * This is where all the devices are downloaded and processed
     * Example: print_r($fmi->devices)
     */
	private function getDevices() {
		$url = "https://".$this->Apple_MMe_Host."/fmipservice/device/".$this->Apple_MMe_Scope."/initClient";
		list($headers, $body) = $this->curlPOST($url, "", $this->username.":".$this->password);
		$this->devices = array();
		for ($x = 0; $x < sizeof($body["content"]); $x++) {
			$device = $this->generateDevice($body["content"][$x]);
			$this->devices[$device->ID] = $device;
		}
	}
	
	/**
	 * This method takes the raw device details from the API and converts it to a FindMyiPhoneDevice object
	 */
	private function generateDevice($deviceDetails) {
		$device = new FindMyiPhoneDevice();	
		$device->API = $deviceDetails;
		$device->ID = $device->API["id"];
		$device->batteryLevel = $device->API["batteryLevel"];
		$device->batteryStatus = $device->API["batteryStatus"];
		$device->class = $device->API["deviceClass"];
		$device->displayName = $device->API["deviceDisplayName"];
		$device->location = new FindMyiPhoneLocation();
		$device->location->timestamp = $device->API["location"]["timeStamp"];
		$device->location->horizontalAccuracy = $device->API["location"]["horizontalAccuracy"];
		$device->location->positionType = $device->API["location"]["positionType"];
		$device->location->longitude = $device->API["location"]["longitude"];
		$device->location->latitude = $device->API["location"]["latitude"];
		$device->model = $device->API["rawDeviceModel"];
		$device->modelDisplayName = $device->API["modelDisplayName"];
		$device->name = $device->API["name"];
		return $device;
	}
	
	/**
	 * This method refreshes the list of devices on the users iCloud account
	 */
	private function refreshDevices($deviceID = "") {
		$url = "https://".$this->Apple_MMe_Host."/fmipservice/device/".$this->Apple_MMe_Scope."/refreshClient";
		if (strlen($deviceID) > 0) {
			$body = json_encode(array("clientContext"=>array("appVersion"=>$this->client["app-version"], "shouldLocate"=>true, "selectedDevice"=>$deviceID, "fmly"=>true)));
		}
		list($headers, $body) = $this->curlPOST($url, $body, $this->username.":".$this->password);
		$this->devices = array();
		for ($x = 0; $x < sizeof($body["content"]); $x++) {
			$device = $this->generateDevice($body["content"][$x]);
			$this->devices[$device->ID] = $device;
		}
	}
	
	/**
	 * Helper method for making POST requests
	 */
	private function curlPOST($url, $body, $authentication = "") {
		$ch = curl_init($url);                                                                      
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
		curl_setopt($ch, CURLOPT_POSTFIELDS, $body);                                                                  
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_VERBOSE, 1);
		curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch, CURLOPT_USERAGENT, $this->client["user-agent"]);
		if (strlen($authentication) > 0) {
			curl_setopt($ch, CURLOPT_USERPWD, $authentication);  
		}
		$arrHeaders = array();
		$arrHeaders["Content-Length"] = strlen($request);
		foreach ($this->client["headers"] as $key=>$value) {
			array_push($arrHeaders, $key.": ".$value);
		}
		curl_setopt($ch, CURLOPT_HTTPHEADER, $arrHeaders);
		$response = curl_exec($ch);
		$info = curl_getinfo($ch);
		$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
		$responseBody = substr($response, $header_size);
		$headers = array();
		foreach (explode("\r\n", substr($response, 0, $header_size)) as $i => $line) {
			if ($i === 0)
            	$headers['http_code'] = $info["http_code"];
			else {
            	list ($key, $value) = explode(': ', $line);
            	if (strlen($key) > 0)
	            	$headers[$key] = $value;
			}
        }
        if ($this->debug) {
        	$debugURL = htmlentities($url);
        	$debugRequestBody = htmlentities(print_r(json_decode($body, true), true));
        	$debugHeaders = htmlentities(print_r($headers, true));
        	$debugResponseBody = htmlentities(print_r(json_decode($responseBody, true), true));
        	print <<<HTML
        		<PRE>
        		<TABLE BORDER="1" CELLPADDING="3">
        			<TR>
        				<TD VALIGN="top"><B>URL</B></TD>
        				<TD VALIGN="top">$debugURL</TD>
        			</TR>
        			<TR>
        				<TD VALIGN="top"><B>Request Body</B></TD>
        				<TD VALIGN="top"><PRE>$debugRequestBody</PRE></TD>
        			</TR>
        			<TR>
        				<TD VALIGN="top"><B>Response Headers</B></TD>
        				<TD VALIGN="top"><PRE>$debugHeaders</PRE></TD>
        			</TR>
        			<TR>
        				<TD VALIGN="top"><B>Response Body</B></TD>
        				<TD VALIGN="top"><PRE>$debugResponseBody</PRE></TD>
        			</TR>
        		</TABLE>
        		</PRE>
HTML;
        }
		return array($headers, json_decode($responseBody, true));
	}
}


class FindMyiPhoneDevice {
	public $ID;
	public $batteryLevel;
	public $batteryStatus;
	public $class;
	public $displayName;
	public $location;
	public $model;
	public $modelDisplayName;
	public $name;
	public $API;
}


class FindMyiPhoneLocation {
	public $timestamp;
	public $horizontalAccuracy;
	public $positionType;
	public $longitude;
	public $latitude;
}
ih.jpg
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Edit:
I senaste versionen på Github har jag även lagt till
1. batteri status
2. Status på om telefonen sitter laddas eller ej.
3. Timestamp på när datan senast hämtades.

Saker som ska läggas till:
skapa en variabel som ska printa adressen på koordinaterna där telefonen befinner sig.

Samt att konvertera timestamp till någon mer läsvänligt. ;-)

God jul
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Update:
Nu kan man även se vart telefonen befinner sig.
iPhone vd
iPhone vd
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Grymt! Hur kör du sen php scriptet? Hur ofta?
Hur e det med batterikonsumtionen i telefonen?


Sent from my iPhone using Tapatalk
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

KristianO wrote:Grymt! Hur kör du sen php scriptet? Hur ofta?
Hur e det med batterikonsumtionen i telefonen?


Sent from my iPhone using Tapatalk
Jag kör launch control. Ställde in ett jobb som körs varje minut (Kan ju ändra till mindre/mer frekvent beroende på hur ofta du vill få informationen. [OK HAND SIGN]

Jag har inte märkt något skillnad på batterikonsumtionen då den använder iOS egna gps. Har man redan hitta min iPhone och platsinformation på så tror jag inte det har någon betydande negativ effekt på batterikonsumtionen.


Skickat från min iPhone med Tapatalk
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Soma-zones launch control?
Din vd för nerladdning?
Tänkte köra med 2 användare, bara att uppdatera globala variabler att vara unika va?


Sent from my iPhone using Tapatalk
maxxar
Medlem
Posts: 126
Joined: 06 Sep 2012, 13:30
11

Detta var ju rätt coolt, vad kan man mer få ut för info från icloud? Vore ju nice om man kunde få ut ex. alarm som är satta m.m.
Med detta kan man ju trigga funktioner ex.vis när telefoner sätts på laddning
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

KristianO wrote:Soma-zones launch control?
Din vd för nerladdning?
Tänkte köra med 2 användare, bara att uppdatera globala variabler att vara unika va?


Sent from my iPhone using Tapatalk
Yes, soma-zones.
Jag kan lägga upp min VD på git så kan vi hjälpas åt att optimera den. Fixar det om någon timme.

Det ska funka att hitta alla enheter på kontot. dock har jag inte kommit så långt :-)
kanske problem om dom inte ligger på samma iCloud.
Dock kan man ju använda två olika script för resp. iCloud konto och sätta två olika variabler för varje telefon, sedan en tredje variabel (hemma = 1 if Bob_telefon = 1 or Kelso_telefon = 1.)




Skickat från min iPhone med Tapatalk
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

maxxar wrote:Detta var ju rätt coolt, vad kan man mer få ut för info från icloud? Vore ju nice om man kunde få ut ex. alarm som är satta m.m.
Med detta kan man ju trigga funktioner ex.vis när telefoner sätts på laddning
Jag vet iaf att man kan plocka horizontalAccuracy och postionstype.


horizontalAccuracy vilken precision datan har, tex felmarginal 300M

Postiontype om telefonen hämtade data via wi-fi eller gsm

Ja nu kan man sätta upp lite nya roliga funktioner. Till pusha telefon två om telefon 1 behöver laddas.

Eller varför inte räkna ut avstånden mellan två olika telefoner

Eller avstånd från hemmet till telefonen.

;-)



Skickat från min iPhone med Tapatalk
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Snyggast att köra ett script och låta alla enheter lokaliseras. Tex så använder jag och frugan delad Find Friends. Med 2 olika konton. Så borde gå att hitta alla dessa enheter då de finns på mitt konto.


Sent from my iPhone using Tapatalk
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Update:
Har lagt till:
Found with
Accuracy Range
Home since / away since.
Samt lite mindre justering av olika enhetstecken och annat.

Någon som vet hur man konverterar tiderna till något mer läsvänligt?


Jag delar VD:en efter önskemål (dock är den inte färdig och detta är min första VD :D
vd
vd

Code: Select all

local vd = 174 --Denna virtuella ID's nummer 

local battery_status = fibaro:getGlobalValue("battery_status")
local address_location = fibaro:getGlobalValue("address_location")
local battery_level = fibaro:getGlobalValue("battery_level")
local home = fibaro:getGlobalValue("home")
local timeStamp = fibaro:getGlobalValue("timeStamp")
local position_type = fibaro:getGlobalValue("position_type")
local phone_accuracy = fibaro:getGlobalValue("phone_accuracy")


fibaro:call(vd, 'setProperty', 'ui.Location.value',address_location)
--fibaro:debug("Your are here: "..address_location)
fibaro:call(vd, 'setProperty', 'ui.status.value',battery_status)
--fibaro:debug("Is your phone charging: "..battery_status)
fibaro:call(vd, 'setProperty', 'ui.level.value',battery_level * 100 .. " %")
--fibaro:debug("Percentage of battery: "..battery_level * 100)
--fibaro:call(vd, 'setProperty', 'ui.home.value',home)
--fibaro:debug("Are the phone home "..home)
fibaro:call(vd, 'setProperty', 'ui.timestamp.value',timeStamp)
--fibaro:debug("Time is now: "..timeStamp)
fibaro:call(vd, 'setProperty', 'ui.positiontype.value',position_type)
--fibaro:debug("You get your data with: "..position_type)
fibaro:call(vd, 'setProperty', 'ui.horizontalAccuracy.value', phone_accuracy .. " M")
--fibaro:debug("How accurate is GPS data: "..phone_accuracy)

if ( tonumber(fibaro:getGlobalValue("home")) == 0 ) then
    fibaro:call(vd, "setProperty", "ui.home.value", "No")
	fibaro:call(vd, "setProperty", "ui.lastseen.value", "Away Since "..os.time())
else
    fibaro:call(vd, "setProperty", "ui.home.value", "Yes")
  	fibaro:call(vd, "setProperty", "ui.lastseen.value", "Home Since "..os.time())
end
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Hur vet den föresten att jag e hemma? Behöver jag sätta hemma lat/long?


Sent from my iPhone using Tapatalk
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Precis.
Ändra dessa:

Code: Select all

$delta = 0.001;//change this if need of bigger area
	//centar of home
	$lat['min']=58.2994752034 - $delta;
	$lat['max']=58.2994802739 + $delta;
	$long['min']=14.2716976115 - $delta;
	$long['max']=14.2716976115 + $delta;
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Update:
Nu räknar den ut avstånden från telefonen och hemmet (just nu i km) :lol:
distance
distance
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Grymt!

- 0.001 motsvarar i meter?
- Kanske skall lägga in att om batteriet är noll alt telefon är avstängd att inte hc2 får någon update av variabler?
- Kollade även familjedelning och de enheter dyker tyvärr inte upp som devices här. Hm..,
- Kan du lägga upp din vd på github?
- Ändra globalvariabeln Hemma till Yes/No för att slippa extra tolkning i vd?


Sent from my iPhone using Tapatalk
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

-0.0001 hur finkänslig. Alltså vilken koordinat som behöver ändras för den ska anses som borta.

Ny funktion: (Time home)
Räkna av avstånden från din hemadress och din telefon och få tillbaka beräknad tid det tar att köra.
Data beräknas via google.


Senaste koden finns på git.
time
time
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Jag ska lägga upp VD:en på git. Men tyvärr har jag inte haft tid bara. Försöker göra det ikväll :D
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Detta blir grymt!

Nu återstår bara att få till 2 användare i samma script alt köra 2 script men att då låta variablerna bli unika med användaren.
Som ett prefix alt unikt nummer per telefon.
Ex. 1_home, 1_battery_status

Sen hade det varit snyggt att skapa variablerna dynamiskt från scriptet.

Tror även InvokeScenes måste användas vid ändring av variabel om den skall trigga en scene vid ändring.

Bra också med tiden hem, när det är mindre än 5 min kvar... Tänd upp hemmet!
bobkelso_527
Medlem
Posts: 48
Joined: 23 Dec 2016, 14:24
7

Nu har jag varit ute och åkt lite och såg att adressen inte uppdaterades korrekt.

Hittat felet och åtgärdat det. Lägger upp det på git ikväll ;-)
KristianO
Medlem
Posts: 461
Joined: 10 Mar 2014, 09:50
10

Sweet! Då fixar du till ovan också? [FISTED HAND SIGN]


Sent from my iPhone using Tapatalk
Post Reply