attr readingsGroup_SB_PLAYER commands {\ [...],\ volumeStraight.-\d+ => "set %DEVICE mute", volumeStraight.\d+ => "set %DEVICE mute",\ [...]\ } | | | | | | | attr readingsGroup_SB_PLAYER valueIcon {\ [...],\ volumeStraight.-\d+ => 'im_volume-mute2@Orange', volumeStraight.\d+ => 'im_volume-medium@Green',\ [...]\ } |
defmod readingsGroup_SB_PLAYER readingsGroup <Status>,<Squeezebox/Lautstärke>,<An/Mute>,<Stopp/zurück>,<Pause/vor>,<Album>,<Sender-Playlist/Wecker>,<Künstler/Stück>\
SB_PLAYER_.*:?icon,?alias,state,playStatus,<{"%fa_pause\@Gainsboro%set+$DEVICE+pause"}>,uR_coverarturl,currentPlaylistName,currentArtist,<br>,presence,volume,<{if(ReadingsVal($DEVICE,'volumeStraight','')<0){"%im_volume-mute2\@Orange%set+$DEVICE+mute"}else{"%im_volume-medium\@Green%set+$DEVICE+mute"}}>,<{"%fa_fast_backward\@Gainsboro%set+$DEVICE+prev"}>,<{"%fa_fast_forward\@Gainsboro%set+$DEVICE+next"}>,currentAlbum,alarmsEnabled,currentTitle,<hr>
attr readingsGroup_SB_PLAYER alias Squeezeboxen
attr readingsGroup_SB_PLAYER cellStyle {\
"c:6" => 'style="text-align:center"'\
}
attr readingsGroup_SB_PLAYER commands {\
'state.on' => "set %DEVICE off", 'state.off' => "set %DEVICE on",\
'playStatus.playing' => "set %DEVICE stop", 'playStatus.paused' => "set %DEVICE play", 'playStatus.stopped' => "set %DEVICE play",\
'volume' => "volume:slider,0,1,100",\
'alarmsEnabled.on' => "set %DEVICE alarmsEnabled-off", 'alarmsEnabled.off' => "set %DEVICE alarmsEnabled-on"\
}
attr readingsGroup_SB_PLAYER group Squeezebox
attr readingsGroup_SB_PLAYER headerRows 1
attr readingsGroup_SB_PLAYER nonames 1
attr readingsGroup_SB_PLAYER room Multimedia
attr readingsGroup_SB_PLAYER sortDevices 1
attr readingsGroup_SB_PLAYER valueIcon {\
'icon' => $VALUE,\
'state.on' => 'fa__485@Green', 'state.off' => 'fa__484@Orange',\
'playStatus.playing' => 'fa_play@Green', 'playStatus.paused' => 'fa_pause@Orange', 'playStatus.stopped' => 'fa_stop@Darksalmon',\
'uR_coverarturl' => "<div align=\"center\"><img src=$VALUE></div>",\
'presence.present' => 'fa__303@Green', 'presence.absent' => 'fa__303@Red',\
'alarmsEnabled.on' => 'fa_bell_alt@Green', 'alarmsEnabled.off' => 'fa__471@Orange'\
}
defmod SB_PLAYER_0004202b459d SB_PLAYER 00:04:20:2b:45:9d
attr SB_PLAYER_0004202b459d DbLogInclude signalstrength,presence
attr SB_PLAYER_0004202b459d IODev XX_XX_XX_SqueezeBoxServer
attr SB_PLAYER_0004202b459d alias Squeezebox Arbeitszimmer (Radio schwarz)
attr SB_PLAYER_0004202b459d amplifier play
attr SB_PLAYER_0004202b459d cmdIcon mute:im_volume-mute2@Gainsboro pause:fa_pause@Gainsboro next:fa_fast_forward@Gainsboro prev:fa_fast_backward@Gainsboro
attr SB_PLAYER_0004202b459d coverartheight 100
attr SB_PLAYER_0004202b459d coverartwidth 100
attr SB_PLAYER_0004202b459d devStateIcon 1.present:fa__303@Green 1.absent:fa__303@Red\
2.on:fa__485@Green:off 2.off:fa__484@Orange:on\
3.playing:fa_play@Green:stop 3.paused:fa_pause@Orange:play 3.stopped:fa_stop@Darksalmon:play\
4.-\d+:im_volume-mute2@Orange:mute 4.\d+:im_volume-medium@Green:mute\
5.on:fa_bell_alt@Green:alarmsEnabled-off 5.off:fa__471@Orange:alarmsEnabled-on
attr SB_PLAYER_0004202b459d do_not_notify 0
attr SB_PLAYER_0004202b459d donotnotify false
attr SB_PLAYER_0004202b459d event-on-change-reading alarmsEnabled,uR_coverarturl,currentPlaylistName,currentArtist,currentAlbum,currentTitle,playStatus,presence,signalstrength,state,volume,volumeStraight
attr SB_PLAYER_0004202b459d eventMap /alarmsEnabled on:alarmsEnabled-on/alarmsEnabled off:alarmsEnabled-off/
attr SB_PLAYER_0004202b459d fadeinsecs 1
attr SB_PLAYER_0004202b459d group Squeezebox
attr SB_PLAYER_0004202b459d icon TR_Logitech_Squeezebox_Radio_schwarz
attr SB_PLAYER_0004202b459d room Multimedia
attr SB_PLAYER_0004202b459d stateFormat 1:presence\
;\
2:state\
;\
3:playStatus\
;\
4:volumeStraight\
;\
5:alarmsEnabled
attr SB_PLAYER_0004202b459d statusRequestInterval 1
attr SB_PLAYER_0004202b459d ttslanguage de
attr SB_PLAYER_0004202b459d ttslink http://translate.google.com/translate_tts?ie=UTF-8&tl=<LANG>&q=<TEXT>&client=tw-ob
attr SB_PLAYER_0004202b459d userReadings uR_coverarturl {\
(my $coverarturl = ReadingsVal($NAME, 'coverarturl', '')) =~ s/&x=\d+//;;\
return $coverarturl;;\
}
attr SB_PLAYER_0004202b459d volumeLimit 100
attr SB_PLAYER_0004202b459d volumeStep 1
attr SB_PLAYER_0004202b459d webCmd volume:pause:prev:next
setstate SB_PLAYER_0004202b459d 1:present\
;\
2:on\
;\
3:playing\
;\
4:16\
;\
5:off
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 alarmsDefaultVolume 50
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 alarmsEnabled off
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 alarmsFadeIn on
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 alarmsFadeSeconds 20
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 alarmsSnooze 9
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 alarmsTimeout 60
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 connected 1
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 coverarturl http://LXC-logitechmediaserver:9000/music/current/cover_100x100.jpg?player=00:04:20:2b:45:9d&x=85099
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 currentAlbum Arrival
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:30 currentArtist ABBA
setstate SB_PLAYER_0004202b459d 2020-07-15 14:50:12 currentMedia file:///media/Multimedia/Audio/Alben/ABBA/1973-1981%C2%B7ABBA%C2%B7The%20Albums%C2%B7Ring%20Ring%C2%B7Waterloo%C2%B7ABBA%C2%B7Arrival%C2%B7The%20Album%C2%B7Voulez-Vous%C2%B7Super%20Trouper%C2%B7The%20Visitors/403%C2%B7ABBA%C2%B7Arrival%C2%B7My%20Love,%20My%20Life.mp3
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 currentPlaylistName -
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 currentPlaylistUrl
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 currentTitle My Love, My Life
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 currentTrackPosition 129
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 duration 234
setstate SB_PLAYER_0004202b459d 2020-07-14 12:46:27 favorites -
setstate SB_PLAYER_0004202b459d 2020-07-15 09:48:30 lastir ?
setstate SB_PLAYER_0004202b459d 2020-07-15 14:10:24 lastunknowncmd displaynotify showbriefly HASH(0x55688a97f4f8) HASH(0x55688a8ea7a8)
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 playStatus playing
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 playlistCurrentTrack 14
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 playlistTracks 100
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 playlists -
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 power on
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 presence present
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 repeat off
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 shuffle off
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 signalstrength 100
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 state on
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 synced none
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 uR_coverarturl http://LXC-logitechmediaserver:9000/music/current/cover_100x100.jpg?player=00:04:20:2b:45:9d
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 volume 16
setstate SB_PLAYER_0004202b459d 2020-07-15 14:52:31 volumeStraight 16
Zitat von: GaiusMarius am 15 Juli 2020, 15:03:00Ist hier überhaupt eine Wildcard möglich? Lässt sich eine andere Lösung finden?Ja, natürlich, guckst du einfach
Zitat von: justme1968 am 21 Oktober 2016, 14:35:10..., '' => '{...}', ...
zwischen die {} dann etwas perl code in der art:
$VALUE eq "0" ? "batterie" : "batterie\@red"
defmod readingsGroup_SB_PLAYER readingsGroup <Status>,<Squeezebox/Lautstärke>,<An/Mute>,<Stopp/zurück>,<Pause/vor>,<Album>,<Sender-Playlist/Wecker>,<Künstler/Stück>\
SB_PLAYER_.*:?icon,?alias,state,playStatus,<{"%fa_pause\@Gainsboro%set+$DEVICE+pause"}>,coverarturl,currentPlaylistName,currentArtist,<br>,presence,volume,volumeStraight,<{"%fa_fast_backward\@Gainsboro%set+$DEVICE+prev"}>,<{"%fa_fast_forward\@Gainsboro%set+$DEVICE+next"}>,currentAlbum,alarmsEnabled,currentTitle,<hr>
attr readingsGroup_SB_PLAYER alias Squeezeboxen
attr readingsGroup_SB_PLAYER cellStyle {\
"c:6" => 'style="text-align:center"'\
}
attr readingsGroup_SB_PLAYER commands {\
'state.on' => "set %DEVICE off", 'state.off' => "set %DEVICE on",\
'playStatus.playing' => "set %DEVICE stop", 'playStatus.paused' => "set %DEVICE play", 'playStatus.stopped' => "set %DEVICE play",\
'volume' => "volume:slider,0,1,100",\
'volumeStraight' => "set %DEVICE mute",\
'alarmsEnabled.on' => "set %DEVICE alarmsEnabled-off", 'alarmsEnabled.off' => "set %DEVICE alarmsEnabled-on"\
}
attr readingsGroup_SB_PLAYER group Squeezebox
attr readingsGroup_SB_PLAYER headerRows 1
attr readingsGroup_SB_PLAYER nonames 1
attr readingsGroup_SB_PLAYER room Multimedia
attr readingsGroup_SB_PLAYER sortDevices 1
attr readingsGroup_SB_PLAYER valueIcon {\
'icon' => $VALUE,\
'state.on' => 'fa__485@Green', 'state.off' => 'fa__484@Orange',\
'playStatus.playing' => 'fa_play@Green', 'playStatus.paused' => 'fa_pause@Orange', 'playStatus.stopped' => 'fa_stop@Darksalmon',\
'coverarturl' => "<div align=\"center\"><img src=%VALUE></div>",\
'presence.present' => 'fa__303@Green', 'presence.absent' => 'fa__303@Red',\
'volumeStraight' => '{($VALUE lt "0") ? "im_volume-mute2\@Orange" : "im_volume-mute2\@Green"}',\
'alarmsEnabled.on' => 'fa_bell_alt@Green', 'alarmsEnabled.off' => 'fa__471@Orange'\
}
War doch gar nicht schwierig, oder? :Pdefine Lampenzustand readingsGroup hueBridge_HUEDevice3:rgb,onoff hueBridge_HUEDevice5:rgb hueBridge_HUEDevice6:rgb hueBridge_HUEDevice2:rgb
attr Lampenzustand noheading 0
attr Lampenzustand nonames 1
attr Lampenzustand notime 1
attr Lampenzustand valueIcon {'onoff.1' => 'colorbutton@#'.ReadingsVal($DEVICE,"rgb",""), 'onoff.0' => 'colorbutton@#808080'}
unddefine Lampenzustand readingsGroup hueBridge_HUEDevice3:rgb,onoff hueBridge_HUEDevice5:rgb,onoff
attr Lampenzustand noheading 0
attr Lampenzustand nonames 1
attr Lampenzustand notime 1
attr Lampenzustand valueFormat { if ($READING eq 'rgb' && ReadingsVal($DEVICE, "onoff", "0") eq '1') {"colorbutton@#".ReadingsVal($DEVICE, "rgb", "ffffff")}else{"colorbutton@#808080"} }
attr Lampenzustand valueIcon %VALUE
als auch über eine Subroutine in myUtils mit der RGdefine Lampenzustand readingsGroup hueBridge_HUEDevice3:<{myUtils_lampeneinaus($DEVICE)}>,rgb,onoff hueBridge_HUEDevice5:{myUtils_lampeneinaus($DEVICE)} hueBridge_HUEDevice6:{myUtils_lampeneinaus($DEVICE)}
und der Subroutinesub
myUtils_lampeneinaus($)
{
my($DEVICE) = @_;
my $icon;
my $link;
if (ReadingsVal($DEVICE,"onoff","" ) eq '0') {
$icon = "colorbutton_off@#808080";
$link = fhem("set $DEVICE off");
}
elsif (ReadingsVal($DEVICE,"onoff","" ) eq '1') {
$icon = "colorbutton@#".ReadingsVal($DEVICE,"rgb","" );
$link = fhem("set $DEVICE on");
}
my $ret = "%$icon";
$ret .= "%$link" if( $link );
return $ret;
}
attr hueBridge_HUEDevice3 event-on-change-reading zustand
attr hueBridge_HUEDevice3 event-on-update-reading zustand
attr hueBridge_HUEDevice3 userReadings zustand {ReadingsVal($name,'rgb','FFFFFF').','.ReadingsVal($name,'onoff','1')}
Die RG-Definition:define Lampenzustand readingsGroup hueBridge_HUEDevice3:zustand ...
attr Lampenzustand commands {'zustand' => '{if ($DEVICE eq "hueBridge_HUEDevice3") {"set hueBridge_HUEGroup3 toggle"}elsif(...){...}}'}
attr Lampenzustand noheading 1
attr Lampenzustand nonames 1
attr Lampenzustand notime 1
attr Lampenzustand valueIcon {'zustand' => '{ HUEvalueFormat($DEVICE,$READING,$VALUE)}'}
Und noch die Subroutine für das Icon:sub
HUEvalueFormat($$$)
{
my ($DEVICE,$READING,$VALUE) = @_;
if( ReadingsVal($DEVICE, "zustand", "") =~ qr/(......),(0|1)/p) {
my $farbe = $1;
my $einaus = $2;
if( $einaus eq '0') {
return 'colorbutton_off@#808080';
}
else {
return 'colorbutton@#'.$farbe;
}
}
}
Danke an alle Forenteilnehmer für ihre Beiträge; mithilfe der Code-Schnipsel konnte ich die Perl-Logik allmählich nachvollziehen :)