Request for getting attributes with square bracket syntax

Begonnen von Nestor, 03 April 2019, 11:12:22

Vorheriges Thema - Nächstes Thema

Nestor

Would it be possible to implement the set magic syntax [a:<device>:<attribute>]?
I'm now using Perl syntax {(AttrVal($DEVICE, $ATTRIBUTE, $DEFAULT))} which gets verbose quickly.

For example:
([Aqicn_Brussels:APL] ne 'Good' or [Aqicn_Brussels:APL] ne 'Moderate')
(set Pu_Al msg title="Outside air is [Aqicn_Brussels:APL]" device="{(AttrVal('Pu_Lr', 'keyLr', ''))}:" "More info at {(AttrVal('Aqicn_Brussels', 'web_url', '?'))}")
DOELSE
(set Pu_Lr msg title="Outside air is [Aqicn_Brussels:APL] again" 
{('It was '.OldReadingsVal('Aqicn_Brussels', 'APL', '?').' for '.Time::Ago->in_words(OldReadingsAge('Aqicn_Brussels', 'APL', 0)))})


Second question:
is it correct that $DEVICE is only available when using [<devicename>:"<regex>"] syntax (evaluation of events) and not evaluation of reading like [<devicename>:<reading>]
In the previous example when trying to get $DEVICE or {($device)}, it appears to be unset, I would expect string: Aqicn_Brussels

Damian

You can use $DEVICE anywhere in the condition or in execution part.

$device is a perl variable. $device you can use only in condition.

Attributes in square brackets were discarded because they do not trigger.

It is not worth developing your own syntax.
Programmierte FHEM-Module: DOIF-FHEM, DOIF-Perl, DOIF-uiTable, THRESHOLD, FHEM-Befehl: IF

Nestor

Thanks for looking into it.
$DEVICE works now, I tested with set <DOIF-modul> cmd_<nr> and then $DEVICE is not set.

Damian

Zitat von: Nestor am 03 April 2019, 19:32:41
Thanks for looking into it.
$DEVICE works now, I tested with set <DOIF-modul> cmd_<nr> and then $DEVICE is not set.

yes, $DEVICE corresponds to the real triggering device
Programmierte FHEM-Module: DOIF-FHEM, DOIF-Perl, DOIF-uiTable, THRESHOLD, FHEM-Befehl: IF