mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
98_weekprofile: new command import_profile
git-svn-id: https://svn.fhem.de/fhem/trunk@21086 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
abf5cac518
commit
a63a5c9621
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: 98_weekprofile: new command import_profile
|
||||
- bugfix: 98_weekprofile: html output for command get associations
|
||||
- bugfix: msgSchema: change Typo LGTV_WebOS
|
||||
- bugfix: 88_HMCCU: Fixed next/return bug
|
||||
|
@ -551,6 +551,31 @@ sub weekprofile_refreshSendDevList($)
|
||||
return undef;
|
||||
}
|
||||
|
||||
##############################################
|
||||
sub weekprofile_receiveList($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
my $me = $hash->{NAME};
|
||||
|
||||
my @rcvList = ();
|
||||
|
||||
foreach my $d (keys %defs)
|
||||
{
|
||||
next if ($defs{$d}{NAME} eq $me);
|
||||
|
||||
my $module = $defs{$d}{TYPE};
|
||||
|
||||
my %sndHash;
|
||||
@sndHash{@DEVLIST_SEND}=();
|
||||
next if (!exists $sndHash{$module});
|
||||
|
||||
my $type = weekprofile_getDeviceType($me, $defs{$d}{NAME});
|
||||
next if (!defined($type));
|
||||
push @rcvList, $defs{$d}{NAME};
|
||||
}
|
||||
return @rcvList;
|
||||
}
|
||||
|
||||
##############################################
|
||||
sub weekprofile_assignDev($)
|
||||
{
|
||||
@ -1102,7 +1127,7 @@ sub weekprofile_Set($$@)
|
||||
|
||||
my ($topic, $name) = weekprofile_splitName($me, $params[0]);
|
||||
|
||||
return "Error topics not enabled" if (!$useTopics && ($topic ne 'default'));
|
||||
return "Error topics not enabled" if (!$useTopics && ($topic ne 'default'));
|
||||
|
||||
my ($delprf,$idx) = weekprofile_findPRF($hash,$name,$topic,0);
|
||||
return "Error unknown profile $params[0]" unless($delprf);
|
||||
@ -1160,6 +1185,43 @@ sub weekprofile_Set($$@)
|
||||
return "Error reading master profile";
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
my @rcvList = weekprofile_receiveList($hash);
|
||||
$list.= " import_profile:" if(@rcvList > 0);
|
||||
foreach my $rcvDev (@rcvList) {
|
||||
$list.=$rcvDev.",";
|
||||
}
|
||||
$list = substr($list, 0, -1) if (@rcvList > 0);
|
||||
if ($cmd eq 'import_profile') {
|
||||
return 'usage: import_profile <device> [name]' if(@params < 1);
|
||||
my $device = $params[0];
|
||||
my $type = weekprofile_getDeviceType($me, $device);
|
||||
if (!defined($type)) {
|
||||
Log3 $me, 2, "$me(Set): device $device not supported or defined";
|
||||
return "Error device $device not supported or defined";
|
||||
}
|
||||
my ($topic, $name) = ('default', $device);
|
||||
($topic, $name) = weekprofile_splitName($me, $params[1]) if(@params == 2);
|
||||
return "Error topics not enabled" if (!$useTopics && ($topic ne 'default'));
|
||||
|
||||
my $devPrf = weekprofile_readDevProfile($device,$type,$me);
|
||||
my $prf = {};
|
||||
$prf->{NAME} = $name;
|
||||
$prf->{TOPIC} = $topic;
|
||||
|
||||
if(defined($devPrf)) {
|
||||
$prf->{DATA} = $devPrf;
|
||||
} else {
|
||||
Log3 $me, 2, "device $device has no week profile";
|
||||
return "Error device $device has no week profile";
|
||||
}
|
||||
|
||||
Log3 $me, 3, "profile $topic:$name from $device imported";
|
||||
push @{$hash->{PROFILES}} , $prf;
|
||||
weekprofile_updateReadings($hash);
|
||||
return undef;
|
||||
}
|
||||
|
||||
$list =~ s/ $//;
|
||||
return "Unknown argument $cmd, choose one of $list";
|
||||
@ -1617,6 +1679,10 @@ sub weekprofile_getEditLNK_MasterDev($$)
|
||||
<li>reread_master<br>
|
||||
Refresh (reread) the master profile from the master device.
|
||||
</li>
|
||||
<li>import_profile<br>
|
||||
<code>set <name> import_profile <device> <[profilename]></code><br>
|
||||
Importing a profile from a supported device
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a name="weekprofileget"></a>
|
||||
@ -1797,6 +1863,10 @@ sub weekprofile_getEditLNK_MasterDev($$)
|
||||
<li>reread_master<br>
|
||||
Aktualisiert das master profile indem das 'Master-Geräte' neu ausgelesen wird.
|
||||
</li>
|
||||
<li>import_profile<br>
|
||||
<code>set <name> import_profile <device> <[profilename]></code><br>
|
||||
Profil von einem Gerät importieren.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a name="weekprofileget"></a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user