@sbr bonjour,
Je regardes ce que tu as ajouté mais j'ai une question.
desktop/js/tvphillips.php : il n'y a pas ce fichier dans js, ne serait ce pas plutôt dans desktop/php/tvphillips.php ?
Dans la même partie :
Tu as oublié de mettre [/code]après le :
<!-- Ligne 164 : Fin Ajout sbr -->
ICI
Si je reprends :
sbr a écrit : ↑12 sept. 2019, 00:35
Ci-dessous mes modifs de code pour rendre disponible cette fonctionnalité, j'espère que l'auteur du plugin pourra les intégrer
desktop/js/tvphillips.js
Code : Tout sélectionner
/* Ligne 660 : Debut Ajout sbr */
function getKey( ) {
$('.eqLogicAttr[data-l1key=configuration][data-l2key=user]').val(Date.now());
$.ajax({
url: "plugins/tvphillips/core/ajax/tvphillips.php",
dataType: 'json',
type: 'post',
data: {
"action" : "pair",
"ip" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=IPaddress]').val(),
"user" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=user]').val()
},
complete : function(resultat){
console.log("*** COMPLETE ***");
console.log(resultat);
var data = JSON.parse(resultat.responseText);
var obj = JSON.parse(data.result);
console.log(obj);
if( obj.error_id == "SUCCESS" ) {
$('.eqLogicAttr[data-l1key=configuration][data-l2key=auth_key]').val( obj.auth_key );
$('.eqLogicAttr[data-l1key=configuration][data-l2key=timestamp]').val( obj.timestamp );
$('.eqLogicAttr[data-l1key=configuration][data-l2key=timeout]').val( obj.timeout );
}
}
});
}
function getToken( ) {
$.ajax({
url: "plugins/tvphillips/core/ajax/tvphillips.php",
dataType: 'json',
type: 'post',
data: {
"action" : "grant",
"ip" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=IPaddress]').val(),
"pin" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=pin]').val(),
"timestamp" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=timestamp]').val(),
"user" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=user]').val(),
"auth_key" : $('.eqLogicAttr[data-l1key=configuration][data-l2key=auth_key]').val()
},
complete : function(resultat){
console.log("*** COMPLETE ***");
console.log(resultat);
var data = JSON.parse(resultat.responseText);
var obj = JSON.parse(data.result);
console.log(obj);
if( obj.error_id == "SUCCESS" ) {
$('.eqLogicAttr[data-l1key=configuration][data-l2key=auth_key]').val( obj.auth_key );
$('.eqLogicAttr[data-l1key=configuration][data-l2key=timestamp]').val( obj.timestamp );
$('.eqLogicAttr[data-l1key=configuration][data-l2key=timeout]').val( obj.timeout );
}
}
});
}
/* Ligne 739 : Fin Ajout sbr */
desktop/php/tvphillips.php
Code : Tout sélectionner
<!-- Ligne 127: Debut Ajout sbr -->
<div class="form-group" style="display: none">
<label class="col-sm-2 control-label">{{Utilisateur}}</label>
<div class="col-sm-3">
<input class="eqLogicAttr form-control" data-l1key='configuration' data-l2key='user' />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{Clé}}</label>
<div class="col-sm-3">
<input class="eqLogicAttr form-control" data-l1key='configuration' data-l2key='auth_key' readonly/>
</div>
<div class="col-sm-1">
<a class="btn btn-danger eqLogicAction" onclick="getKey()"><i class="fa fa-minus-circle"></i> {{Récupérer une clé}}</a>
</div>
</div>
<div class="form-group" style="display: none">
<label class="col-sm-2 control-label" style="display: none">{{Timestamp}}</label>
<div class="col-sm-3">
<input class="eqLogicAttr form-control" data-l1key='configuration' data-l2key='timestamp' readonly/>
</div>
</div>
<div class="form-group" style="display: none">
<label class="col-sm-2 control-label">{{Timeout}}</label>
<div class="col-sm-3">
<input class="eqLogicAttr form-control" data-l1key='configuration' data-l2key='timeout' readonly/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{Pin}}</label>
<div class="col-sm-3">
<input class="eqLogicAttr form-control" data-l1key='configuration' data-l2key='pin' />
</div>
<div class="col-sm-1">
<a class="btn btn-danger eqLogicAction" onclick="getToken()"><i class="fa fa-minus-circle"></i> {{Appairer la tv}}</a>
</div>
</div>
<!-- Ligne 164 : Fin Ajout sbr -->
core/class/tvphillips.class.php
Code : Tout sélectionner
/* Ligne 828 : Debut Ajout sbr */
$user = $eqLogic->getConfiguration('user');
$auth_key = $eqLogic->getConfiguration('auth_key');
if( $user != "" ) {
$IPaddress = $eqLogic->getConfiguration('IPaddress');
$key_data = $this->getConfiguration('key_data');
$api_type = $this->getConfiguration('ApiType');
$request1 = "curl --digest -u".$user.":".$auth_key." -X POST https://";
$request4 = '"}';
$request5 = "'";
switch($api_type) {
case 'key':
$request2 = ":1926/6/input/key -v -k -d '{";
$request3 = '"key":"';
break;
case 'volume':
if ($_options !== null && $_options !== '') {
$options = self::cmdToValue($_options);
if (is_json($_options)) {
$options = json_decode($_options, true);
}
} else {
$options = null;
}
if (isset($options['volume'])) {
$request2 = ":1926/6/audio/volume -d '{";
$request3 = '"muted": false,"current":"';
$key_data = $options['volume'];
}
break;
case 'sources':
$request2 = ":1926/6/sources/current -d '{";
$request3 = '"id":"';
break;
default:
break;
}
$request = $request1.$IPaddress.$request2.$request3.$key_data.$request4.$request5;
$request_shell = new com_shell($request . ' 2>&1');
$result = trim($request_shell->exec());
return $result;
} else {
/* Ligne 892 : Fin Ajout sbr */
et
Code : Tout sélectionner
/* Ligne 938 : Debut Ajout sbr */
}
/* Ligne 942 Fin Ajout sbr */
Puis créer un dossier ajax dans core, un fichier txt que l'on nomme
tvphillips.php puis y copier ce qui suit :
core/ajax/tvphillips.php
Code : Tout sélectionner
<?php
/* This file is part of Jeedom.
*
* Jeedom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Jeedom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
*/
try {
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
if ( init('action') == 'grant' ) {
$input = '{ "auth" : { "auth_AppId" : "1" , "pin" : "' . $_POST['pin'] . '" , "auth_timestamp" : "" , "auth_signature" : "" } , "device" : { "device_name" : "heliotrope", "device_os" : "Android", "app_name" : "ApplicationName", "type" : "native" , "app_id": "app.id" , "id" : "' . $_POST['user'] . '" } }';
$ch = curl_init();
$ip = init('ip');
curl_setopt($ch, CURLOPT_URL, "https://".$ip.":1926/6/pair/grant");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, $_POST['user'] . ":" . $_POST['auth_key']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' ));
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
ajax::success($httpcode);
} else if ( init('action') == 'pair') {
$input = '{ "scope" : [ "read", "write", "control"] , "device" : { "device_name" : "heliotrope", "device_os" : "Android", "app_name" : "ApplicationName", "type" : "native" , "app_id": "app.id" , "id" : "' . $_POST['user'] . '" } }';
$ch = curl_init();
$ip = init('ip');
curl_setopt($ch, CURLOPT_URL, "https://".$ip.":1926/6/pair/request");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' ));
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
ajax::success($output);
}
throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
} catch (Exception $e) {
ajax::error(displayExeption($e), $e->getCode());
}
?>
Tu pourras me corriger si je me suis planté ?
Merci @sbr
@Koleos Bonjour,
Je me prépares à recevoir mon super cadeau de nöel
une Philips OLED
J'ai donc besoin de ce plugin pour gérer l'extinction (mise en vieille) de mon 'joujou'. Je ne pourrai plus éteindre comme je fais actuellement avec mon ancienne TV via une prise (On/Off) avec Homebridge et Siri. Les OLED doivent être mis en vieille, pas coupé net....Donc ce super plugin va me permettre (j'espère) de mettre en vieille via Siri.... D)
Peux-tu faire les modifs dans ton plugin ? Et si possible le mettre compatible V4 ?
Je met le sujet sur le Community, vu que celui-ci va passer en lecture seule
Remise à niveau plugin TV Phillips (AndroidTV)
Pour le post plugin, ce sera d'une autre façon sur Community.
Vous pouvez répondre sur Community si vous le souhaitez.
Je vous en remercie tous les deux.