FHEM Forum

FHEM => Automatisierung => DOIF => Thema gestartet von: Nestor am 25 November 2019, 19:41:24

Titel: Usage of Perl expression in attr wait
Beitrag von: Nestor am 25 November 2019, 19:41:24
I want to change the wait time for a DOIF during the weekend.
The following seems not be working:
(($we ? 18 : 16) * HOURSECONDS)

What is valid syntax to use?
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: amenomade am 25 November 2019, 20:06:10
I would try with:
{($we ? 18 : 16) * HOURSECONDS}
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: Nestor am 26 November 2019, 09:10:45
Makes sense. :-)
The example in the DOIF#wait command ref (http://fhem.lan/fhem/docs/commandref_DE.html#DOIF_wait) is kind of confusing, since no curly braces are used for Perl expressions.

attr my_doif wait 1:[mydummy:state]*3:rand(600)+100,Attr("mydevice","myattr","")

Maybe this could be clarified?
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: Nestor am 26 November 2019, 11:03:26
Zitat von: amenomade am 25 November 2019, 20:06:10
{($we ? 18 : 16) * HOURSECONDS}

Update: this does not work.
I suppose the code needs to put in a function because Perl expressions are not accepted in attr wait if I understand command ref correctly.
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: amenomade am 26 November 2019, 11:18:56
Zitat von: Nestor am 26 November 2019, 11:03:26
Update: this does not work.
I suppose the code needs to put in a function because Perl expressions are not accepted in attr wait if I understand command ref correctly.
I'm afraid you're right. That would have been my second proposition.
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: Damian am 26 November 2019, 13:22:41
(($we ? 18 : 16) * HOURSECONDS)

Syntax is ok, but $we is unknown at wait
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: Nestor am 26 November 2019, 13:24:27
Would IsWe() work?
Titel: Antw:Usage of Perl expression in attr wait
Beitrag von: Damian am 26 November 2019, 13:36:38
Zitat von: Nestor am 26 November 2019, 13:24:27
Would IsWe() work?
try out