mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 06:48:43 +00:00
98_weekprofile: add log messages + correct widget remove profile
git-svn-id: https://svn.fhem.de/fhem/trunk@10249 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
75bdb8bd18
commit
7973e1ec9f
@ -67,7 +67,9 @@ sub weekprofile_getDeviceType($)
|
|||||||
|
|
||||||
# determine device type
|
# determine device type
|
||||||
my $devHash = $main::defs{$device};
|
my $devHash = $main::defs{$device};
|
||||||
return undef unless (!defined($devHash));
|
if (!defined($devHash)){
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
my $type = undef;
|
my $type = undef;
|
||||||
|
|
||||||
@ -244,8 +246,14 @@ sub weekprofile_assignDev($)
|
|||||||
|
|
||||||
my $prf = undef;
|
my $prf = undef;
|
||||||
if ($hash->{MASTERDEV}->{NAME}) {
|
if ($hash->{MASTERDEV}->{NAME}) {
|
||||||
|
|
||||||
|
Log3 $me, 5, "$me(assignDev): assign to device $hash->{MASTERDEV}->{NAME}";
|
||||||
|
|
||||||
my $type = weekprofile_getDeviceType($hash->{MASTERDEV}->{NAME});
|
my $type = weekprofile_getDeviceType($hash->{MASTERDEV}->{NAME});
|
||||||
return if (!defined($type));
|
if (!defined($type)) {
|
||||||
|
Log3 $me, 2, "$me(assignDev): device $hash->{MASTERDEV}->{NAME} not supported or defined";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$hash->{MASTERDEV}->{TYPE} = $type;
|
$hash->{MASTERDEV}->{TYPE} = $type;
|
||||||
|
|
||||||
@ -323,7 +331,7 @@ sub weekprofile_Define($$)
|
|||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $me = $a[0];
|
my $me = $a[0];
|
||||||
|
|
||||||
$hash->{MASTERDEV}->{NAME} = undef;
|
$hash->{MASTERDEV}->{NAME} = undef;
|
||||||
$hash->{MASTERDEV}->{NAME} = $a[2] if (@a > 1);
|
$hash->{MASTERDEV}->{NAME} = $a[2] if (@a > 1);
|
||||||
@ -332,11 +340,11 @@ sub weekprofile_Define($$)
|
|||||||
my @profiles = ();
|
my @profiles = ();
|
||||||
$hash->{PROFILES} = \@profiles;
|
$hash->{PROFILES} = \@profiles;
|
||||||
|
|
||||||
weekprofile_assignDev($hash);
|
#$attr{$me}{verbose} = 5;
|
||||||
weekprofile_readProfilesFromFile($hash);
|
|
||||||
weekprofile_updateReadings($hash);
|
|
||||||
|
|
||||||
#$attr{$me}{verbose} = 5;
|
weekprofile_assignDev($hash);
|
||||||
|
weekprofile_updateReadings($hash);
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
##############################################
|
##############################################
|
||||||
@ -495,6 +503,7 @@ sub weekprofile_Set($$@)
|
|||||||
if ($cmd eq 'remove_profile') {
|
if ($cmd eq 'remove_profile') {
|
||||||
return 'usage: remove_profile <name>' if(@params < 1);
|
return 'usage: remove_profile <name>' if(@params < 1);
|
||||||
return 'Error master profile can not removed' if($params[0] eq "master");
|
return 'Error master profile can not removed' if($params[0] eq "master");
|
||||||
|
return 'Error Remove last profile is not allowed' if(scalar(@{$hash->{PROFILES}}) == 1);
|
||||||
|
|
||||||
my $delprf = undef;
|
my $delprf = undef;
|
||||||
my $idx = 0;
|
my $idx = 0;
|
||||||
@ -539,7 +548,6 @@ sub weekprofile_Notify($$)
|
|||||||
|
|
||||||
if ($what =~ m/INITIALIZED/) {
|
if ($what =~ m/INITIALIZED/) {
|
||||||
splice($own->{PROFILES});
|
splice($own->{PROFILES});
|
||||||
Log3 $me, 5, "$me(Notify): assign to device $own->{MASTERDEV}->{NAME}" if (defined($own->{MASTERDEV}->{NAME}));
|
|
||||||
weekprofile_assignDev($own);
|
weekprofile_assignDev($own);
|
||||||
weekprofile_readProfilesFromFile($own);
|
weekprofile_readProfilesFromFile($own);
|
||||||
weekprofile_updateReadings($own);
|
weekprofile_updateReadings($own);
|
||||||
|
@ -49,12 +49,11 @@ function weekprofile_DoEditWeek(devName)
|
|||||||
widget.setValueFn("REUSEPRF");
|
widget.setValueFn("REUSEPRF");
|
||||||
}
|
}
|
||||||
|
|
||||||
function FW_weekprofilePRFCached(devName,select)
|
function FW_weekprofilePRFChached(devName,select)
|
||||||
{
|
{
|
||||||
var widget = $('div[informid="'+devName+'"]').get(0)
|
var widget = $('div[informid="'+devName+'"]').get(0)
|
||||||
|
|
||||||
var prfName = select.options[select.selectedIndex].value;
|
var prfName = select.options[select.selectedIndex].value;
|
||||||
|
|
||||||
widget.CURPRF = prfName;
|
widget.CURPRF = prfName;
|
||||||
widget.PROFILE = null;
|
widget.PROFILE = null;
|
||||||
FW_queryValue('get '+devName+' profile_data '+prfName, widget);
|
FW_queryValue('get '+devName+' profile_data '+prfName, widget);
|
||||||
@ -77,7 +76,7 @@ function FW_weekprofileCopyPrf(devName,lnk)
|
|||||||
|
|
||||||
FW_weekprofileInputDialog("<span>Name:</span>","text",lnk,function(name,ok){
|
FW_weekprofileInputDialog("<span>Name:</span>","text",lnk,function(name,ok){
|
||||||
if (!name || name.length <=0)
|
if (!name || name.length <=0)
|
||||||
return;
|
return;
|
||||||
FW_cmd(FW_root+"?cmd=set "+widget.DEVICE+" copy_profile "+widget.CURPRF+" "+name+"&XHR=1",function(arg) {FW_weekprofileSendCallback(widget.DEVICE,arg);});
|
FW_cmd(FW_root+"?cmd=set "+widget.DEVICE+" copy_profile "+widget.CURPRF+" "+name+"&XHR=1",function(arg) {FW_weekprofileSendCallback(widget.DEVICE,arg);});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -88,7 +87,7 @@ function FW_weekprofileRemovePrf(devName,lnk)
|
|||||||
|
|
||||||
FW_weekprofileInputDialog("<p>Delete Profile: '"+widget.CURPRF+"' ?</p>","hidden",lnk,function(name,ok){
|
FW_weekprofileInputDialog("<p>Delete Profile: '"+widget.CURPRF+"' ?</p>","hidden",lnk,function(name,ok){
|
||||||
if (ok < 1)
|
if (ok < 1)
|
||||||
return;
|
return;
|
||||||
FW_cmd(FW_root+"?cmd=set "+widget.DEVICE+" remove_profile "+widget.CURPRF+"&XHR=1",function(arg) {FW_weekprofileSendCallback(widget.DEVICE,arg);});
|
FW_cmd(FW_root+"?cmd=set "+widget.DEVICE+" remove_profile "+widget.CURPRF+"&XHR=1",function(arg) {FW_weekprofileSendCallback(widget.DEVICE,arg);});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -103,7 +102,7 @@ function FW_weekprofileShow(widget)
|
|||||||
|
|
||||||
if (widget.PROFILENAMES) {
|
if (widget.PROFILENAMES) {
|
||||||
html += " "
|
html += " "
|
||||||
html += "<select name=\"PROFILES\" onchange=\"FW_weekprofilePRFCached('"+widget.DEVICE+"',this)\">";
|
html += "<select name=\"PROFILES\" onchange=\"FW_weekprofilePRFChached('"+widget.DEVICE+"',this)\">";
|
||||||
for (var k=0; k < widget.PROFILENAMES.length; k++)
|
for (var k=0; k < widget.PROFILENAMES.length; k++)
|
||||||
{
|
{
|
||||||
var selected = (widget.CURPRF == widget.PROFILENAMES[k]) ? "selected " : "";
|
var selected = (widget.CURPRF == widget.PROFILENAMES[k]) ? "selected " : "";
|
||||||
@ -121,6 +120,11 @@ function FW_weekprofileShow(widget)
|
|||||||
html += "<button type=\"button\" onclick=\"FW_weekprofileSendToDev('"+widget.DEVICE+"',this)\" data-toggle=\"tooltip\" title=\"send to device\">--></button>";
|
html += "<button type=\"button\" onclick=\"FW_weekprofileSendToDev('"+widget.DEVICE+"',this)\" data-toggle=\"tooltip\" title=\"send to device\">--></button>";
|
||||||
|
|
||||||
$(widget.MENU.CONTENT).append(html);
|
$(widget.MENU.CONTENT).append(html);
|
||||||
|
|
||||||
|
var select = $(widget.MENU.CONTENT).find('select[name="PROFILES"]').get(0);
|
||||||
|
var prfName = select.options[select.selectedIndex].value;
|
||||||
|
if (widget.CURPRF != prfName)
|
||||||
|
FW_weekprofilePRFChached(widget.DEVICE,select);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!widget.PROFILE) {
|
if (!widget.PROFILE) {
|
||||||
@ -403,7 +407,7 @@ function FW_weekprofileGetValues(devName,what,data)
|
|||||||
widget.WEEKDAYS = data.split(',');
|
widget.WEEKDAYS = data.split(',');
|
||||||
} else if (what == "PROFILENAMES") {
|
} else if (what == "PROFILENAMES") {
|
||||||
widget.PROFILENAMES = data.split(',');
|
widget.PROFILENAMES = data.split(',');
|
||||||
if (widget.MODE != 'EDIT') {
|
if (widget.MODE != 'EDIT') {
|
||||||
widget.setValueFn("REUSEPRF");
|
widget.setValueFn("REUSEPRF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user