Page 89 sur 148

Re: Custom page

Publié : 07 juin 2016, 11:16
par jackyhi
Salut

je suis parvenu à des résultats probants!! voici ma page chauffage et ma page meteo:
Custom page meteo
Custom page meteo
Ma_PageMeteo.png (1.46 Mio) Consulté 8889 fois
Custom page Chauffage
Custom page Chauffage
Ma_PageChauffage.png (1.38 Mio) Consulté 8889 fois
Merci à vil1driver

Maintenant j'aimerais inserrer une image de fond est-ce possible? ou changer la couleur du fond?
Autre problème:
J'ai essayé un script en php pour récupérer des infos météo et losque j'essaie de le lancer en ligne j'ai l'erreur suivante.
le script est installé dans le répertoire /home/pi/domoticz/scripts/weather-forecast.php
lancement du fichier en ligne de commande et retour de l'erreur:
pi@raspberrypi:~/domoticz/scripts$ ./weather-forecast.php 2
-bash: ./weather-forecast.php : /usr/bin/php^M : mauvais interpréteur: Aucun fichier ou dossier de ce type
pi@raspberrypi:~/domoticz/scripts$


le fichier ci joint:
weather-forecast.zip
(2.88 Kio) Téléchargé 294 fois
Quelqu'un peut-il m'éclairer sur ce dernier point?

Merci

Re: Custom page

Publié : 07 juin 2016, 12:11
par papoo
jackyhi a écrit : J'ai essayé un script en php pour récupérer des infos météo et losque j'essaie de le lancer en ligne j'ai l'erreur suivante.
le script est installé dans le répertoire /home/pi/domoticz/scripts/weather-forecast.php
lancement du fichier en ligne de commande et retour de l'erreur:
pi@raspberrypi:~/domoticz/scripts$ ./weather-forecast.php 2
-bash: ./weather-forecast.php : /usr/bin/php^M : mauvais interpréteur: Aucun fichier ou dossier de ce type
pi@raspberrypi:~/domoticz/scripts$


Quelqu'un peut-il m'éclairer sur ce dernier point?

Merci
il me semble qu'il y a plus simple
http://easydomoticz.com/la-meteo-depuis ... -domoticz/

Re: Custom page

Publié : 07 juin 2016, 13:25
par vil1driver
tu devrais avoir l'image de fond par défaut, si ton fond est noir c'est en principe de ton fait..
regardes de plus près ton fichier settings..

la page météo c'est toi qui à supprimé les 2 séparateurs verticaux ?

@thier,

on affiche pas une sonde mais une valeur, à toi d'afficher soit la température, soit l'humidité..
pour tes compteurs c'est probablement le même soucis, affiches tu la bonne info ?

Re: Custom page

Publié : 07 juin 2016, 14:54
par jackyhi
Salut à papoo
En réponse à ta remarque, c'est justement le tuto que tu suggères que j'ai utilisé :

http://easydomoticz.com/les-previsions- ... -domoticz/

J'ai trouvé quelques coquilles ( oubli de $ devant LON et des lignes commentaires non précédées des caractères de commentaires) dans le script php corrigées et malgré cela j'ai toujours l'erreur à l'exécution du script.


Code : Tout sélectionner

#!/usr/bin/php
<?php

/**
--------------------------------------------------
recuperation de previsions meteo depuis "forecast.io"
Changer API key, Latitude and Longtitude
Si le parametre unit vaut "ca" affiche la vitesse du vent en km/h ,
...si donne les vitesses du vent en m/s et...
...UK in mile/hour il en faut pour tout le monde
ca par defaut
--------------------------------------------------
$offset est le delai de temps en heure pour lequel
vous souhaitez voir la prevision
Ainsi si il est 17:37 et que $offset  = 3, alors vous aurez la meteo de 20:00
Vous pouvez lancer ce script depuis le shell linux avec une valeur d'offset de 3 en tapant ./weather-previ.php 3 si vous avez nomme ce script weather-previ
le maximum autorisé est de 48 (=48h)
les valeurs s'affichent dans le shell
Si vous souhaitez toujours utiliser une même valeur de prevision ; 
on peut supprimer les 3  lignes ci dessous
puis supprimer le // devant $offset et placer votre valeur ainsi $offset = 12 donnera les previsions pour 12h.
Dans ce cas lancez le script par ./weather-previ.php
*/
// supprimer ici les 3 lignes pour une valeur fixe 
$offset = $argv[1];
echo $offset;
echo "\n";
//--------------------------------------------------

//definissez vos valeurs ici
//---------------------------
$API = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$LAT = "YY.XXXXX";
$LON = "Y.XXXXXX";
//$offset = 12;
//--------------------------------------------------

//-----------------------------------------------
//A plusieurs reprises dans le script vous trouverez des lignes comme cela  (ce type de bloc par type de capteur : thermonetre,pluie,vent)

//send forecast values to Domoticz virtual devices
// exchange the "idx=xyz" with your idx values
// exchange the $offset value with your value here-> 12h and any else h

if ($offset == 12) {
	$idx = 115; //18;
} else {
	$idx = 108;  //23;
} 

//Il faut bien entendu mettre vos valeurs d'idx a vous en fonction du capteur (thermonetre, rain, wind)
//Cherchez dans le script les thermonetres,rainrain2 eet wind pour modifier vos idx

//Cela permet d'alimenter le virtual device 18 dans l'exemple si offset =12 sinon on alimente le virtual device 23
// --------------------------------------

$json_string = file_get_contents("https://api.forecast.io/forecast/$API/$LAT,$LON?units=ca&exclude=currently,minutely,daily,alerts,flags");
$parsed_json = json_decode($json_string, true);

//--------------------------------------------------

//---for debugging and development of a own forecast "combination"
//---this file will show the complete array of a weather forecast for the next 48h delivered with the above URL request
/**
$wetterdatei = "/home/pi/domoticz/scripts/forecast.txt";
$wd = fopen ($wetterdatei, "w+");
fwrite ($wd, print_R($parsed_json, TRUE));
fclose ($wd);
*/

//following lines are just for debugging -------------------------------------
//start the script in Putty to see date & time & data responses
//read present date
$present_date = date("d.m.y - H:i:s");
echo $present_date;
echo " ";

//shwo Unix time with minutes and seconds of the present date
echo strtotime("now");
echo "\n";

//end of debugging line -----------------------------------------------------


//add "3" for a 3h forecast
//can be changed to any value until 48h in the future (max = 47)
$h = date('H')+$offset;
echo $h;
echo "\n";

//create a Unix time with minutes & seconds = 0
$day=date("d");
$month=date("m");
$year=date("Y"); 

$ref =  mktime($h,0,0,$month,$day,$year);
echo $ref;
echo "\n";

//find the relevant forecast value in the array
//means: current time + n hours

for ($count = 0; $count < 49; $count++)  { 
	$parsed_json = json_decode($json_string, true);
	$parsed_json = $parsed_json['hourly']['data'][$count];
	$time = $parsed_json['time'];
	
	if ($ref == $time)  {
	echo $count." ".$time;
	echo "\n";

//now read some of the forecast values
//there are more values delivered but no corresponding Domoticz devies are available :-(

	$temperature = $parsed_json['temperature'];
	echo $temperature;
	echo "\n";

	$humidity = $parsed_json['humidity'];
	$hum = $humidity * 100;
	echo $hum;
	echo "\n";

	$windSpeed = $parsed_json['windSpeed'];
	echo $windSpeed;
	echo "\n";

	$windBearing = $parsed_json['windBearing'];
	echo $windBearing;
	echo "\n";

	$pressure = $parsed_json['pressure'];
	echo $pressure;
	echo "\n";

	$precipIntensity = $parsed_json['precipIntensity'];
	echo $precipIntensity;
	echo "\n";
 
	$precipProbability = $parsed_json['precipProbability'];
	echo $precipProbability;
	echo "\n";

	$icon = $parsed_json['icon'];
	echo $icon;
	echo "\n";

	}
}

//send forecast values to Domoticz virtual devices
// exchange the "idx=xyz" with your idx values
// exchange the $offset value with your value here-> 12h and any else h

if ($offset == 12) {
	$idx = 113;   //18;
} else {
	$idx = 108;  //23;
} 

//Thermometer-----------------------------------------------------------------

if ($temperature != "")  {
$ch = curl_init("http://192.168.0.22:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$temperature");
curl_exec($ch);
curl_close($ch);
}

//Thermometer/Humidity/Barometer-----------------------------------------------
//Humidity to text conversion -> not clear at the moment about the correct ranges!
if ($hum <40 ) {
	$status = 2;
} 	elseif ($hum >= 40 && $hum < 70) {
	$status = 1;
} else {
	$status = 3;
}	

//Prediction text to value conversion------------------------------------------
if ($icon == "clear-day" || $icon == "clear-night") {
	$prediction = 1;
} 	elseif ($icon == "partly-cloudy-day" || $icon == "partly-cloudy-night") {
	$prediction = 2;
}	elseif ($icon == "cloudy") {
	$prediction = 3;
}	elseif ($icon == "rain" || $icon == "snow" || $icon == "fog" || $icon == "sleet") {
	$prediction = 4;
} else {
	$prediction = 0;
}

// exchange the "idx=xyz" with your idx values
// exchange the $offset value with your value here-> 12h and any else h
if ($offset == 12) {
	$idx = 116;  //20;
} else {
	$idx = 108;  //24;
} 


if ($temperature != "" && $hum != "" && $pressure != "") {
$ch = curl_init("http://192.168.0.22:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$temperature;$hum;$status;$pressure;$prediction");
curl_exec($ch);
curl_close($ch);
}

//Rain-------------------------------------------------------------------------
//work-around -> since beta 1.1657 no rain value=0 will be propagated
//therefore the value is set to 0.01 which will be displayed as 0.0mm
// exchange the "idx=xyz" with your idx values
// exchange the $offset value with your value here-> 12h and any else h

if ($offset == 12) {
	$idx = 116;  //21;
} else {
	$idx = 110;  //25;
} 
 
if ($precipIntensity == "") {
$precipIntensity = 0.01;
}

if ($precipIntensity != "") {
$ch = curl_init("http://192.168.0.22:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=0;$precipIntensity");
curl_exec($ch);
curl_close($ch);
}
//Rain-2-----------------------------------------------------------------------
// exchange the "idx=xyz" with your idx values
// exchange the $offset value with your value here-> 12h and any else h

if ($offset == 12) {
	$idx = 117;   //32;
} else {
	$idx = 115;    //31;
} 

if ($precipProbability == "") {
$precipProbability = 0;
}

$precipProbabilityProcent = $precipProbability * 100;
//if ($precipProbabilityProcent != "") {
$ch = curl_init("http://192.168.0.22:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$precipProbabilityProcent");
curl_exec($ch);
curl_close($ch);
//}

//Wind-------------------------------------------------------------------------
//windbearing to compass direction conversion

if ($windBearing < 11.25) {
	$dir = "N";
} 	elseif ($windBearing >= 11.25 && $windBearing < 33.75) {
	$dir = "NNE";
}	elseif ($windBearing >= 33.75 && $windBearing < 56.25) {
	$dir = "NE";
}	elseif ($windBearing >= 56.25 && $windBearing < 78.75) {
	$dir = "ENE";
}	elseif ($windBearing >= 78.75 && $windBearing < 101.25) {
	$dir = "E";
}	elseif ($windBearing >= 101.25 && $windBearing < 123.75) {
	$dir = "ESE";
}	elseif ($windBearing >= 123.75 && $windBearing < 146.25) {
	$dir = "SE";
}	elseif ($windBearing >= 146.25 && $windBearing < 168.75) {
	$dir = "SSE";
}	elseif ($windBearing >= 168.75 && $windBearing < 191.25) {
	$dir = "S";
}	elseif ($windBearing >= 191.25 && $windBearing < 213.75) {
	$dir = "SSW";
}	elseif ($windBearing >= 213.75 && $windBearing < 236.25) {
	$dir = "SW";
}	elseif ($windBearing >= 236.25 && $windBearing < 258.75) {
	$dir = "WSW";
}	elseif ($windBearing >= 258.75 && $windBearing < 281.25) {
	$dir = "W";
}	elseif ($windBearing >= 281.25 && $windBearing < 303.75) {
	$dir = "WNW";
}	elseif ($windBearing >= 303.75 && $windBearing < 326.25) {
	$dir = "NW";
}	elseif ($windBearing >= 326.25 && $windBearing < 348.75) {
	$dir = "NNW";
} else {
	$dir = "N";
}

echo $dir;

//Windspeed and Wind-direction
//"Gust" values are not delivered by forecast.io; therefore "Windpeed" = "Gust"
//"$temperature = unused but necessary dummy values
// exchange the "idx=xyz" with your idx values
// exchange the $offset value with your value here-> 12h and any else h

if ($offset == 12) {
	$idx = 115;   //22;
} else {
	$idx = 109;  //26;
} 

if ($windBearing != "" && $windSpeed != "" && $temperature != "") {
$ch = curl_init("http://192.168.0.22:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$windBearing;$dir;$windSpeed;$windSpeed;$temperature;$temperature");
curl_exec($ch);
curl_close($ch);
}
?>


avec la commande suivante:

Code : Tout sélectionner

pi@raspberrypi:~/domoticz/scripts$ ./weather-forecast.php 12
-bash: ./weather-forecast.php : /usr/bin/php^M : mauvais interpréteur: Aucun fichier ou dossier de ce type
pi@raspberrypi:~/domoticz/scripts$
Je ne trouve pas ce qui provoque cette erreur ?? (sur le net indication:ce type d'erreur est renvoyée quand des caractères incorrects figurent dans le fichier!).

Dans le tuto les autres utilisateurs semblent dire que le script fonctionne.


Merci

Re: Custom page

Publié : 07 juin 2016, 15:09
par jacob
Hello.

Le peut laisser supposer un mauvais copier-coller si tu es sous Windows?

Autre piste, que donne un

Code : Tout sélectionner

which php
?

Re: Custom page

Publié : 07 juin 2016, 15:20
par papoo
Il n'y a pas de script Php dans le lien que je t'indique car forecast.io est intégré directement dans domoticz

Re: Custom page

Publié : 07 juin 2016, 15:22
par jackyhi
Salut vil1driver

J'ai encore des questions de débutant! voici ma page meteo:
Ma_PageMeteo.png
Ma_PageMeteo.png (1.46 Mio) Consulté 9053 fois
comme tu peux le constater, il manque les séparateurs verticaux, l'image de fond et je n'ai que 5 cases pour les prévisions pluie.

Peux-tu m'indiquer comment remédier à ces 3 problèmes, (je n'ai rien trouvé concernant ces questions sur les 90 pages du blog)?

voici ma page des settings pour la météo:

Code : Tout sélectionner

				// meteo page
		
				['0','Clock',           'meteo1',                             '','','','font-family:digital;color:#8BFD1C;font-size:160%',''],   // heure et date
				['0','Hide',             'meteo2',                             ' ','','','',''], // colonne 1
				['0','SunBoth',         'ls_meteo25',                  '','','','color:#F2DDB3;font-size:19px;font-weight:bold'],   // heures soleil dans la description de la cellule 25
				['108','Temp',              'meteo3',                             '','','','color:#F2DDB3;font-size:90%'], // colonne 2
				['108','HumidityStatus',              'desc_meteo3',                             '','','','color:#F2DDB3;font-size:19px;font-weight:bold'], // colonne 2
				['108','Level',               'meteo4',                          '','','','',''], // colonne 5 Vigilance Météo
				['0','Text',               'desc_meteo4',                          'Vigilance Météo','','','',''], // colonne 5            
				//['0','',               'meteo4',                          '','','','',''],
				['117','ForecastStr',     'meteo25',                        '','1','','',''], // colonne 4            
				['0','Text',             'desc_meteo25',                             'Demain','','','color:#F2DDB3;font-size:19px;font-weight:bold',''], // colonne 4            
                                ['0','Hide',               'meteo5',                          '','','','',''],   
				['118','Data',   'meteo6','Pluie 1h','','','','x > 65'],   // proba pluie dans 1h
				['119','Data',   'meteo7','Pluie 2h','','','','x > 45'],   // proba pluie dans 2h
				['120','Data',   'meteo8','Pluie 3h','','','','x > 45'],   // proba pluie dans 3h
				['121','Data',   'meteo9','Pluie 4h','','','','x > 45'],   // proba pluie dans 4h
				['122','Data',   'meteo10','Pluie 5h','','','','x > 45'],   // proba pluie dans 5h   
				['123','Data',   'meteo11','Pluie 6h','','','','x > 45'],   // proba pluie dans 6h   
D'avance merci.

Re: Custom page

Publié : 07 juin 2016, 15:32
par vil1driver
ta page météo n'est pas à jour.. peut-être que ce n'est pas la seule chose qui n'est pas à jour..

Re: Custom page

Publié : 07 juin 2016, 15:33
par jackyhi
Réponse à papoo

Si tu vas jusqu'en bas de la page du tuto que tu m'indiques il y a ceci

" P.S : En ce qui me concerne la pluie est toujours a 0 !

Dans un prochain article ,
nous récupèrons via php et forecast.io , les prévisions à 6H et 12H , traduction du wiki de Domoticz « Weather forecast from forecast.io in Domoticz » .(adresse du lien :http://www.domoticz.com/wiki/Weather_fo ... n_Domoticz )

Bon vent …"

et tout naturellement j'ai suivi le lien qui m'a emmené vers un autre tuto faisant suite à celui que tu m'indiques!

voilà pour mes sources. ;)

Merci

Re: Custom page

Publié : 07 juin 2016, 15:40
par jackyhi
A vil1driver,

comment fais-t-on pour remettre à jour les différents fichiers ? Ou puis-je les télécharger?

Ceux que j'ai téléchargés dernièrement sont :monitor-master.zip daté du 25/04/2016.

Peux-tu me donner la procédure et le lien pour récupérer ces fichiers?

Merci