mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
SolarForecast: contrib/SolarForecast files changed
git-svn-id: https://svn.fhem.de/fhem/trunk@28256 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
429340664d
commit
89624cc4a0
@ -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
|
||||
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
|
5
fhem/contrib/SolarForecast/ftui_smaportalspg.css
Normal file
5
fhem/contrib/SolarForecast/ftui_smaportalspg.css
Normal file
@ -0,0 +1,5 @@
|
||||
[data-type="smaportalspg"] svg {
|
||||
height: 2em;
|
||||
width: 2em;
|
||||
}
|
||||
|
94
fhem/contrib/SolarForecast/widget_smaportalspg.js
Normal file
94
fhem/contrib/SolarForecast/widget_smaportalspg.js
Normal file
@ -0,0 +1,94 @@
|
||||
/* FTUI Plugin
|
||||
* Copyright (c) 2016 Mario Stephan <mstephan@shared-files.de>
|
||||
* originally created by Thomas Nesges,
|
||||
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/* Einbindung:
|
||||
*
|
||||
* <li data-row="1" data-col="1" data-sizey="3" data-sizex="4">
|
||||
* <header>SMA Grafik</header>
|
||||
* <div class="cell">
|
||||
* <div data-type="smaportalspg" data-device="SPG1.Sonnenstrom" data-get="parentState" ></div>
|
||||
* </div>
|
||||
* </li>
|
||||
*/
|
||||
|
||||
/* 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('<link rel="stylesheet" href="'+ ftui.config.basedir + 'css/ftui_smaportalspg.css" type="text/css" />')
|
||||
else
|
||||
$('head').append('<link rel="stylesheet" href="'+ ftui.config.basedir + 'css/ftui_smaportalspg.css" type="text/css" />');
|
||||
|
||||
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;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user