2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

98_Hyperion.pm: Revert changes to autoreload after get configFiles, introducing new attr hyperionNoSudo

git-svn-id: https://svn.fhem.de/fhem/trunk@11932 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
deespe 2016-08-09 18:25:18 +00:00
parent c683de4aa6
commit 3f5926b580
2 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- changed: 98_Hyperion: introducing new attribute hyperionNoSudo
- changed: 38_netatmo: removed event-on-change default, min HOME interval - changed: 38_netatmo: removed event-on-change default, min HOME interval
- changed: 93_DbRep: usage of "insert" changed, pls. refer to commandref - changed: 93_DbRep: usage of "insert" changed, pls. refer to commandref
- changed: 93_DbRep: function "insert" added, check of numeric value type - changed: 93_DbRep: function "insert" added, check of numeric value type

View File

@ -68,6 +68,7 @@ sub Hyperion_Initialize($)
"hyperionDefaultDuration ". "hyperionDefaultDuration ".
"hyperionDefaultPriority ". "hyperionDefaultPriority ".
"hyperionDimStep ". "hyperionDimStep ".
"hyperionNoSudo:1 ".
"hyperionSshUser ". "hyperionSshUser ".
"queryAfterSet:0 ". "queryAfterSet:0 ".
$readingFnAttributes; $readingFnAttributes;
@ -411,7 +412,8 @@ sub Hyperion_GetConfigs($)
$Hyperion_sets{configFile} = "textField" if ($Hyperion_sets{configFile} ne "textField"); $Hyperion_sets{configFile} = "textField" if ($Hyperion_sets{configFile} ne "textField");
$attr{$name}{webCmd} = $Hyperion_webCmd if (AttrVal($name,"webCmd","") eq $Hyperion_webCmd_config); $attr{$name}{webCmd} = $Hyperion_webCmd if (AttrVal($name,"webCmd","") eq $Hyperion_webCmd_config);
} }
fhem("trigger WEB JS:location.reload(true)"); # fhem("trigger WEB JS:location.reload(true)");
return "Found at least one config file. Please refresh this page to see the result.";
} }
sub Hyperion_listFilesInDir($$) sub Hyperion_listFilesInDir($$)
@ -462,7 +464,7 @@ sub Hyperion_Set($@)
my %obj; my %obj;
Log3 $name,4,"$name: Hyperion_Set cmd: $cmd" if (defined($cmd)); Log3 $name,4,"$name: Hyperion_Set cmd: $cmd" if (defined($cmd));
Log3 $name,4,"$name: Hyperion_Set value: $value" if (defined($value) && $value ne ""); Log3 $name,4,"$name: Hyperion_Set value: $value" if (defined($value) && $value ne "");
Log3 $name,4,"$name: Hyperion_Set duration: $duration,priority: $priority"; Log3 $name,4,"$name: Hyperion_Set duration: $duration, priority: $priority";
if ($cmd eq "configFile") if ($cmd eq "configFile")
{ {
$value = $value.".config.json"; $value = $value.".config.json";
@ -471,7 +473,7 @@ sub Hyperion_Set($@)
my $bin = (split("/",$binpath))[scalar(split("/",$binpath)) - 1]; my $bin = (split("/",$binpath))[scalar(split("/",$binpath)) - 1];
my $user = AttrVal($name,"hyperionSshUser","pi"); my $user = AttrVal($name,"hyperionSshUser","pi");
my $ip = $hash->{IP}; my $ip = $hash->{IP};
my $sudo = ($user eq "root") ? "" : "sudo "; my $sudo = ($user eq "root" || int(AttrVal($name,"hyperionNoSudo",0)) == 1) ? "" : "sudo ";
my $command = $sudo."killall $bin; sleep 1; ".$sudo."$binpath $confdir$value > /dev/null 2>&1 &"; my $command = $sudo."killall $bin; sleep 1; ".$sudo."$binpath $confdir$value > /dev/null 2>&1 &";
my $status; my $status;
my $fh; my $fh;
@ -738,13 +740,20 @@ sub Hyperion_Attr(@)
$err = "Invalid value $attr_value for attribute $attr_name. Must be a number between 0 and 65536."; $err = "Invalid value $attr_value for attribute $attr_name. Must be a number between 0 and 65536.";
} }
} }
elsif ($attr_name eq "hyperionDimStep" || $attr_name eq "hyperionSatStep") elsif ($attr_name eq "hyperionDimStep")
{ {
if ($attr_value !~ /^(\d+)$/ || $1 < 1 || $1 > 50) if ($attr_value !~ /^(\d+)$/ || $1 < 1 || $1 > 50)
{ {
$err = "Invalid value $attr_value for attribute $attr_name. Must be between 1 and 50 in steps of 1, default is 5."; $err = "Invalid value $attr_value for attribute $attr_name. Must be between 1 and 50 in steps of 1, default is 5.";
} }
} }
elsif ($attr_name eq "hyperionNoSudo")
{
if ($attr_value !~ /^1$/)
{
$err = "Invalid value $attr_value for attribute $attr_name. Can only be value 1.";
}
}
elsif ($attr_name eq "hyperionSshUser") elsif ($attr_name eq "hyperionSshUser")
{ {
if ($attr_value !~ /^\w+$/) if ($attr_value !~ /^\w+$/)
@ -975,6 +984,10 @@ sub Hyperion_devStateIcon($;$)
<i>hyperionDefaultDuration</i><br> <i>hyperionDefaultDuration</i><br>
default duration, if not set it's infinity default duration, if not set it's infinity
</li> </li>
<li>
<i>hyperionNoSudo</i><br>
disable sudo for non-root users
</li>
<li> <li>
<i>hyperionDefaultPriority</i><br> <i>hyperionDefaultPriority</i><br>
default priority, if not set it's 0 default priority, if not set it's 0