Hallo Zusammen,
ich weiß nicht ob mein Betreff richtig ist und ob das überhaupt verschachtelt ist, ich nenne es einfach mal so. Zunächst mal der Code, welcher so nicht funktioniert:
([dummy_timeprog_poll:state] > 0)
(set dim_trigger_starthour1 [dummy_[dummy_timeprog_poll:state]_start1:hour])
Was möchte ich tun? State von dummy_timeprogr_poll kann Zahlen annehmen. Diese Zahl soll dann wiederum die Bezeichnung von dummy_start1 angeben.
Beispiel:
In das State von dummy_timeprog_poll wird eine 1 geschrieben. In diesem Moment wird das DOIF ausgeführt und das Reading hour von dummy_1_start1 in den dim_trigger_starthour1 gesetzt. Wird eine 2 in dummy_timeprog_poll als State geschrieben, wird beim ausführen des DOIF dann dummy_2_start1 in den dim_trigger_starthour1 gesetzt. Usw. usw. Aber die Verschachtelung [dummy_[dummy_timeprog_poll:state]_start1:hour] funktioniert so nicht.
Gibt es hierfür eine Lösung, oder hat jemand eine Idee?
Danke
Tino
Du kannst dir den Device Name über Perl zusammen basteln
ReadingsVal("dummy_".ReadingsVal("dummy_timeprog_poll", "state", 0)."_start1", "hour", 0)
Nun muss du nur noch in der commandref nachlesen wie das im Ausführugsteil zu klammer ist, das weiß ich grad nicht.
Klammerfehler sollten im Logfile auftauchen.
Hallo igami,
ja ok das kenne ich und so geht es natürlich.
ReadingsVal("dummy_".ReadingsVal("dummy_timeprog_poll", "state", 0)."_start1", "hour", 0)
Mein Ziel wäre es direkt in DOIF ohne Perl und zusammenbasteln die Funktion zu haben. Aber scheinbar wird das nicht unterstützt oder eben so wie ich es denke falsch ist.
Puschel74, hier der Auszug aus dem Logfile sowie die weiteren gewünschten Infos.
2015.12.22 12:20:57 2: doif_dim_timeprogr_save: set dim_trigger_starthour1 [dummy_[dummy_timeprog_poll:state]_start1:hour]: no set value specified
Diese Meldung kommt auch als Error im DOIF:
Internals:
CFGFN
DEF ([dummy_timeprog_poll:state] > 0)
(set dim_trigger_starthour1 [dummy_[dummy_timeprog_poll:state]_start1:hour])
NAME doif_dim_timeprogr_save
NR 554
NTFY_ORDER 50-doif_dim_timeprogr_save
STATE cmd_1
TYPE DOIF
Readings:
2015-12-23 08:38:42 Device dummy_timeprog_poll
2015-12-23 08:38:43 cmd_event dummy_timeprog_poll
2015-12-23 08:38:43 cmd_nr 1
2015-12-23 08:38:42 e_dummy_timeprog_poll_state 1
2015-12-23 08:38:43 error set dim_trigger_starthour1 [dummy_[dummy_timeprog_poll:state]_start1:hour]: no set value specified
2015-12-23 08:38:43 state cmd_1
2015-12-23 08:38:43 wait_timer no timer
Condition:
0 ReadingValDoIf('dummy_timeprog_poll','state','') > 0
Devices:
0 dummy_timeprog_poll
all dummy_timeprog_poll
Do:
0:
0 set dim_trigger_starthour1 [dummy_[dummy_timeprog_poll:state]_start1:hour]
Helper:
globalinit 1
last_timer 0
sleepdevice dummy_timeprog_poll
sleepsubtimer -1
sleeptimer -1
Internals:
Itimer:
Readings:
0 dummy_timeprog_poll:state
all dummy_timeprog_poll:state
State:
Timerfunc:
Trigger:
Attributes:
do always
wait 1
List dummy_timeprog_poll
Internals:
CFGFN
NAME dummy_timeprog_poll
NR 536
STATE 1
TYPE dummy
Readings:
2015-12-23 08:38:42 state 1
List dim_trigger_starthour1
Internals:
CFGFN
CHANGED
DEF 0 5066
HeatPumpServer_MSGCNT 133449
HeatPumpServer_TIME 2015-12-23 08:42:13
IODev HeatPumpServer
LASTInputDev HeatPumpServer
MSGCNT 133449
ModbusRegister_lastRcv 2015-12-23 08:42:13
NAME dim_trigger_starthour1
NR 691
NTFY_ORDER 50-dim_trigger_starthour1
STATE 09
TYPE ModbusRegister
lastUpdate Wed Dec 23 08:42:13 2015
nextUpdate Wed Dec 23 08:42:13 2015
Readings:
2015-12-23 08:42:13 RAW 0009
2015-12-23 08:42:13 state 9
Helper:
addr 3 0 5066
address 5066
disableRegisterMapping 0
lastUpdate 1450860133.1353
nextUpdate 1450860133.63702
nread 1
readCmd �
register 5066
registerType 3
unitId 0
updateIntervall 0.1
Cnv:
a 1
b 0
max 32767
min -32768
step 100
Attributes:
IODev HeatPumpServer
alias Start Stunde 1
event-on-change-reading .*
group Trigger
plcDataType INT
registerType Holding
room Administration
sortby 01
stateFormat {if (ReadingsVal($name,'state',0) < 10) {'0'.ReadingsVal($name,'state',0)} else {ReadingsVal($name,'state',0)}}
List dummy_1_start1
Internals:
CFGFN
NAME dummy_1_start1
NR 484
STATE 09:01
TYPE dummy
Readings:
2015-12-22 18:57:19 hour 09
2015-12-22 18:57:19 minute 01
2015-12-22 18:57:19 state 09:01
Attributes:
alias Startzeit 1
event-on-change-reading .*
setList state:time
userReadings hour {(split ':',ReadingsVal($name,"state",0))[0]}, minute {(split ':',ReadingsVal($name,"state",0))[1]}
webCmd state
Versucht habe ich auch:
([dummy_timeprog_poll:state] > 0)
(set dim_trigger_starthour1 [[dummy_[dummy_timeprog_poll:state]_start1:hour]])
Was aber nur ein Versuch war und Unsinn ist.
Noch jemand eine Idee? Damian?
Danke
Tino
Zitat von: oniT am 23 Dezember 2015, 09:49:21
Versucht habe ich auch:
([dummy_timeprog_poll:state] > 0)
(set dim_trigger_starthour1 [[dummy_[dummy_timeprog_poll:state]_start1:hour]])
Was aber nur ein Versuch war und Unsinn ist.
Noch jemand eine Idee? Damian?
OK, weil es bald weihnachtet ;)
Ineinander geschachtelte Readings funktionieren nicht - ich habe dafür intern keine Iteration programmiert.
Das sollte funktionieren:
set dim_trigger_starthour1 {(ReadingsVal("dummy_[dummy_timeprog_poll]_start1", "hour", 0))}
Gruß
Damian
Zitat von: Damian am 23 Dezember 2015, 11:10:35
Das sollte funktionieren:
set dim_trigger_starthour1 {(ReadingsVal("dummy_[dummy_timeprog_poll]_start1", "hour", 0))}
Gruß
Damian
Ah, schade funktioniert leider auch nicht. :-\
Internals:
CFGFN
DEF ([dummy_timeprog_poll:state] > 0)
(set dim_trigger_starthour1 {(ReadingsVal("dummy_[dummy_timeprog_poll]_start1", "hour", 0))})
NAME doif_dim_timeprogr_save
NR 554
NTFY_ORDER 50-doif_dim_timeprogr_save
STATE cmd_1
TYPE DOIF
Readings:
2015-12-23 11:33:53 Device dummy_timeprog_poll
2015-12-23 11:33:54 cmd_event dummy_timeprog_poll
2015-12-23 11:33:54 cmd_nr 1
2015-12-23 11:33:53 e_dummy_timeprog_poll_state 1
2015-12-23 11:33:54 error no right bracket
2015-12-23 11:33:54 state cmd_1
2015-12-23 11:33:54 wait_timer no timer
Condition:
0 ReadingValDoIf('dummy_timeprog_poll','state','') > 0
Devices:
0 dummy_timeprog_poll
all dummy_timeprog_poll
Do:
0:
0 set dim_trigger_starthour1 {(ReadingsVal("dummy_[dummy_timeprog_poll]_start1", "hour", 0))}
Helper:
globalinit 1
last_timer 0
sleepdevice dummy_timeprog_poll
sleepsubtimer -1
sleeptimer -1
Internals:
Itimer:
Readings:
0 dummy_timeprog_poll:state
all dummy_timeprog_poll:state
State:
Timerfunc:
Trigger:
Attributes:
do always
loglevel 5
wait 1
Zitat von: Damian am 23 Dezember 2015, 11:10:35
OK, weil es bald weihnachtet ;)
Ineinander geschachtelte Readings funktionieren nicht - ich habe dafür intern keine Iteration programmiert.
Wenn wir aber einmal bei Weihnachten sind, wenn der Aufwand nicht zu groß ist wäre das ja mein Wunsch :)
Danke
Gruß
Tino
Was geht ist
{fhem("set dim_trigger_starthour1 ".ReadingsVal("dummy_[dummy_timeprog_poll]_start1", "hour", 0))}
Zitat von: oniT am 23 Dezember 2015, 12:39:33
Ah, schade funktioniert leider auch nicht. :-\
Wegen der Kommata musst du das ganze noch mal in Klammern packen:
((set dim_trigger_starthour1 {(ReadingsVal("dummy_[dummy_timeprog_poll]_start1", "hour", 0))}))
Ja, jetzt funktioniert es.
Danke
Gruß
Tino