2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 20:24:36 +00:00

76_SMAPortal: contrib 2.4.0

git-svn-id: https://svn.fhem.de/fhem/trunk@19717 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2019-06-26 21:43:03 +00:00
parent d385fe259b
commit 2e9c4c34ba
3 changed files with 45 additions and 15 deletions

View File

@ -161,6 +161,7 @@ use vars qw($FW_ME); # webname (default is fh
# Versions History intern # Versions History intern
our %vNotesIntern = ( our %vNotesIntern = (
"2.4.0" => "26.06.2019 support for FTUI-Widget ",
"2.3.7" => "24.06.2019 replace suggestIcon by consumerAdviceIcon ", "2.3.7" => "24.06.2019 replace suggestIcon by consumerAdviceIcon ",
"2.3.6" => "21.06.2019 revise commandref ", "2.3.6" => "21.06.2019 revise commandref ",
"2.3.5" => "20.06.2019 subroutine consinject added to pv, pvco style ", "2.3.5" => "20.06.2019 subroutine consinject added to pv, pvco style ",
@ -1823,8 +1824,8 @@ return($txt);
############################################################################### ###############################################################################
# Subroutine für Portalgrafik # Subroutine für Portalgrafik
############################################################################### ###############################################################################
sub PortalAsHtml ($$) { sub PortalAsHtml ($$;$) {
my ($name,$wlname) = @_; my ($name,$wlname,$ftui) = @_;
my $hash = $defs{$name}; my $hash = $defs{$name};
my $ret = ""; my $ret = "";
@ -1879,6 +1880,12 @@ sub PortalAsHtml ($$) {
my $cmdoff = "\"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name $txt off')\""; my $cmdoff = "\"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name $txt off')\"";
my $cmdauto = "\"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name $txt auto')\""; my $cmdauto = "\"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name $txt auto')\"";
if ($ftui && $ftui eq "ftui") {
$cmdon = "\"ftui.setFhemStatus('set $name $txt on')\"";
$cmdoff = "\"ftui.setFhemStatus('set $name $txt off')\"";
$cmdauto = "\"ftui.setFhemStatus('set $name $txt auto')\"";
}
my $swstate = ReadingsVal($name,"L3_".$txt."_Switch", "undef"); my $swstate = ReadingsVal($name,"L3_".$txt."_Switch", "undef");
my $swicon = "<img src=\"$FW_ME/www/images/default/1px-spacer.png\">"; my $swicon = "<img src=\"$FW_ME/www/images/default/1px-spacer.png\">";
if($swstate eq "off") { if($swstate eq "off") {

View File

@ -34,12 +34,15 @@ eval "use FHEM::Meta;1" or my $modMetaAbsent = 1;
# Versions History intern # Versions History intern
our %SMAPortalSPG_vNotesIntern = ( our %SMAPortalSPG_vNotesIntern = (
"1.4.0" => "26.06.2019 support for FTUI-Widget ",
"1.3.0" => "24.06.2019 replace suggestIcon by consumerAdviceIcon ", "1.3.0" => "24.06.2019 replace suggestIcon by consumerAdviceIcon ",
"1.2.0" => "21.06.2019 GetFn -> get <name> html ", "1.2.0" => "21.06.2019 GetFn -> get <name> html ",
"1.1.0" => "13.06.2019 commandRef revised, changed attribute W/kW to Wh/kWh ", "1.1.0" => "13.06.2019 commandRef revised, changed attribute W/kW to Wh/kWh ",
"1.0.0" => "03.06.2019 initial Version " "1.0.0" => "03.06.2019 initial Version "
); );
sub SMAPortalSPG_AsHtml($;$$);
################################################################ ################################################################
sub SMAPortalSPG_Initialize($) { sub SMAPortalSPG_Initialize($) {
my ($hash) = @_; my ($hash) = @_;
@ -127,6 +130,10 @@ sub SMAPortalSPG_Get($@) {
return SMAPortalSPG_AsHtml($hash); return SMAPortalSPG_AsHtml($hash);
} }
if ($cmd eq "ftui") {
return SMAPortalSPG_AsHtml($hash,"ftui");
}
return undef; return undef;
return "Unknown argument $cmd, choose one of html:noArg"; return "Unknown argument $cmd, choose one of html:noArg";
} }
@ -284,12 +291,18 @@ return;
################################################################ ################################################################
# Grafik als HTML zurück liefern (z.B. für Widget) # Grafik als HTML zurück liefern (z.B. für Widget)
################################################################ ################################################################
sub SMAPortalSPG_AsHtml($) { sub SMAPortalSPG_AsHtml($;$) {
my ($hash) = @_; my ($hash,$ftui) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $link = $hash->{LINK}; my $link = $hash->{LINK};
my $height; my $height;
if ($ftui && $ftui eq "ftui") {
# Aufruf aus TabletUI -> FW_cmd ersetzen gemäß FTUI Syntax
my $s = substr($link,0,length($link)-2);
$link = $s.",'$ftui')}";
}
$link = AnalyzePerlCommand(undef, $link) if($link =~ m/^{(.*)}$/s); $link = AnalyzePerlCommand(undef, $link) if($link =~ m/^{(.*)}$/s);
my $alias = AttrVal($name, "alias", $name); # Linktext als Aliasname oder Devicename setzen my $alias = AttrVal($name, "alias", $name); # Linktext als Aliasname oder Devicename setzen

View File

@ -4,6 +4,16 @@
* Under MIT License (http://www.opensource.org/licenses/mit-license.php) * 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>
*/
/* global ftui:true, Modul_widget:true */ /* global ftui:true, Modul_widget:true */
"use strict"; "use strict";
@ -11,8 +21,8 @@
var Modul_smaportalspg = function () { var Modul_smaportalspg = function () {
function init_attr(elem) { function init_attr(elem) {
elem.initData('get', 'STATE'); elem.initData('get', 'parentState');
elem.initData('max-update', 60); elem.initData('max-update', 2);
me.addReading(elem, 'get'); me.addReading(elem, 'get');
} }
@ -25,7 +35,7 @@ var Modul_smaportalspg = function () {
.each(function (index) { .each(function (index) {
var elem = $(this); var elem = $(this);
var value = elem.getReading('get').val; var value = elem.getReading('get').val;
//console.log('readingsgroup:',value); //console.log('smaportalspg:',value);
if (ftui.isValid(value)) { if (ftui.isValid(value)) {
var dNow = new Date(); var dNow = new Date();
@ -34,14 +44,14 @@ var Modul_smaportalspg = function () {
if (isNaN(lMaxUpdate) || (lMaxUpdate < 1)) if (isNaN(lMaxUpdate) || (lMaxUpdate < 1))
lMaxUpdate = 10; lMaxUpdate = 10;
//console.log('readingsgroup update time stamp diff : ', dNow - lUpdate, ' param maxUPdate :' + lMaxUpdate + ' : ' + $(this).data('max-update') ); //console.log('smaportalspg update time stamp diff : ', dNow - lUpdate, ' param maxUPdate :' + lMaxUpdate + ' : ' + $(this).data('max-update') );
lUpdate = (((dNow - lUpdate) / 1000) > lMaxUpdate) ? null : lUpdate; lUpdate = (((dNow - lUpdate) / 1000) > lMaxUpdate) ? null : lUpdate;
if (lUpdate === null) { if (lUpdate === null) {
//console.log('readingsgroup DO update' ); //console.log('smaportalspg DO update' );
elem.data('lastUpdate', dNow); elem.data('lastUpdate', dNow);
var cmd = [ 'get', elem.data('device'), "html" ].join(' '); var cmd = [ 'get', elem.data('device'), "ftui" ].join(' ');
ftui.log('readingsgroup update', dev, ' - ', cmd); ftui.log('smaportalspg update', dev, ' - ', cmd);
ftui.sendFhemCommand(cmd) ftui.sendFhemCommand(cmd)
.done(function (data, dev) { .done(function (data, dev) {