mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
01_FHEMWEB.pm: support ON/OFF for automatic toggling (Forum #94434)
git-svn-id: https://svn.fhem.de/fhem/trunk@17989 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e328888c5a
commit
60e389f3c4
@ -3071,11 +3071,11 @@ FW_devState($$@)
|
|||||||
my $state = $defs{$d}{STATE};
|
my $state = $defs{$d}{STATE};
|
||||||
$state = "" if(!defined($state));
|
$state = "" if(!defined($state));
|
||||||
|
|
||||||
$hasOnOff = ($allSets =~ m/(^| )on(:[^ ]*)?( |$)/ &&
|
|
||||||
$allSets =~ m/(^| )off(:[^ ]*)?( |$)/);
|
|
||||||
my $txt = $state;
|
my $txt = $state;
|
||||||
my $dsi = ($attr{$d} && ($attr{$d}{stateFormat} || $attr{$d}{devStateIcon}));
|
my $dsi = ($attr{$d} && ($attr{$d}{stateFormat} || $attr{$d}{devStateIcon}));
|
||||||
|
|
||||||
|
$hasOnOff = ($allSets =~ m/(^| )on(:[^ ]*)?( |$)/i &&
|
||||||
|
$allSets =~ m/(^| )off(:[^ ]*)?( |$)/i);
|
||||||
if(AttrVal($d, "showtime", undef)) {
|
if(AttrVal($d, "showtime", undef)) {
|
||||||
my $v = $defs{$d}{READINGS}{state}{TIME};
|
my $v = $defs{$d}{READINGS}{state}{TIME};
|
||||||
$txt = $v if(defined($v));
|
$txt = $v if(defined($v));
|
||||||
@ -3128,9 +3128,11 @@ FW_devState($$@)
|
|||||||
|
|
||||||
|
|
||||||
if($hasOnOff) {
|
if($hasOnOff) {
|
||||||
|
my $isUpperCase = ($allSets =~ m/(^| )ON(:[^ ]*)?( |$)/ &&
|
||||||
|
$allSets =~ m/(^| )OFF(:[^ ]*)?( |$)/);
|
||||||
# Have to cover: "on:An off:Aus", "A0:Aus AI:An Aus:off An:on"
|
# Have to cover: "on:An off:Aus", "A0:Aus AI:An Aus:off An:on"
|
||||||
my $on = ReplaceEventMap($d, "on", 1);
|
my $on = ReplaceEventMap($d, $isUpperCase ? "ON" :"on" , 1);
|
||||||
my $off = ReplaceEventMap($d, "off", 1);
|
my $off = ReplaceEventMap($d, $isUpperCase ? "OFF":"off", 1);
|
||||||
$link = "cmd.$d=set $d " . ($state eq $on ? $off : $on) if(!defined($link));
|
$link = "cmd.$d=set $d " . ($state eq $on ? $off : $on) if(!defined($link));
|
||||||
$cmdList = "$on:$off" if(!$cmdList);
|
$cmdList = "$on:$off" if(!$cmdList);
|
||||||
|
|
||||||
|
@ -5,3 +5,7 @@ on-for-timer light_on-for-timer.svg
|
|||||||
off-for-timer light_off-for-timer.svg
|
off-for-timer light_off-for-timer.svg
|
||||||
dimup light_dim_up.svg
|
dimup light_dim_up.svg
|
||||||
dimdown light_dim_down.svg
|
dimdown light_dim_down.svg
|
||||||
|
set_on light_exclamation.svg
|
||||||
|
set_off light_exclamation.svg
|
||||||
|
set_ON light_exclamation.svg
|
||||||
|
set_OFF light_exclamation.svg
|
||||||
|
Loading…
Reference in New Issue
Block a user