-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_elec.php
29 lines (21 loc) · 1.28 KB
/
import_elec.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/*************************************************************************************/
/* ### Report electricité eedomus SQL - import ### */
/* */
/* Developpement par [email protected] */
/* */
/*************************************************************************************/
include ('parametres.php');
$periph_id = $periph_rlv_elec;
$url = "http://".$IPeedomus."/api/get?action=periph.caract&periph_id=".$periph_id."&api_user=".$api_user."&api_secret=".$api_secret."";
$arr = json_decode(utf8_encode(file_get_contents($url)));
$conso = $arr->body->last_value;
$datereleve = $arr->body->last_value_change;
$db = mysql_connect($server, $sqllogin, $sqlpass);
mysql_select_db('historique',$db);
$sql = ' INSERT INTO electricite( date, conso ) VALUES ("'.$datereleve.'", "'.$conso.'")';
$req = mysql_query($sql);
if ($req) { echo utf8_encode("<div class=\"envoi\"><b>Enregistrement effectué</b></div>"); }
else { echo 'Erreur SQL !<br />'.$sql.'<br />'.mysql_error(); }
mysql_close();
?>