Skip to content

Commit

Permalink
Merge pull request #2 from paxal/home
Browse files Browse the repository at this point in the history
Add home automation
  • Loading branch information
alphayax authored Jun 8, 2019
2 parents 6b90f93 + f0bbeb1 commit 824881b
Show file tree
Hide file tree
Showing 23 changed files with 942 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Pour acceder aux services proposés par l'API de la freebox, vous deverez
autoriser votre application. Cette procedure impose que vous soyez connecté
au réseau local de votre Freebox lors de "l'association" et que vous ayez la
Freebox a portée de main. L'application sauvegarde automatiquement le token
retourné par la frebox et cette procedure ne sera plus a reproduire.
retourné par la freebox et cette procedure ne sera plus a reproduire.

Notez que pour modifier les droits d'accès aux differents services, vous deverez
passer par l'interface web locale : [http://mafreebox.freebox.fr/login.php].
Expand Down Expand Up @@ -167,3 +167,11 @@ Les exemples sont disponibles dans le repertoire `exemple`. Ils sont classés pa
- `Partition` : Retourne des infos sur ces disques. Possibilité de verification ou de formatage
- `remote` : Un exemple de connexion distant
- `version` : Affichage de la version de l'API de la freebox

## Freebox Delta et accès aux objets connectés

Pour accéder aux objets connectés, vous devez autoriser l'application à y accéder.
Pour ce faire, allez dans l'interface d'administration de la freebox après avoir
obtenu votre clé API, puis rendez vous dans `Paramètres de la Freebox` /
`Gestion des accès` / `Application` puis autorisez
`Gestion de l'alarme et maison connectée`.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"api",
"rest",
"Freebox revolution",
"Freebox delta",
"download"
],
"require": {
Expand Down
1 change: 1 addition & 0 deletions docs/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

generateDocForService("v3");
generateDocForService("v4");
generateDocForService("v6");
generateDocForService("common");


Expand Down
49 changes: 49 additions & 0 deletions docs/services_v6/Home/__NAMESPACE__.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# Home

**Namespace** : alphayax\freebox\api\v6\services\Home

# Overview

- [Tileset](__NAMESPACE__.md#Tileset)
- [EndpointValues](__NAMESPACE__.md#EndpointValues)
- [Nodes](__NAMESPACE__.md#Nodes)


---
<a name="Tileset"></a>
## Tileset

**Class** : alphayax\freebox\api\v6\services\Home\Tileset

### Public methods

| Method | Description |
|---|---|
| `getTiles` | Retrieve all tiles. |
| `getTile` | Get single tile. |

<a name="EndpointValues"></a>
## EndpointValues

**Class** : alphayax\freebox\api\v6\services\Home\EndpointValues

### Public methods

| Method | Description |
|---|---|
| `getEndpointValue` | Get endpoint value. |
| `setEndpointValue` | Set endpoint value. |

<a name="Nodes"></a>
## Nodes

**Class** : alphayax\freebox\api\v6\services\Home\Nodes

### Public methods

| Method | Description |
|---|---|
| `getAll` | Retrieve all nodes. |
| `getNode` | Retrieve one node. |

14 changes: 14 additions & 0 deletions docs/services_v6/__NAMESPACE__.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# services

**Namespace** : alphayax\freebox\api\v6\services

# Overview

- [Home](./Home/__NAMESPACE__.md)
- [Tileset](Home/__NAMESPACE__.md#Tileset)
- [EndpointValues](Home/__NAMESPACE__.md#EndpointValues)
- [Nodes](Home/__NAMESPACE__.md#Nodes)


---
30 changes: 30 additions & 0 deletions exemple/Home/Nodes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/// Require Composer AutoLoader
require_once dirname(__FILE__).'/../../vendor/autoload.php';

/// Define our application
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.os', 'AYX Freebox OS', '1.0.0');
$App->loadAppToken();
$App->openSession();

$nodeService = new \alphayax\freebox\api\v6\services\Home\Nodes($App);
$nodes = $nodeService->getAll();

$nbNodes = count($nodes);
echo "Found ".$nbNodes." nodes.".PHP_EOL;
if ($nbNodes > 0) {
echo "First node :".PHP_EOL;
var_dump(current($nodes));
}
echo PHP_EOL;
echo PHP_EOL;

$tileService = new \alphayax\freebox\api\v6\services\Home\Tileset($App);
$tiles = $tileService->getTiles();
$nbTiles = count($tiles);
echo "Found ".$nbTiles." tiles.".PHP_EOL;
if ($nbTiles > 0) {
echo "First tile :".PHP_EOL;
var_dump(current($tiles));
}
110 changes: 110 additions & 0 deletions freebox/api/v6/models/Home/Endpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
namespace alphayax\freebox\api\v6\models\Home;

use alphayax\freebox\utils\Model;

class Endpoint extends Model
{
/**
* @var string (Read-Only) : The endpoint type
* @see \alphayax\freebox\api\v6\symbols\Node\Enpoint\Type
*/
protected $ep_type;

/** @var int (Read-Only) : The endpoint id */
protected $id;

/**
* @var string (Read-Only) : Visibility level of this endpoint
* @see
*/
protected $visibility;

/** @var string (Read-Only) : The endpoint displayable type */
protected $label;

/** @var string (Read-Only) : The endpoint technical name */
protected $name;

/** @var string (Read-Only) : The current value of the endpoint */
protected $value;

/**
* @var string (Read-Only) : The type of value this endpoint expose
* @see \alphayax\freebox\api\v6\symbols\Node\Enpoint\ValueType
*/
protected $value_type;

/** @var EndpointUi (Read-Only) : Ui descriptor for this data to know how to display it */
protected $ui;

public function __construct($properties_x = [])
{
parent::__construct($properties_x);
$this->initProperty('ui', EndpointUi::class);
}

/**
* @return string
*/
public function getEpType()
{
return $this->ep_type;
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getVisibility()
{
return $this->visibility;
}

/**
* @return string
*/
public function getLabel()
{
return $this->label;
}

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @return string
*/
public function getValue()
{
return $this->value;
}

/**
* @return string
*/
public function getValueType()
{
return $this->value_type;
}

/**
* @return EndpointUi
*/
public function getUi()
{
return $this->ui;
}
}
145 changes: 145 additions & 0 deletions freebox/api/v6/models/Home/EndpointUi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?php
namespace alphayax\freebox\api\v6\models\Home;

use alphayax\freebox\utils\Model;

class EndpointUi extends Model
{
/**
* @var string (Read-Only) : Display mode of this data
* @see \alphayax\freebox\api\v6\symbols\Node\Enpoint\EndpointUiDisplay
*/
protected $display;

/**
* @var string (Read-Only) : Access mode of this endpoint
* @see \alphayax\freebox\api\v6\symbols\Node\Enpoint\HomeAccess
*/
protected $access;

/** @var string|null (Read-Only) : Url or name of the icon to display. The icon may be displayed for any value of “display”. */
protected $icon_url;

/** @var string|null (Read-Only) : The unit of the value to display. */
protected $unit;

/** @var string|null (Read-Only) : The hexadecimal presentation of the tint to apply to the icon fetched from “icon_url”. */
protected $icon_color;

/** @var string|null (Read-Only) : The hexadecimal presentation of the color of this endpoint label. */
protected $text_color;

/** @var string|null (Read-Only) : The hexadecimal presentation of the color of this endpoint value. */
protected $value_color;

/** @var float[]|int[]|null (Read-Only) : Range of array of threshold values for this endpoint value. */
protected $range;

/** @var string[]|null (Read-Only) : A range of colors to choose from instead of “icon_color”. The index in the range is the index in the “range” array which is just below the endpoint value. */
protected $icon_color_range;

/** @var string[]|null (Read-Only) : A range of colors to choose from instead of “text_color”. The index in the range is the index in the “range” array which is just below the endpoint value. */
protected $text_color_range;

/** @var string[]|null (Read-Only) : A range of colors to choose from instead of “value_color”. The index in the range is the index in the “range” array which is just below the endpoint value. */
protected $value_color_range;

/** @var string[]|null (Read-Only) : Text values to display instead of the value itself. The index in the range is the index in the “range” array which is just below the endpoint value. */
protected $status_text_range;

/**
* @return string
*/
public function getDisplay()
{
return $this->display;
}

/**
* @return string
*/
public function getAccess()
{
return $this->access;
}

/**
* @return string|null
*/
public function getIconUrl()
{
return $this->icon_url;
}

/**
* @return string|null
*/
public function getUnit()
{
return $this->unit;
}

/**
* @return string|null
*/
public function getIconColor()
{
return $this->icon_color;
}

/**
* @return string|null
*/
public function getTextColor()
{
return $this->text_color;
}

/**
* @return string|null
*/
public function getValueColor()
{
return $this->value_color;
}

/**
* @return float[]|int[]|null
*/
public function getRange()
{
return $this->range;
}

/**
* @return string[]|null
*/
public function getIconColorRange()
{
return $this->icon_color_range;
}

/**
* @return string[]|null
*/
public function getTextColorRange()
{
return $this->text_color_range;
}

/**
* @return string[]|null
*/
public function getValueColorRange()
{
return $this->value_color_range;
}

/**
* @return string[]|null
*/
public function getStatusTextRange()
{
return $this->status_text_range;
}
}
8 changes: 8 additions & 0 deletions freebox/api/v6/models/Home/EndpointValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
namespace alphayax\freebox\api\v6\models\Home;

use alphayax\freebox\utils\Model;

class EndpointValue extends Model
{
}
Loading

0 comments on commit 824881b

Please sign in to comment.