Comme annoncé, ce forum est passé en lecture seule au 1er janvier 2020. Désormais nous vous invitons à vous rendre sur notre nouvelle page communauté :
Image

A très bientôt !

modif widget pour qu'il soit compatible V3.22

Réservé à l'utilisation et la création de widgets dans JEEDOM
Répondre
sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 24 mai 2019, 13:47

bonjour à tous.
j'ai téléchargé sur le market un widget nommé signal.

Image
Cependant, celui-ci date de 2016 et ne se rafraichit plus automatiquement depuis le dernier core.
que dois je modifier dans le code pour qu'il se rafraîchisse seul de nouveau ?

merci de votre aide

Code : Tout sélectionner

<div style="width:142px;min-height:110px;" class="cmd #history# tooltips cmd-widget" data-type="info" data-subtype="numeric" data-cmd_id="#id#" title="#collectDate#">
    <center><span class='cmdName' style="font-weight: bold;font-size : 0.8em;width: 65px;height: 17px;overflow: hidden;position: relative;#hideCmdName#;" title="#name#">#name_display#</span></center>
  	<div style="margin:5px;position:relative;width:65px;height:80px;float: left;line-height: 20px;">
      	<br>
    	<span style="margin-left: 30px;font-weight: bold;font-size: 1.5em;margin-top: 5px;">#state#</span>
      	<br>
      	<span style="margin-left: 30px;font-size: 1em;font-weight: bold;margin-top: 5px;">#unite#</span>
       	<!-- A activer si vous voulez avoir les statistiques -->
        <!--<span style="line-height:10px;font-size: 0.7em;font-weight: bold;float: left;text-align: justify;#displayHistory#">
        <span title='Min' class='tooltips left'>Min : </span><span style="float:right;">#minHistoryValue# #unite#</span><br/>
        <span title='Moyenne' class='tooltips'>Moy: </span><span style="float:right;">#averageHistoryValue# #unite#</span><br/>
        <span title='Max' class='tooltips'>Max: </span><span style="float:right;">#maxHistoryValue# #unite#</span><br/> <i class="#tendance#"></i></span>-->
  	</div>
    <div style="margin-right:5px;position:relative;width:62px;height:64px;float: left;">
        <span id="imgCmd#id#"></span>
   </div>
  
  

   <script>
		$(function() {    
		    var chemin_fichier  = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Signal_IMG/';

            var valeur=#state#;
            if ('#echelle#'.trim() != '10' && '#echelle#'.trim() != '100') {
            	var echelle = 100; 
            } else {
                var echelle = '#echelle#'.trim(); 
            }
            
          	if (valeur < 0) {
            	var valeur = valeur * -1;
            }
          
            if (echelle == 10) { 
            	var numero_fichier = valeur;
            } else if (echelle == 100) { 
              	if (valeur < 100) {
            		var numero_fichier = Math.floor(valeur/10);
                } else {                
                    var numero_fichier = 10;
                }
            }
          
          	$('#imgCmd#id#').append('<img src="' + chemin_fichier + numero_fichier + '.png" />');

        });
    </script>
  
</div>

        

Avatar de l’utilisateur
cadavor
Actif
Messages : 1284
Inscription : 21 juin 2015, 22:00
Localisation : 34

Re: modif widget pour qu'il soit compatible V3.22

Message par cadavor » 24 mai 2019, 14:05

Code : Tout sélectionner

<div style="width:142px;min-height:110px;" class="cmd #history# tooltips cmd-widget" data-type="info" data-subtype="numeric" data-cmd_id="#id#">
     <!-- Version 2019-05-24 14h05 -->
    <center><span class='cmdName' style="font-weight: bold;font-size : 0.8em;width: 65px;height: 17px;overflow: hidden;position: relative;#hideCmdName#;" title="#name#">#name_display#</span></center>
  	<div style="margin:5px;position:relative;width:65px;height:80px;float: left;line-height: 20px;">
      	<br>
    	<span style="margin-left: 30px;font-weight: bold;font-size: 1.5em;margin-top: 5px;">#state#</span>
      	<br>
      	<span style="margin-left: 30px;font-size: 1em;font-weight: bold;margin-top: 5px;">#unite#</span>
       	<!-- A activer si vous voulez avoir les statistiques -->
        <!--<span style="line-height:10px;font-size: 0.7em;font-weight: bold;float: left;text-align: justify;#displayHistory#">
        <span title='Min' class='tooltips left'>Min : </span><span style="float:right;">#minHistoryValue# #unite#</span><br/>
        <span title='Moyenne' class='tooltips'>Moy: </span><span style="float:right;">#averageHistoryValue# #unite#</span><br/>
        <span title='Max' class='tooltips'>Max: </span><span style="float:right;">#maxHistoryValue# #unite#</span><br/> <i class="#tendance#"></i></span>-->
  	</div>
    <div style="margin-right:5px;position:relative;width:62px;height:64px;float: left;">
        <span id="imgCmd#id#"></span>
   </div>

   <script>
   	 jeedom.cmd.update['#id#'] = function(_options){	
		    var chemin_fichier  = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Signal_IMG/';

            var valeur=_options.display_value;
            if ('#echelle#'.trim() != '10' && '#echelle#'.trim() != '100') {
            	var echelle = 100; 
            } else {
                var echelle = '#echelle#'.trim(); 
            }
            
          	if (valeur < 0) {
            	valeur *= -1;
            }
          
            if (echelle == 10) { 
            	var numero_fichier = valeur;
            } else if (echelle == 100) { 
              	if (valeur < 100) {
            		var numero_fichier = Math.floor(valeur/10);
                } else {                
                    var numero_fichier = 10;
                }
            }
          
          	$('#imgCmd#id#').html('<img src="' + chemin_fichier + numero_fichier + '.png" />');
      $('.cmd[data-cmd_id=#id#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate);
    }
    jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#'}); // init
    </script>
  
</div>
Ca devrait marcher
Jeedom Stable 3.3
NUC Z83 + Aeotec Z-Stick Gen5
Z-Wave FGR + FGMS + FGDS + FGFS + FGK + FGWPE + ZW062 + ZW080
GH Mini + Orvibo AllOne + Playbulb + Miband2

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 24 mai 2019, 15:17

Merci beaucoup Cavador,

j'ai collé ton code et je te tiens au courant.
je regarderai ce qui diffère de l'original pour essayer de comprendre

merci encore

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 24 mai 2019, 18:32

rebonjour,

et encore merci à Cavador pour son aide
Cependant, le widget avec le code de Cavador ne se rafraîchit pas seul non plus ... :-(
à noter que j'affiche sur mon design la commande et non pas l'équipement. Je ne pense pas que cela soit ça le problème mais je préfère le préciser ...

Avatar de l’utilisateur
Salvialf
Helper
Messages : 1334
Inscription : 24 févr. 2018, 09:37
Contact :

Re: modif widget pour qu'il soit compatible V3.22

Message par Salvialf » 24 mai 2019, 21:21

Salut,

T'es dur... les modifs de @cadavor ont apporté la mise à jour de l'image déjà alors que ce n'était pas le cas avant ! Seule la valeur d'état à gauche ne se rafraichissait pas...

Testé très rapidement mais semble ok:

Code : Tout sélectionner

<div style="width:142px;min-height:110px;" class="cmd #history# tooltips cmd-widget" data-type="info" data-subtype="numeric" data-cmd_id="#id#" title="#collectDate#">
    <center><span class='cmdName' style="font-weight: bold;font-size : 0.8em;width: 65px;height: 17px;overflow: hidden;position: relative;#hideCmdName#;" title="#name#">#name_display#</span></center>
  	<div style="margin:5px;position:relative;width:65px;height:80px;float: left;line-height: 20px;">
      	<br>
    	<span id="state#id#" style="margin-left: 5px;font-weight: bold;font-size: 2em;margin-top: 5px;"></span>
      	<br>
      	<span style="font-size: 1em;font-weight: bold;margin-top: 5px;">#unite#</span>
       	<!-- A activer si vous voulez avoir les statistiques -->
        <!--<span style="line-height:10px;font-size: 0.7em;font-weight: bold;float: left;text-align: justify;#displayHistory#">
        <span title='Min' class='tooltips left'>Min : </span><span style="float:right;">#minHistoryValue# #unite#</span><br/>
        <span title='Moyenne' class='tooltips'>Moy: </span><span style="float:right;">#averageHistoryValue# #unite#</span><br/>
        <span title='Max' class='tooltips'>Max: </span><span style="float:right;">#maxHistoryValue# #unite#</span><br/> <i class="#tendance#"></i></span>-->
  	</div>
    <div style="margin-right:5px;position:relative;width:62px;height:64px;float: left;">
        <span id="imgCmd#id#"></span>
   </div>
  
  

   <script>
		  jeedom.cmd.update['#id#'] = function(_options){ 
		    var chemin_fichier  = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Signal_IMG/';

            var valeur=_options.display_value;
            if ('#echelle#'.trim() != '10' && '#echelle#'.trim() != '100') {
            	var echelle = 100; 
            } else {
                var echelle = '#echelle#'.trim(); 
            }
            
          	if (valeur < 0) {
            	var valeur = valeur * -1;
            }
          
            if (echelle == 10) { 
            	var numero_fichier = valeur;
            } else if (echelle == 100) { 
              	if (valeur < 100) {
            		var numero_fichier = Math.floor(valeur/10);
                } else {                
                    var numero_fichier = 10;
                }
            }
            
          	$('#imgCmd#id#').empty().append('<img src="' + chemin_fichier + numero_fichier + '.png" />');
			$('.cmd[data-cmd_id=#id#] #state#id#').empty().append(_options.display_value);
            
       $('.cmd[data-cmd_id=#id#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate);
    }
    jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#'});
    </script>
  
</div>

        
VM Jeedom 3.2.16 sous Proxmox 5.4 sur NUC5i5RYH (Debian 9.9)
Helper Officiel Jeedom
Widgets développés
Téléchargement d'icônes domotique (Topic Forum)

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 24 mai 2019, 21:53

Salvialf a écrit :
24 mai 2019, 21:21
Salut,

T'es dur... les modifs de @cadavor ont apporté la mise à jour de l'image déjà alors que ce n'était pas le cas avant ! Seule la valeur d'état à gauche ne se rafraichissait pas...

Testé très rapidement mais semble ok:

Code : Tout sélectionner

<div style="width:142px;min-height:110px;" class="cmd #history# tooltips cmd-widget" data-type="info" data-subtype="numeric" data-cmd_id="#id#" title="#collectDate#">
    <center><span class='cmdName' style="font-weight: bold;font-size : 0.8em;width: 65px;height: 17px;overflow: hidden;position: relative;#hideCmdName#;" title="#name#">#name_display#</span></center>
  	<div style="margin:5px;position:relative;width:65px;height:80px;float: left;line-height: 20px;">
      	<br>
    	<span id="state#id#" style="margin-left: 5px;font-weight: bold;font-size: 2em;margin-top: 5px;"></span>
      	<br>
      	<span style="font-size: 1em;font-weight: bold;margin-top: 5px;">#unite#</span>
       	<!-- A activer si vous voulez avoir les statistiques -->
        <!--<span style="line-height:10px;font-size: 0.7em;font-weight: bold;float: left;text-align: justify;#displayHistory#">
        <span title='Min' class='tooltips left'>Min : </span><span style="float:right;">#minHistoryValue# #unite#</span><br/>
        <span title='Moyenne' class='tooltips'>Moy: </span><span style="float:right;">#averageHistoryValue# #unite#</span><br/>
        <span title='Max' class='tooltips'>Max: </span><span style="float:right;">#maxHistoryValue# #unite#</span><br/> <i class="#tendance#"></i></span>-->
  	</div>
    <div style="margin-right:5px;position:relative;width:62px;height:64px;float: left;">
        <span id="imgCmd#id#"></span>
   </div>
  
  

   <script>
		  jeedom.cmd.update['#id#'] = function(_options){ 
		    var chemin_fichier  = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Signal_IMG/';

            var valeur=_options.display_value;
            if ('#echelle#'.trim() != '10' && '#echelle#'.trim() != '100') {
            	var echelle = 100; 
            } else {
                var echelle = '#echelle#'.trim(); 
            }
            
          	if (valeur < 0) {
            	var valeur = valeur * -1;
            }
          
            if (echelle == 10) { 
            	var numero_fichier = valeur;
            } else if (echelle == 100) { 
              	if (valeur < 100) {
            		var numero_fichier = Math.floor(valeur/10);
                } else {                
                    var numero_fichier = 10;
                }
            }
            
          	$('#imgCmd#id#').empty().append('<img src="' + chemin_fichier + numero_fichier + '.png" />');
			$('.cmd[data-cmd_id=#id#] #state#id#').empty().append(_options.display_value);
            
       $('.cmd[data-cmd_id=#id#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate);
    }
    jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#'});
    </script>
  
</div>

        

Merci beaucoup, je colle le code et reviens vers toi. Merci encore à Cadavor qui m'a aidé. J'ai pas fait attention que le graph se rafraîchissait car la valeur fluctue peu et comme le graphe varie par tranche de 10 ...... ;-)

sans abuser de votre gentillesse, pouvez vous me dire comment faire pour que le % soit à droite de la valeur et non en dessous ?

Avatar de l’utilisateur
Salvialf
Helper
Messages : 1334
Inscription : 24 févr. 2018, 09:37
Contact :

Re: modif widget pour qu'il soit compatible V3.22

Message par Salvialf » 24 mai 2019, 22:04

sebforum29 a écrit :
24 mai 2019, 21:53
sans abuser de votre gentillesse, pouvez vous me dire comment faire pour que le % soit à droite de la valeur et non en dessous ?

En enlevant le <br> (saut de ligne) entre les 2 premiers spans au début du code:

Code : Tout sélectionner

<div style="width:142px;min-height:110px;" class="cmd #history# tooltips cmd-widget" data-type="info" data-subtype="numeric" data-cmd_id="#id#" title="#collectDate#">
    <center><span class='cmdName' style="font-weight: bold;font-size : 0.8em;width: 65px;height: 17px;overflow: hidden;position: relative;#hideCmdName#;" title="#name#">#name_display#</span></center>
  	<div style="margin:5px;position:relative;width:65px;height:80px;float: left;line-height: 20px;">
      	<br>
    	<span id="state#id#" style="margin-left: 5px;font-weight: bold;font-size: 2em;margin-top: 5px;"></span>
      	<span style="font-size: 1em;font-weight: bold;margin-top: 5px;">#unite#</span>
       	<!-- A activer si vous voulez avoir les statistiques -->
        <!--<span style="line-height:10px;font-size: 0.7em;font-weight: bold;float: left;text-align: justify;#displayHistory#">
        <span title='Min' class='tooltips left'>Min : </span><span style="float:right;">#minHistoryValue# #unite#</span><br/>
        <span title='Moyenne' class='tooltips'>Moy: </span><span style="float:right;">#averageHistoryValue# #unite#</span><br/>
        <span title='Max' class='tooltips'>Max: </span><span style="float:right;">#maxHistoryValue# #unite#</span><br/> <i class="#tendance#"></i></span>-->
  	</div>
    <div style="margin-right:5px;position:relative;width:62px;height:64px;float: left;">
        <span id="imgCmd#id#"></span>
   </div>
  
  

   <script>
		  jeedom.cmd.update['#id#'] = function(_options){ 
		    var chemin_fichier  = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Signal_IMG/';

            var valeur=_options.display_value;
            if ('#echelle#'.trim() != '10' && '#echelle#'.trim() != '100') {
            	var echelle = 100; 
            } else {
                var echelle = '#echelle#'.trim(); 
            }
            
          	if (valeur < 0) {
            	var valeur = valeur * -1;
            }
          
            if (echelle == 10) { 
            	var numero_fichier = valeur;
            } else if (echelle == 100) { 
              	if (valeur < 100) {
            		var numero_fichier = Math.floor(valeur/10);
                } else {                
                    var numero_fichier = 10;
                }
            }
            
          	$('#imgCmd#id#').empty().append('<img src="' + chemin_fichier + numero_fichier + '.png" />');
			$('.cmd[data-cmd_id=#id#] #state#id#').empty().append(_options.display_value);
            
       $('.cmd[data-cmd_id=#id#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate);
    }
    jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#'});
    </script>
</div>
VM Jeedom 3.2.16 sous Proxmox 5.4 sur NUC5i5RYH (Debian 9.9)
Helper Officiel Jeedom
Widgets développés
Téléchargement d'icônes domotique (Topic Forum)

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 25 mai 2019, 08:04

super merci beaucoup pour le %, plus qu'à attendre que la valeur évolue pour voir si le rafraîchissement auto est ok !! ;-)

Avatar de l’utilisateur
JAG
Actif
Messages : 597
Inscription : 21 mai 2016, 11:10

Re: modif widget pour qu'il soit compatible V3.22

Message par JAG » 25 mai 2019, 16:59

Salut,

J'ai fait une petite modif si cela peut aider les autres (Pour l'historique) et j'ai fusionné la valeur avec l'unité

Code : Tout sélectionner

<div style="width:142px;min-height:110px;" class="cmd #history# tooltips cmd-widget" data-type="info" data-subtype="numeric" data-cmd_id="#id#" title="#collectDate#">
    <center>
        <span class='cmdName' style="font-weight: bold;font-size : 0.8em;width: 65px;height: 17px;overflow: hidden;position: relative;#hideCmdName#;" title="#name#">#name_display#</span>
    </center>
    <div style="margin:5px;position:relative;width:65px;height:80px;float: left;">
        <br>
        <span class="value#id#" id="state#id#" style="margin-left: 5px;font-weight: bold;font-size: 2em;"></span>
        <span style="font-size: 1em;font-weight: bold;margin-top: 5px;">#unite#</span>
       	<!-- Historique -->
            <div class="cmdStats #hide_history#" style="#displayHistory# font-size : 10px;position:relative">
                <span title="Min">Min : #minHistoryValue# #unite#</span><br/>
                <span title="Moy">Moy : #averageHistoryValue# #unite#</span><br/>
                <span title="Max">Max : #maxHistoryValue# #unite#</span><br/>
                <i class="#tendance#"></i>
        </div>
  	</div>
    <div style="margin-right:5px;position:relative;width:62px;height:64px;float: left;">
        <span id="imgCmd#id#"></span>
   </div>
  
  

   <script>
		  jeedom.cmd.update['#id#'] = function(_options){ 
		    var chemin_fichier  = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Signal_IMG/';

            var valeur=_options.display_value;
            if ('#echelle#'.trim() != '10' && '#echelle#'.trim() != '100') {
            	var echelle = 100; 
            } else {
                var echelle = '#echelle#'.trim(); 
            }
            
          	if (valeur < 0) {
            	var valeur = valeur * -1;
            }
          
            if (echelle == 10) { 
            	var numero_fichier = valeur;
            } else if (echelle == 100) { 
              	if (valeur < 100) {
            		var numero_fichier = Math.floor(valeur/10);
                } else {                
                    var numero_fichier = 10;
                }
            }
            
          	$('#imgCmd#id#').empty().append('<img src="' + chemin_fichier + numero_fichier + '.png" />');
			$('.cmd[data-cmd_id=#id#] #state#id#').empty().append(_options.display_value);
            
       $('.cmd[data-cmd_id=#id#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate);
    }
    jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#'});
    </script>
</div>
Bonne journée à tous
Box : Jeedom Smart + Jeedom VM-Synology (avec Jeedom en beta)
Protocoles : Z-wave - RFXcom - Hue - Bluetooth - Xiaomi
Mon Matériel
Widgets développés

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 27 mai 2019, 12:20

bonjour et merci à tous. Le % et le graphe se met bien à jour automatiquement !

Merci !

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 28 mai 2019, 08:30

rebonjour, après un premier widget, voici un autre qui me pose problème car il ne se rafraîchit pas automatiquement.. Ce qui est bizarre, c'est que je l'ai crée avec l'assistant donc la syntaxe devrait être bonne :

si vous pouvez jeter un coup d'oeil !!! ?
merci une fois de plus

Code : Tout sélectionner

<div style="min-width:40px; min-height:70px;" class="cmd tooltips cmd-widget cursor container-fluid" data-type="info" data-subtype="numeric" data-cmd_id="#id#" data-cmd_uid="#uid#">
	<center>
		<div style="font-weight: bold;font-size : 12px;#hideCmdName#">#name_display#</div>
		<span style="font-size: 2em;" class="iconCmd"></span>
	    <div style="display:block;padding:1px;"> 
			<span style="font-weight: bold;" class="pull-right">#unite#</span>
			<span style="font-size: 1em;font-weight: bold;" class="pull-center state"></span>
		</div>
		<div style="#displayHistory# font-size: 0.8em;" class="col-xs-12">
			<span title="Min" class="tooltips">#minHistoryValue#</span>|<span title="Moyenne" class="tooltips" >#averageHistoryValue#</span> | <span title="Max" class="tooltips">#maxHistoryValue#</span> <i class="#tendance#"></i>
		</div>
	</center>
<!-- Ne Pas Supprimer -->
	<script class="createWidgetInfo" type="text/javascript">//<![CDATA[{"type":"1","version":"1","size":"2.5","min":["-3000","-10","11"],"max":["-11","10","12"],"images":["Water_level_down.png","Water_level_stable.png","Water_level_up.png"]}]]></script>
<!-- Ne Pas Supprimer -->
	<script>
   var srcImg = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Eau_Cuve_(perso)/';
	var iconUpdate = function (state){
		$('.cmd[data-cmd_uid=#uid#] .iconCmd').empty();
		if (state >= -3000 && state <= -11) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_down.png">');
		}
		if (state >= -10 && state <= 10) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_stable.png">');
		}
		if (state >= 11 && state <= 3000) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_up.png">');
		}
		$('.cmd[data-cmd_uid=#uid#] .state').text(state);
	};
	jeedom.cmd.update['#id#'] = function(_options){
		$('.cmd[data-cmd_uid=#uid#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate)
		iconUpdate(_options.display_value);
	}
	jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#',alertLevel:'#alertLevel#'});
	</script>
</div>

Avatar de l’utilisateur
cadavor
Actif
Messages : 1284
Inscription : 21 juin 2015, 22:00
Localisation : 34

Re: modif widget pour qu'il soit compatible V3.22

Message par cadavor » 28 mai 2019, 11:19

sebforum29 a écrit :
28 mai 2019, 08:30
rebonjour, après un premier widget, voici un autre qui me pose problème car il ne se rafraîchit pas automatiquement.. Ce qui est bizarre, c'est que je l'ai crée avec l'assistant donc la syntaxe devrait être bonne :

si vous pouvez jeter un coup d'oeil !!! ?
merci une fois de plus

Code : Tout sélectionner

<div style="min-width:40px; min-height:70px;" class="cmd tooltips cmd-widget cursor container-fluid" data-type="info" data-subtype="numeric" data-cmd_id="#id#" data-cmd_uid="#uid#">
	<center>
		<div style="font-weight: bold;font-size : 12px;#hideCmdName#">#name_display#</div>
		<span style="font-size: 2em;" class="iconCmd"></span>
	    <div style="display:block;padding:1px;"> 
			<span style="font-weight: bold;" class="pull-right">#unite#</span>
			<span style="font-size: 1em;font-weight: bold;" class="pull-center state"></span>
		</div>
		<div style="#displayHistory# font-size: 0.8em;" class="col-xs-12">
			<span title="Min" class="tooltips">#minHistoryValue#</span>|<span title="Moyenne" class="tooltips" >#averageHistoryValue#</span> | <span title="Max" class="tooltips">#maxHistoryValue#</span> <i class="#tendance#"></i>
		</div>
	</center>
<!-- Ne Pas Supprimer -->
	<script class="createWidgetInfo" type="text/javascript">//<![CDATA[{"type":"1","version":"1","size":"2.5","min":["-3000","-10","11"],"max":["-11","10","12"],"images":["Water_level_down.png","Water_level_stable.png","Water_level_up.png"]}]]></script>
<!-- Ne Pas Supprimer -->
	<script>
   var srcImg = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Eau_Cuve_(perso)/';
	var iconUpdate = function (state){
		$('.cmd[data-cmd_uid=#uid#] .iconCmd').empty();
		if (state >= -3000 && state <= -11) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_down.png">');
		}
		if (state >= -10 && state <= 10) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_stable.png">');
		}
		if (state >= 11 && state <= 3000) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_up.png">');
		}
		$('.cmd[data-cmd_uid=#uid#] .state').text(state);
	};
	jeedom.cmd.update['#id#'] = function(_options){
		$('.cmd[data-cmd_uid=#uid#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate)
		iconUpdate(_options.display_value);
	}
	jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#',alertLevel:'#alertLevel#'});
	</script>
</div>
La fonction iconUpdate est déclarée comme une variable...

Perso je suis pas fan des fonctions dans Jeedom car tu n'es pas à l'abri d'avoir un conflit si tu utilises plusieurs fois le meme widget (avis perso) donc :

Code : Tout sélectionner

<div style="min-width:40px; min-height:70px;" class="cmd tooltips cmd-widget cursor container-fluid" data-type="info" data-subtype="numeric" data-cmd_id="#id#" data-cmd_uid="#uid#">
	<center>
		<div style="font-weight: bold;font-size : 12px;#hideCmdName#">#name_display#</div>
		<span style="font-size: 2em;" class="iconCmd"></span>
	    <div style="display:block;padding:1px;"> 
			<span style="font-weight: bold;" class="pull-right">#unite#</span>
			<span style="font-size: 1em;font-weight: bold;" class="pull-center state"></span>
		</div>
		<div style="#displayHistory# font-size: 0.8em;" class="col-xs-12">
			<span title="Min" class="tooltips">#minHistoryValue#</span>|<span title="Moyenne" class="tooltips" >#averageHistoryValue#</span> | <span title="Max" class="tooltips">#maxHistoryValue#</span> <i class="#tendance#"></i>
		</div>
	</center>
<!-- Ne Pas Supprimer -->
	<script class="createWidgetInfo" type="text/javascript">//<![CDATA[{"type":"1","version":"1","size":"2.5","min":["-3000","-10","11"],"max":["-11","10","12"],"images":["Water_level_down.png","Water_level_stable.png","Water_level_up.png"]}]]></script>
<!-- Ne Pas Supprimer -->
	<script>
	jeedom.cmd.update['#id#'] = function(_options){
		$('.cmd[data-cmd_uid=#uid#]').attr('title','Valeur du '+_options.valueDate+', collectée le '+_options.collectDate)
		var state = _options.display_value;
		var srcImg = 'plugins/widget/core/template/dashboard/cmd.info.numeric.Niveau_Eau_Cuve_(perso)/';
		
		$('.cmd[data-cmd_uid=#uid#] .iconCmd').empty();
		if (state >= -3000 && state <= -11) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_down.png">');
		}
		else if (state >= -10 && state <= 10) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_stable.png">');
		}
		else if (state >= 11 && state <= 3000) {
			$('.cmd[data-cmd_uid=#uid#] .iconCmd').html('<img style="display: inline-block;" src="'+srcImg+'Water_level_up.png">');
		}
		$('.cmd[data-cmd_uid=#uid#] .state').text(state);
	}
	jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#',alertLevel:'#alertLevel#'});
	</script>
</div>
Jeedom Stable 3.3
NUC Z83 + Aeotec Z-Stick Gen5
Z-Wave FGR + FGMS + FGDS + FGFS + FGK + FGWPE + ZW062 + ZW080
GH Mini + Orvibo AllOne + Playbulb + Miband2

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 28 mai 2019, 15:13

Merci beaucoup, je teste ça de suite. A noter que le widget a été créé avec l'assistant.
faut il croire que l'assistant ne fait pas les choses si bien que ça ?

sebforum29
Timide
Messages : 349
Inscription : 04 janv. 2018, 20:17

Re: modif widget pour qu'il soit compatible V3.22

Message par sebforum29 » 28 mai 2019, 18:02

@cavador : Merci beaucoup, ça fonctionne nickel !!
comme quoi, même en passant par l'assistant, les widget ne se rafraichissent pas ....... :roll:

Répondre

Revenir vers « [Plugin officiel] Widgets »

Qui est en ligne ?

Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 3 invités