Script JSON. Station météo Davis Instruments

Bonjour,

Si vous avez l’intention de traiter rtd > forrule pour avoir la description de la météo en anglais, voici un widget code à affecter à la commande du plugin script.

Widget code: cmd.info.string.MeteoPiDescription.html
<div class="cmd cmd-widget #history#" data-type="info" data-subtype="string" data-template="meteopi" data-cmd_id="#id#" data-cmd_uid="#uid#" data-version="#version#" data-eqLogic_id="#eqLogic_id#">
  <div class="content-xs">
    <span class="cmdName #hide_name#">#name_display#</span> <span class="value"></span> <strong class="unit"></strong>
  </div>
  <div class="timeCmd label label-default #history#" data-type="info"></div>
  <template>
    <div>time : duration|date ({{Affiche durée ou date de la valeur}})</div>
  </template>
  <script>
    function forecast(frule){
      switch(parseInt(frule)){
        case 0: return "Mostly clear and cooler.";break;
        case 1: return "Mostly clear with little temperature change.";break;
        case 2: return "Mostly clear for 12 hrs. with little temperature change.";break;
        case 3: return "Mostly clear for 12 to 24 hrs. and cooler.";break;
        case 4: return "Mostly clear with little temperature change.";break;
        case 5: return "Partly cloudy and cooler.";break;
        case 6: return "Partly cloudy with little temperature change.";break;
        case 7: return "Partly cloudy with little temperature change.";break;
        case 8: return "Mostly clear and warmer.";break;
        case 9: return "Partly cloudy with little temperature change.";break;
        case 10: return "Partly cloudy with little temperature change.";break;
        case 11: return "Mostly clear with little temperature change.";break;
        case 12: return "Increasing clouds and warmer. Precipitation possible within 24 to 48 hrs.";break;
        case 13: return "Partly cloudy with little temperature change.";break;
        case 14: return "Mostly clear with little temperature change.";break;
        case 15: return "Increasing clouds with little temperature change. Precipitation possible within 24 hrs.";break;
        case 16: return "Mostly clear with little temperature change.";break;
        case 17: return "Partly cloudy with little temperature change.";break;
        case 18: return "Mostly clear with little temperature change.";break;
        case 19: return "Increasing clouds with little temperature change. Precipitation possible within 12 hrs.";break;
        case 20: return "Mostly clear with little temperature change.";break;
        case 21: return "Partly cloudy with little temperature change.";break;
        case 22: return "Mostly clear with little temperature change.";break;
        case 23: return "Increasing clouds and warmer. Precipitation possible within 24 hrs.";break;
        case 24: return "Mostly clear and warmer. Increasing winds.";break;
        case 25: return "Partly cloudy with little temperature change.";break;
        case 26: return "Mostly clear with little temperature change.";break;
        case 27: return "Increasing clouds and warmer. Precipitation possible within 12 hrs. Increasing winds.";break;
        case 28: return "Mostly clear and warmer. Increasing winds.";break;
        case 29: return "Increasing clouds and warmer.";break;
        case 30: return "Partly cloudy with little temperature change.";break;
        case 31: return "Mostly clear with little temperature change.";break;
        case 32: return "Increasing clouds and warmer. Precipitation possible within 12 hrs. Increasing winds.";break;
        case 33: return "Mostly clear and warmer. Increasing winds.";break;
        case 34: return "Increasing clouds and warmer.";break;
        case 35: return "Partly cloudy with little temperature change.";break;
        case 36: return "Mostly clear with little temperature change.";break;
        case 37: return "Increasing clouds and warmer. Precipitation possible within 12 hrs. Increasing winds.";break;
        case 38: return "Partly cloudy with little temperature change.";break;
        case 39: return "Mostly clear with little temperature change.";break;
        case 40: return "Mostly clear and warmer. Precipitation possible within 48 hrs.";break;
        case 41: return "Mostly clear and warmer.";break;
        case 42: return "Partly cloudy with little temperature change.";break;
        case 43: return "Mostly clear with little temperature change.";break;
        case 44: return "Increasing clouds with little temperature change. Precipitation possible within 24 to 48 hrs.";break;
        case 45: return "Increasing clouds with little temperature change.";break;
        case 46: return "Partly cloudy with little temperature change.";break;
        case 47: return "Mostly clear with little temperature change.";break;
        case 48: return "Increasing clouds and warmer. Precipitation possible within 12 to 24 hrs.";break;
        case 49: return "Partly cloudy with little temperature change.";break;
        case 50: return "Mostly clear with little temperature change.";break;
        case 51: return "Increasing clouds and warmer. Precipitation possible within 12 to 24 hrs. Windy.";break;
        case 52: return "Partly cloudy with little temperature change.";break;
        case 53: return "Mostly clear with little temperature change.";break;
        case 54: return "Increasing clouds and warmer. Precipitation possible within 12 to 24 hrs. Windy.";break;
        case 55: return "Partly cloudy with little temperature change.";break;
        case 56: return "Mostly clear with little temperature change.";break;
        case 57: return "Increasing clouds and warmer. Precipitation possible within 6 to 12 hrs.";break;
        case 58: return "Partly cloudy with little temperature change.";break;
        case 59: return "Mostly clear with little temperature change.";break;
        case 60: return "Increasing clouds and warmer. Precipitation possible within 6 to 12 hrs. Windy.";break;
        case 61: return "Partly cloudy with little temperature change.";break;
        case 62: return "Mostly clear with little temperature change.";break;
        case 63: return "Increasing clouds and warmer. Precipitation possible within 12 to 24 hrs. Windy.";break;
        case 64: return "Partly cloudy with little temperature change.";break;
        case 65: return "Mostly clear with little temperature change.";break;
        case 66: return "Increasing clouds and warmer. Precipitation possible within 12 hrs.";break;
        case 67: return "Partly cloudy with little temperature change.";break;
        case 68: return "Mostly clear with little temperature change.";break;
        case 69: return "Increasing clouds and warmer. Precipitation likely.";break;
        case 70: return "clearing and cooler. Precipitation ending within 6 hrs.";break;
        case 71: return "Partly cloudy with little temperature change.";break;
        case 72: return "clearing and cooler. Precipitation ending within 6 hrs.";break;
        case 73: return "Mostly clear with little temperature change.";break;
        case 74: return "Clearing and cooler. Precipitation ending within 6 hrs.";break;
        case 75: return "Partly cloudy and cooler.";break;
        case 76: return "Partly cloudy with little temperature change.";break;
        case 77: return "Mostly clear and cooler.";break;
        case 78: return "clearing and cooler. Precipitation ending within 6 hrs.";break;
        case 79: return "Mostly clear with little temperature change.";break;
        case 80: return "Clearing and cooler. Precipitation ending within 6 hrs.";break;
        case 81: return "Mostly clear and cooler.";break;
        case 82: return "Partly cloudy with little temperature change.";break;
        case 83: return "Mostly clear with little temperature change.";break;
        case 84: return "Increasing clouds with little temperature change. Precipitation possible within 24 hrs.";break;
        case 85: return "Mostly cloudy and cooler. Precipitation continuing.";break;
        case 86: return "Partly cloudy with little temperature change.";break;
        case 87: return "Mostly clear with little temperature change.";break;
        case 88: return "Mostly cloudy and cooler. Precipitation likely.";break;
        case 89: return "Mostly cloudy with little temperature change. Precipitation continuing.";break;
        case 90: return "Mostly cloudy with little temperature change. Precipitation likely.";break;
        case 91: return "Partly cloudy with little temperature change.";break;
        case 92: return "Mostly clear with little temperature change.";break;
        case 93: return "Increasing clouds and cooler. Precipitation possible and windy within 6 hrs.";break;
        case 94: return "Increasing clouds with little temperature change. Precipitation possible and windy within 6 hrs.";break;
        case 95: return "Mostly cloudy and cooler. Precipitation continuing. Increasing winds.";break;
        case 96: return "Partly cloudy with little temperature change.";break;
        case 97: return "Mostly clear with little temperature change.";break;
        case 98: return "Mostly cloudy and cooler. Precipitation likely. Increasing winds.";break;
        case 99: return "Mostly cloudy with little temperature change. Precipitation continuing. Increasing winds.";break;
        case 100: return "Mostly cloudy with little temperature change. Precipitation likely. Increasing winds.";break;
        case 101: return "Partly cloudy with little temperature change.";break;
        case 102: return "Mostly clear with little temperature change.";break;
        case 103: return "Increasing clouds and cooler. Precipitation possible within 12 to 24 hrs. Possible wind shift to the W, NW, or N.";break;
        case 104: return "Increasing clouds with little temperature change. Precipitation possible within 12 to 24 hrs. Possible wind shift to the W, NW, or N.";break;
        case 105: return "Partly cloudy with little temperature change.";break;
        case 106: return "Mostly clear with little temperature change.";break;
        case 107: return "Increasing clouds and cooler. Precipitation possible within 6 hrs. Possible wind shift to the W, NW, or N.";break;
        case 108: return "Increasing clouds with little temperature change. Precipitation possible within 6 hrs. Possible wind shift to the W, NW, or N.";break;
        case 109: return "Mostly cloudy and cooler. Precipitation ending within 12 hrs. Possible wind shift to the W, NW, or N.";break;
        case 110: return "Mostly cloudy and cooler. Possible wind shift to the W, NW, or N.";break;
        case 111: return "Mostly cloudy with little temperature change. Precipitation ending within 12 hrs. Possible wind shift to the W, NW, or N.";break;
        case 112: return "Mostly cloudy with little temperature change. Possible wind shift to the W, NW, or N.";break;
        case 113: return "Mostly cloudy and cooler. Precipitation ending within 12 hrs. Possible wind shift to the W, NW, or N.";break;
        case 114: return "Partly cloudy with little temperature change.";break;
        case 115: return "Mostly clear with little temperature change.";break;
        case 116: return "Mostly cloudy and cooler. Precipitation possible within 24 hrs. Possible wind shift to the W, NW, or N.";break;
        case 117: return "Mostly cloudy with little temperature change. Precipitation ending within 12 hrs. Possible wind shift to the W, NW, or N.";break;
        case 118: return "Mostly cloudy with little temperature change. Precipitation possible within 24 hrs. Possible wind shift to the W, NW, or N.";break;
        case 119: return "clearing, cooler and windy. Precipitation ending within 6 hrs.";break;
        case 120: return "clearing, cooler and windy.";break;
        case 121: return "Mostly cloudy and cooler. Precipitation ending within 6 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 122: return "Mostly cloudy and cooler. Windy with possible wind shift to the W, NW, or N.";break;
        case 123: return "clearing, cooler and windy.";break;
        case 124: return "Partly cloudy with little temperature change.";break;
        case 125: return "Mostly clear with little temperature change.";break;
        case 126: return "Mostly cloudy with little temperature change. Precipitation possible within 12 hrs. Windy.";break;
        case 127: return "Partly cloudy with little temperature change.";break;
        case 128: return "Mostly clear with little temperature change.";break;
        case 129: return "Increasing clouds and cooler. Precipitation possible within 12 hrs., possibly heavy at times. Windy.";break;
        case 130: return "Mostly cloudy and cooler. Precipitation ending within 6 hrs. Windy.";break;
        case 131: return "Partly cloudy with little temperature change.";break;
        case 132: return "Mostly clear with little temperature change.";break;
        case 133: return "Mostly cloudy and cooler. Precipitation possible within 12 hrs. Windy.";break;
        case 134: return "Mostly cloudy and cooler. Precipitation ending in 12 to 24 hrs.";break;
        case 135: return "Mostly cloudy and cooler.";break;
        case 136: return "Mostly cloudy and cooler. Precipitation continuing, possible heavy at times. Windy.";break;
        case 137: return "Partly cloudy with little temperature change.";break;
        case 138: return "Mostly clear with little temperature change.";break;
        case 139: return "Mostly cloudy and cooler. Precipitation possible within 6 to 12 hrs. Windy.";break;
        case 140: return "Mostly cloudy with little temperature change. Precipitation continuing, possibly heavy at times. Windy.";break;
        case 141: return "Partly cloudy with little temperature change.";break;
        case 142: return "Mostly clear with little temperature change.";break;
        case 143: return "Mostly cloudy with little temperature change. Precipitation possible within 6 to 12 hrs. Windy.";break;
        case 144: return "Partly cloudy with little temperature change.";break;
        case 145: return "Mostly clear with little temperature change.";break;
        case 146: return "Increasing clouds with little temperature change. Precipitation possible within 12 hrs., possibly heavy at times. Windy.";break;
        case 147: return "Mostly cloudy and cooler. Windy.";break;
        case 148: return "Mostly cloudy and cooler. Precipitation continuing, possibly heavy at times. Windy.";break;
        case 149: return "Partly cloudy with little temperature change.";break;
        case 150: return "Mostly clear with little temperature change.";break;
        case 151: return "Mostly cloudy and cooler. Precipitation likely, possibly heavy at times. Windy.";break;
        case 152: return "Mostly cloudy with little temperature change. Precipitation continuing, possibly heavy at times. Windy.";break;
        case 153: return "Mostly cloudy with little temperature change. Precipitation likely, possibly heavy at times. Windy.";break;
        case 154: return "Partly cloudy with little temperature change.";break;
        case 155: return "Mostly clear with little temperature change.";break;
        case 156: return "Increasing clouds and cooler. Precipitation possible within 6 hrs. Windy.";break;
        case 157: return "Increasing clouds with little temperature change. Precipitation possible within 6 hrs. windy";break;
        case 158: return "Increasing clouds and cooler. Precipitation continuing. Windy with possible wind shift to the W, NW, or N.";break;
        case 159: return "Partly cloudy with little temperature change.";break;
        case 160: return "Mostly clear with little temperature change.";break;
        case 161: return "Mostly cloudy and cooler. Precipitation likely. Windy with possible wind shift to the W, NW, or N.";break;
        case 162: return "Mostly cloudy with little temperature change. Precipitation continuing. Windy with possible wind shift to the W, NW, or N.";break;
        case 163: return "Mostly cloudy with little temperature change. Precipitation likely. Windy with possible wind shift to the W, NW, or N.";break;
        case 164: return "Increasing clouds and cooler. Precipitation possible within 6 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 165: return "Partly cloudy with little temperature change.";break;
        case 166: return "Mostly clear with little temperature change.";break;
        case 167: return "Increasing clouds and cooler. Precipitation possible within 6 hrs. Possible wind shift to the W, NW, or N.";break;
        case 168: return "Increasing clouds with little temperature change. Precipitation possible within 6 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 169: return "Increasing clouds with little temperature change. Precipitation possible within 6 hrs. Possible wind shift to the W, NW, or N.";break;
        case 170: return "Partly cloudy with little temperature change.";break;
        case 171: return "Mostly clear with little temperature change.";break;
        case 172: return "Increasing clouds and cooler. Precipitation possible within 6 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 173: return "Increasing clouds with little temperature change. Precipitation possible within 6 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 174: return "Partly cloudy with little temperature change.";break;
        case 175: return "Mostly clear with little temperature change.";break;
        case 176: return "Increasing clouds and cooler. Precipitation possible within 12 to 24 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 177: return "Increasing clouds with little temperature change. Precipitation possible within 12 to 24 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 178: return "Mostly cloudy and cooler. Precipitation possibly heavy at times and ending within 12 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 179: return "Partly cloudy with little temperature change.";break;
        case 180: return "Mostly clear with little temperature change.";break;
        case 181: return "Mostly cloudy and cooler. Precipitation possible within 6 to 12 hrs., possibly heavy at times. Windy with possible wind shift to the W, NW, or N.";break;
        case 182: return "Mostly cloudy with little temperature change. Precipitation ending within 12 hrs. Windy with possible wind shift to the W, NW, or N.";break;
        case 183: return "Mostly cloudy with little temperature change. Precipitation possible within 6 to 12 hrs., possibly heavy at times. Windy with possible wind shift to the W, NW, or N.";break;
        case 184: return "Mostly cloudy and cooler. Precipitation continuing.";break;
        case 185: return "Partly cloudy with little temperature change.";break;
        case 186: return "Mostly clear with little temperature change.";break;
        case 187: return "Mostly cloudy and cooler. Precipitation likely, windy with possible wind shift to the W, NW, or N.";break;
        case 188: return "Mostly cloudy with little temperature change. Precipitation continuing.";break;
        case 189: return "Mostly cloudy with little temperature change. Precipitation likely.";break;
        case 190: return "Partly cloudy with little temperature change.";break;
        case 191: return "Mostly clear with little temperature change.";break;
        case 192: return "Mostly cloudy and cooler. Precipitation possible within 12 hours, possibly heavy at times. Windy.";break;
        case 193: return "FORECAST REQUIRES 3 HRS. OF RECENT DATA";break;
        case 194: return "Mostly clear and cooler.";break;
        default: return '---'; break;
      }
    }

    jeedom.cmd.addUpdateFunction('#id#', function(_options) {
      if (is_object(cmd = document.querySelector('.cmd[data-cmd_uid="#uid#"]'))) {
        cmd.querySelector('.content-xs').setAttribute('title', '{{Date de valeur}}: ' + _options.valueDate + '<br>{{Date de collecte}}: ' + _options.collectDate)
        if ('#time#' == 'duration' || '#time#' == 'date') {
          jeedom.cmd.displayDuration(_options.valueDate, cmd.querySelector('.timeCmd'), '#time#')
        }

        cmd.querySelector('.value').innerHTML = forecast(_options.display_value);
        cmd.querySelector('.unit').innerHTML = _options.unit

        if (_options.alertLevel == 'warning') {
          cmd.querySelector('.value').innerHTML = '<span class="label label-warning"><i class="fas fa-bell"></i> ' + _options.value + '</span>'
        } else if (_options.alertLevel == 'danger') {
          cmd.querySelector('.value').innerHTML = '<span class="label label-danger"><i class="fas fa-exclamation"></i> ' + _options.value + '</span>'
        }
      }
    })

    jeedom.cmd.refreshValue([{ cmd_id: '#id#', value: '#value#', display_value: '#state#', valueDate: '#valueDate#', collectDate: '#collectDate#', alertLevel: '#alertLevel#', unit: '#unite#' }])
  </script>
</div>

A sauvegarder dans data/customTemplates/dashboard/
image

La cmd à créer dans le plugin script:
image

1 « J'aime »

Bonjour,
Merci je me suis absenté je vais regarder a mon retour

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.