Hallo,
ich habe ein notify. Ich benötige den Namen des Devices von dem ReadingsVal AVR_input_.*
avr:input:..* {
if (ReadingsVal("AVR_input_.*","input","") == $EVTPART1) {fhem ("set Telegram msg " .$NAME)}
}
Mit $NAME bekomme ich nur den Namen von avr. Wie bekomme ich den Namen von AVR_input_.* ?
Gruß
TWART016
ZitatReadingsVal("AVR_input_.*","input","")
Das kann nicht funktionieren: ReadingsVal benötigt einen existierenden Devicenamen kein devspec Ausruck.
Variablen die Du nutzen kannst sind $NAME und $EVENT bzw. EVTPARTx. Siehe: https://fhem.de/commandref.html#notify
Schade. Wie bekomme ich dann den Namen des Devices. Ich hole vielleicht noch ein wenig aus.
Wenn ich per Fernbedienung den Input an meinem AV ändere, bekommt das Modul das mit. Leider ist die Zuordnung der Eingänge in einem Reading von einem dummy hinterlegt. Dazu gibt es für jeden Input ein dummy AVR_input_.* . In jedem der dummies gibt es das Reading input mit einem Wert z.B. "video6" oder "12".
In der IF Abfrage möchte ich abprüfen, in welchem Device das Reading mit dem Wert video6 ist, und dieses Gerät auf On/off schalten. Wie bekomme ich das heraus?
Hallo,
Mit was für einem Modul arbeitest Du? Bei meinem Yamaha_AVR gibt es ein Reading input und das kann ich einfach auswerten. Ich kann mir das mit dem dummy im Moment noch nicht so richtig vorstellen.
Gruß Rolf
Ich habe nicht wirklich verstanden was Du machen möchtest. Wenn die benötigten Informationen in keinem Event auftauchen, dann kannst Du in einer Schleife (foreach) alle infrage kommenden Devices (devspec2array) abfragen (ReadingsVal)...
Ich nutze das Onkyo Modul. Problem die Zuordnung ist dort nicht richtig. TV ist nicht TV sondern "12".
Ich habe 6 dummies mit jeweils einen Reading state und input:
AVR_input_Computer:
state: on/off
input: video6
AVR_input_TV:
state: on/off
input: 12
usw.
Wenn jetzt avr:input geschalten werde, bekomme ich im notify mit EVTPART den Eingang heraus (z.B. 12). Jetzt möchte ich Namen des Gerätes (AVR_input_.*) haben, der im Reading input: 12 haben, in dem Fall TV
Wäre da devspec2array das richtige?
Wenn 12 kommt dann möchtest Du die Textkette AVR_input_TV erzeugen?
Ein list des Devices wäre wohl hilfreich. Wusste schon in der Nacht nicht was der Fragesteller eigentlich will.
Hier ein list
ein dummy:
Internals:
NAME AVR_input_Fernseher
NR 767
STATE on
TYPE dummy
READINGS:
2017-12-27 00:46:01 input 12
2018-03-28 23:00:07 state on
Attributes:
alexaName input Fernseher
genericDeviceType switch
homebridgeMapping On=state,valueOn=/on/,valueOff=/off/,cmdOn=on,cmdOff=off
room Homekit,alexa
siriName input Fernseher
webCmd on:off
avr:
Internals:
CHANGED
CHANNEL 00
Clients :ONKYO_AVR_ZONE:
DEF 192.168.178.22
DeviceName 192.168.178.22:60128
FD 67
INPUT 12
NAME avr
NR 234
NTFY_ORDER 50-avr
PARTIAL
PROTOCOLVERSION 2013
SCREENLAYER 1
STATE opened
TIMEOUT 3
TYPE ONKYO_AVR
ZONE 1
READINGS:
2017-05-20 17:48:49 _NLU 00000000
2017-03-06 16:49:21 _PRZ 00
2017-06-17 15:25:57 _SLZ 2B
2017-03-06 16:49:21 _TUZ 08750
2017-03-18 14:19:41 _ZMT 00
2017-06-17 15:21:25 _ZPW 01
2017-06-17 15:32:23 _ZVL 17
2018-03-10 22:49:26 audin_ch 2
2018-03-10 22:49:26 audin_enc PCM
2018-03-10 22:49:26 audin_srate 2
2018-03-10 22:49:26 audin_src HDMI 4
2018-01-26 17:01:31 audout_ch 2
2018-01-26 17:01:31 audout_mode All Ch Stereo
2017-03-04 13:01:32 center-temporary-level -4
2018-03-29 00:12:20 channel DLNA
2017-03-03 21:18:15 channelList AUPEO!_PERSONAL_RADIO,DLNA,Home_Media,Last.fm_Internet_Radio,MP3tunes,Mediafly,My_Favorites,Napster,Pandora_Internet_Radio,Rhapsody,SiriusXM_Internet_Radio,Slacker_Personal_Radio,Spotify,TuneIn,e-onkyo_music,radiko.jp,simfy,vTuner
2017-03-04 21:59:15 cinema-filter off
2018-03-29 01:09:57 currentAlbum Unkown Album
2017-03-18 14:01:57 currentAlbumArtURI ./FHEM/lib/UPnP/sonos_empty.jpg
2017-03-18 14:01:57 currentAlbumArtURL ?/ONKYO_AVR/cover/empty.jpg
2018-03-29 01:09:57 currentArtist [no artist]
2018-03-29 00:44:20 currentTitle
2018-03-29 01:09:58 currentTrackDuration --:--:--
2018-03-29 01:12:19 currentTrackPosition 00:02:22
2017-03-04 21:59:15 dimmer-level dim
2018-03-29 13:36:38 input 12
2017-03-03 21:18:15 inputList 1
2018-02-24 10:17:04 listening-mode all-ch-stereo
2017-06-17 16:42:11 music-optimizer on
2018-03-22 09:46:26 mute off
2017-03-04 12:35:04 network-standby on
2017-03-04 12:35:05 phase-matching-bass off
2018-03-29 01:09:57 playStatus playing
2018-03-29 13:36:36 power on
2018-03-18 00:18:00 presence present
2017-03-06 16:49:21 preset
2017-04-17 20:18:42 repeat -
2018-03-28 00:24:39 screenCurser -
2018-03-29 13:36:37 screenIconLeft FF
2018-03-22 07:27:10 screenIconRight 00
2018-03-17 08:11:47 screenItemC0000 Kein Server
2017-12-16 01:45:59 screenItemC0001 Pandora
2017-12-14 22:39:47 screenItemC0002 Spotify
2017-12-14 22:39:37 screenItemC0003 Deezer
2017-03-18 14:03:30 screenItemC0004 AirPlay
2017-12-14 22:39:09 screenItemC0005 DLNA
2017-12-14 22:39:09 screenItemC0006 Home Media
2017-03-18 14:01:58 screenItemC0007 USB(R)
2017-03-18 14:01:58 screenItemC0008 My Favorites
2018-03-29 13:36:37 screenItemCnt 0001
2017-12-14 22:38:37 screenLayer 00
2018-03-29 13:36:37 screenLayerInfo 1
2018-03-29 13:36:37 screenListPos 0000
2017-03-18 14:01:57 screenStatus
2018-03-29 13:36:37 screenTitle DLNA
2018-03-29 13:36:37 screenType 0
2017-04-17 20:18:42 shuffle -
2017-03-03 21:18:14 sleep off
2018-03-18 00:18:00 state opened
2018-03-29 13:36:36 stateAV on
2017-09-23 17:52:10 subwoofer-temporary-level 10
2017-03-18 14:15:45 tone-front-bass 0
2017-03-18 14:15:44 tone-front-treble 0
2017-03-06 16:49:21 tunerFrequency 08750
2017-03-06 10:53:44 vidin_cdepth
2017-03-06 10:53:44 vidin_cspace
2017-03-06 10:53:44 vidin_res
2017-03-06 10:53:44 vidin_src
2017-03-06 10:53:44 vidout_cdepth
2017-03-06 10:53:44 vidout_cspace
2017-03-06 10:53:44 vidout_dst
2017-03-06 10:53:44 vidout_mode
2017-03-06 10:53:44 vidout_res
2018-03-29 00:12:19 volume 5
SCREEN:
0:
list:
0000:
curser 0
listpos 1
0003:
curser 0
data Deezer
listpos 0
property -
0007:
curser 0
data USB(R)
listpos 0
property -
0008:
curser 0
data My Favorites
listpos 0
property -
1:
list:
0000:
curser 0
data Kein Server
listpos 1
property -
2:
list:
0000:
curser 0
data Kein Server
listpos 1
property -
fhem:
infix ONKYO_AVR
helper:
nextConnectionCheck 1522323599.45127
receiver:
device:
netservicelist:
netservice:
00:
f3:
f4:
selectorlist:
zonelist:
zone:
1:
name Main
value 1
2:
input:
input_aliases:
input_names:
Attributes:
alexaName AV Receiver
inputs 1
model TX-NR646
room 01_Wohnzimmer
siriName AV Receiver
verbose 2
volumeSteps 2
webCmd volume:on:off
Würde ein Userreading erstellen und darin mit einer Hashliste arbeiten. Werden ja nicht so viele Input-Kanäle sein.
Internals:
CFGFN
NAME avr
NR 90
STATE connected
TYPE dummy
READINGS:
2018-03-29 14:13:38 input 12
2018-03-29 14:13:38 inputDevice TV
2018-03-29 14:07:42 state connected
Attributes:
readingList input
room Test
setList input:10,11,12,13
userReadings inputDevice:input:.* { my %list=( 10 => 'Walkman',11 => 'Phono',12 => 'TV'); $list{ReadingsVal($name,'input',0)} }
Es ist nicht die Lösung Deines Problems sondern der Weg dahin.
Das mit dem Userreading sieht gut aus.
Wenn wenn ich jedoch 2E als Input eingebe, bekomme ich im Reading den Fehler.
Error evaluating avr userReading input_custom: syntax error at (eval 7237142) line 1, near "2E"
Global symbol "%list" requires explicit package name (did you forget to declare "my %list"?) at (eval 7237142) line 1.
input_custom:input:.* {my %list=(12 => 'Fernseher', video6 => 'Computer', dvd => 'KODI', video2 => 'NUC', video3 => 'PlayStation', 2E => 'Bluetooth');$list{ReadingsVal($name,'input',0)} }
input_custom:input:.* {my %list=(12 => 'Fernseher', 'video6' => 'Computer', 'dvd' => 'KODI', 'video2' => 'NUC', 'video3' => 'PlayStation', '2E' => 'Bluetooth');$list{ReadingsVal($name,'input',0)} }
Das sieht schon mal gut aus. Wie kann ich das Reading auf [leer] oder einen beliebigen Text (undefiniert) definieren, wenn keiner der 6 Werte zutrifft?
Mit if Bedingung arbeiten
In dem Userreading bei input_custom:input?
input_custom:input:.* {my %list=(12 => 'Fernseher', 'video6' => 'Computer', 'dvd' => 'KODI', 'video2' => 'NUC', 'video3' => 'PlayStation', '2E' => 'Bluetooth'); if( defined($list{ReadingsVal($name,'input',0)}) { $list{ReadingsVal($name,'input',0)} else { 'none' } }
Ungetestet
Das gibt noch einen Fehler
Error evaluating avr userReading input_custom: syntax error at (eval 237897) line 9, near ") {"
Die Klammer von dem IF wird auch nicht zugemacht. Auch wenn ich die schließe, bekomme ich trotzdem den gleichen Fehler.
Hier nochmal der aktuelle Code
input_id_fernseher {AttrVal($name,"input_id_fernseher",0) ;;},
input_id_computer {AttrVal($name,"input_id_computer",0) ;;},
input_id_bluetooth {AttrVal($name,"input_id_bluetooth",0) ;;},
input_id_playstation {AttrVal($name,"input_id_playstation",0) ;;},
input_id_kodi {AttrVal($name,"input_id_kodi",0) ;;},
input_id_nuc {AttrVal($name,"input_id_nuc",0) ;;},
input_custom:input:.* {
my $input_fernseher=AttrVal($name,"input_id_fernseher","");
my $input_computer=AttrVal($name,"input_id_computer","");
my $input_bluetooth=AttrVal($name,"input_id_bluetooth","");
my $input_playstation=AttrVal($name,"input_id_playstation","");
my $input_kodi=AttrVal($name,"input_id_kodi","");
my $input_nuc=AttrVal($name,"input_id_nuc","");
fhem ("set Telegram msg" .$name);
my %list=($input_fernseher => 'Fernseher', $input_computer => 'Computer', $input_kodi => 'KODI', $input_nuc => 'NUC', $input_playstation => 'PlayStation', $input_bluetooth => 'Bluetooth');If( defined($list{ReadingsVal($name,'input',0)}) { $list{ReadingsVal($name,'input',0)} else { 'none' } }
},
Kleines i
if
Trotzdem noch der Fehler.
if( defined($list{ReadingsVal($name,'input',0)}) { $list{ReadingsVal($name,'input',0)} else { 'none' } })
Ich habe die Klammer am Ende geschlossen.
Die letzte Runde Klammer ist falsch
Auch ohne die Klammer kommt der Fehler.
Wenn ich mir die Syntax ansehe, wird die runde Klammer vom if nicht geschlossen.
input_custom:input:.* {my %list=(12 => 'Fernseher', 'video6' => 'Computer', 'dvd' => 'KODI', 'video2' => 'NUC', 'video3' => 'PlayStation', '2E' => 'Bluetooth'); if( defined($list{ReadingsVal($name,'input',0)})) { $list{ReadingsVal($name,'input',0)} else { 'none' } }
So sollte es gehen.
Danke, es hat zwar noch eine Klammer gefehlt, aber jetzt funktioniert alles.
if( defined($list{ReadingsVal($name,'input',0)})) { $list{ReadingsVal($name,'input',0)}} else { 'none' }