diff --git a/fhem/contrib/SolarForecast/controls_solarforecast.txt b/fhem/contrib/SolarForecast/controls_solarforecast.txt index 1e68157bf..5a7e9e241 100644 --- a/fhem/contrib/SolarForecast/controls_solarforecast.txt +++ b/fhem/contrib/SolarForecast/controls_solarforecast.txt @@ -2,4 +2,6 @@ DIR www/tablet DIR www/tablet/css DIR www/tablet/js UPD 2023-12-04_11:34:56 65 www/tablet/css/ftui_forecast.css -UPD 2023-12-04_11:34:56 3413 www/tablet/js/widget_forecast.js \ No newline at end of file +UPD 2019-06-28_22:09:14 69 www/tablet/css/ftui_smaportalspg.css +UPD 2023-12-04_11:34:56 3413 www/tablet/js/widget_forecast.js +UPD 2019-07-02_23:42:41 3096 www/tablet/js/widget_smaportalspg.js \ No newline at end of file diff --git a/fhem/contrib/SolarForecast/ftui_smaportalspg.css b/fhem/contrib/SolarForecast/ftui_smaportalspg.css new file mode 100644 index 000000000..9029e8cd8 --- /dev/null +++ b/fhem/contrib/SolarForecast/ftui_smaportalspg.css @@ -0,0 +1,5 @@ +[data-type="smaportalspg"] svg { + height: 2em; + width: 2em; +} + diff --git a/fhem/contrib/SolarForecast/widget_smaportalspg.js b/fhem/contrib/SolarForecast/widget_smaportalspg.js new file mode 100644 index 000000000..e5df5fd5d --- /dev/null +++ b/fhem/contrib/SolarForecast/widget_smaportalspg.js @@ -0,0 +1,94 @@ +/* FTUI Plugin + * Copyright (c) 2016 Mario Stephan + * originally created by Thomas Nesges, + * Under MIT License (http://www.opensource.org/licenses/mit-license.php) + */ + +/* Einbindung: + * + *
  • + *
    SMA Grafik
    + *
    + *
    + *
    + *
  • +*/ + +/* Versionen: + * + * 1.0.0 02.07.2019 initial version +*/ + +/* global ftui:true, Modul_widget:true */ + +"use strict"; + +function depends_smaportalspg (){ + var deps = []; + + var userCSS = $('head').find("[href$='css/fhem-tablet-ui.css']"); + + if (userCSS.length) + userCSS.before('') + else + $('head').append(''); + + return deps; +}; + +var Modul_smaportalspg = function () { + + function init_attr(elem) { + elem.initData('get', 'parentState'); + elem.initData('max-update', 2); + + me.addReading(elem, 'get'); + } + + //usage of "function init()" from Modul_widget() + + function update(dev, par) { + + me.elements.filterDeviceReading('get', dev, par) + .each(function (index) { + var elem = $(this); + var value = elem.getReading('get').val; + //console.log('smaportalspg:',value); + if (ftui.isValid(value)) { + var dNow = new Date(); + + var lUpdate = elem.data('lastUpdate') || null; + var lMaxUpdate = parseInt(elem.data('max-update')); + if (isNaN(lMaxUpdate) || (lMaxUpdate < 1)) + lMaxUpdate = 10; + + //console.log('smaportalspg update time stamp diff : ', dNow - lUpdate, ' param maxUPdate :' + lMaxUpdate + ' : ' + $(this).data('max-update') ); + lUpdate = (((dNow - lUpdate) / 1000) > lMaxUpdate) ? null : lUpdate; + if (lUpdate === null) { + //console.log('smaportalspg DO update' ); + elem.data('lastUpdate', dNow); + + var cmd = [ 'get', elem.data('device'), "ftui" ].join(' '); + ftui.log('smaportalspg update', dev, ' - ', cmd); + + ftui.sendFhemCommand(cmd) + .done(function (data, dev) { + //console.log('received update for dynamic html : ', $(this) ); + elem.html(data); + }); + } + } + }); + } + + // public + // inherit all public members from base class + var me = $.extend(new Modul_widget(), { + //override or own public members + widgetname: 'smaportalspg', + init_attr: init_attr, + update: update, + }); + + return me; +}; \ No newline at end of file