node-red-contrib-discovergy-meter
Version:
Allows to work with a Discovergy Smart Meter (Electricity only) within Node RED flows
1 lines • 7.88 kB
JavaScript
$(document).ready((function(){let i=!0;const t=function(){if(void 0!==window.localStorage.getItem("msg")&&null!==window.localStorage.getItem("msg")){let t=JSON.parse(window.localStorage.getItem("msg"));if(document.title=(100*t.stats.last24h.energyPrice_kwh).toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:2})+"/kWh "+(-1*t.stats.last24h.incomeSaldo).toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:2})+"/Tag",void 0===t.community)return;let e=$("#communityChart"),a=["24 Stunden","7 Tage","30 Tage","365 Tage"];new Chart(e,{type:"radar",data:{datasets:[{label:"Minimum",data:[t.community.last24h.energyPrice_kwh.min,t.community.last7d.energyPrice_kwh.min,t.community.last30d.energyPrice_kwh.min,t.community.last365d.energyPrice_kwh.min],backgroundColor:"rgba(237,166,69,1)"},{label:"Ich",data:[t.community.last24h.energyPrice_kwh.me,t.community.last7d.energyPrice_kwh.me,t.community.last30d.energyPrice_kwh.me,t.community.last365d.energyPrice_kwh.me],backgroundColor:"rgba(20,109,59.1)"},{label:"Maximum",data:[t.community.last24h.energyPrice_kwh.max,t.community.last7d.energyPrice_kwh.max,t.community.last30d.energyPrice_kwh.max,t.community.last365d.energyPrice_kwh.max],backgroundColor:"rgba(192,192,192,1)"}],labels:a},options:{responsive:!0,legend:{position:"top"},plugins:{datalabels:{display:!0,color:"#000000",formatter:function(i,t){return""+i.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})}}},title:{display:!1,text:""},animation:{animateScale:i,animateRotate:i},tooltips:{enabled:!0,mode:"nearest",callbacks:{label:function(i,t){let e="Maximum";return 0==i.datasetIndex&&(e="Minimum"),1==i.datasetIndex&&(e="Ich"),e+":"+t.datasets[i.datasetIndex].data[i.index]+" €/kWh"}}},elements:{}}});i&&setTimeout((function(){$("#info").addClass("show")}),2e3);let n=t.stats.last24h.consumption_wh*t.meterinfo.energyPriceWh+t.stats.last24h.baseCosts,r=(Math.round(1e4*(1- -1*t.stats.last24h.incomeSaldo/n)),"");if(r+='<tr class="table-success" data-order=0><td>Ich</td>',r+='<td data-order="'+t.community.last24h.energyPrice_kwh.me+'">'+t.community.last24h.energyPrice_kwh.me.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last7d.energyPrice_kwh.me+'">'+t.community.last7d.energyPrice_kwh.me.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last30d.energyPrice_kwh.me+'">'+t.community.last30d.energyPrice_kwh.me.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last365d.energyPrice_kwh.me+'">'+t.community.last365d.energyPrice_kwh.me.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+="</tr>",r+="<tr><td data-order=1>Minimum</td>",r+='<td data-order="'+t.community.last24h.energyPrice_kwh.min+'">'+t.community.last24h.energyPrice_kwh.min.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last7d.energyPrice_kwh.min+'">'+t.community.last7d.energyPrice_kwh.min.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last30d.energyPrice_kwh.min+'">'+t.community.last30d.energyPrice_kwh.min.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last365d.energyPrice_kwh.min+'">'+t.community.last365d.energyPrice_kwh.min.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+="</tr>",r+="<tr><td data-order=2>Durschschnitt</td>",r+='<td data-order="'+t.community.last24h.energyPrice_kwh.avg+'">'+t.community.last24h.energyPrice_kwh.avg.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last7d.energyPrice_kwh.avg+'">'+t.community.last7d.energyPrice_kwh.avg.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last30d.energyPrice_kwh.avg+'">'+t.community.last30d.energyPrice_kwh.avg.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last365d.energyPrice_kwh.avg+'">'+t.community.last365d.energyPrice_kwh.avg.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+="</tr>",r+="<tr><td data-order=3>Maximum</td>",r+='<td data-order="'+t.community.last24h.energyPrice_kwh.max+'">'+t.community.last24h.energyPrice_kwh.max.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last7d.energyPrice_kwh.max+'">'+t.community.last7d.energyPrice_kwh.max.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last30d.energyPrice_kwh.max+'">'+t.community.last30d.energyPrice_kwh.max.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+='<td data-order="'+t.community.last365d.energyPrice_kwh.max+'">'+t.community.last365d.energyPrice_kwh.max.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:4})+"</td>",r+="</tr>",$("#ctable").html(r),i&&$("table").DataTable({searching:!1,paging:!1,info:!1}),window.swiper.removeAllSlides(),t.community.last24h.energyPrice_kwh.avg>t.community.last24h.energyPrice_kwh.me){let i=Math.abs(Math.round(100*(1-t.community.last24h.energyPrice_kwh.me/t.community.last24h.energyPrice_kwh.avg)));window.swiper.appendSlide('<div class="blog-slider__item swiper-slide"><div class="blog-slider__content"><div class="blog-slider__title"><i class="fa fa-info-circle" style=" margin-right: 10px;"></i>24 Stunden Erfolg </div><div class="blog-slider__text" id="info0">Dein Strompreis war in den letzten 24 Stunden <strong>'+i+"% günstiger</strong> als durchschnittlich in der Community.</div></div></div>")}if(t.community.last7d.energyPrice_kwh.avg>t.community.last7d.energyPrice_kwh.me){let i=Math.abs(Math.round(100*(1-t.community.last7d.energyPrice_kwh.me/t.community.last7d.energyPrice_kwh.avg)));window.swiper.appendSlide('<div class="blog-slider__item swiper-slide"><div class="blog-slider__content"><div class="blog-slider__title"><i class="fa fa-info-circle" style=" margin-right: 10px;"></i>7 Tage Erfolg </div><div class="blog-slider__text" id="info0">Dein Strompreis war in den letzten 7 Tagen <strong>'+i+"% günstiger</strong> als durchschnittlich in der Community.</div></div></div>")}if(t.community.last30d.energyPrice_kwh.avg>t.community.last30d.energyPrice_kwh.me){let i=Math.abs(Math.round(100*(1-t.community.last30d.energyPrice_kwh.me/t.community.last30d.energyPrice_kwh.avg)));window.swiper.appendSlide('<div class="blog-slider__item swiper-slide"><div class="blog-slider__content"><div class="blog-slider__title"><i class="fa fa-info-circle" style=" margin-right: 10px;"></i>30 Tage Erfolg </div><div class="blog-slider__text" id="info0">Dein Strompreis war in den letzten 30 Tagen <strong>'+i+"% günstiger</strong> als durchschnittlich in der Community.</div></div></div>")}if(t.community.last365d.energyPrice_kwh.avg>t.community.last365d.energyPrice_kwh.me){let i=Math.abs(Math.round(100*(1-t.community.last365d.energyPrice_kwh.me/t.community.last365d.energyPrice_kwh.avg)));window.swiper.appendSlide('<div class="blog-slider__item swiper-slide"><div class="blog-slider__content"><div class="blog-slider__title"><i class="fa fa-info-circle" style=" margin-right: 10px;"></i>365 Tage Erfolg </div><div class="blog-slider__text" id="info0">Dein Strompreis war in den letzten 365 Tagen <strong>'+i+"% günstiger</strong> als durchschnittlich in der Community.</div></div></div>")}i=!1}},e=function(){$.getJSON("/msg",(function(i){window.localStorage.setItem("msg",JSON.stringify(i)),t()}))};t(),setInterval(e,12e4),e()}));