Hauptmenü

State auf zwei Readings

Begonnen von TomekWaw, 17 August 2019, 19:32:57

Vorheriges Thema - Nächstes Thema

TomekWaw

Hallo,
Sorry for no speaking German good enought.
I have a z-wave swtich that reports "scene_26: 0" on single button press and "scene_24: 0" on double press:

2019-08-17 19:21:03 ZWave Fibaro_Dimmer_1 scene_26: 0
[...]
2019-08-17 19:21:06 ZWave Fibaro_Dimmer_1 scene_24: 0


I publish all state changes to MQTT broker, but as this includes always 0, its pretty useless so far.
I tried to create my own reading:

attr Fibaro_Dimmer_1 userReadings clicks:scene_26.*0 {"1"}

and this works fine, but when I add second command like this for scene_24, only last gets saved.
Then I've tried this:

attr Fibaro_Dimmer_1 userReadings clicks { if (ReadingsVal($name,"scene_26","") eq "0") {"1"} elsif (ReadingsVal($name,"scene_24","") eq "0") {"2"} else {"0"} }

but I always get clicks: 1

My intend is to get a new Fibaro_Dimmer_1 reading "clicks", that will get value of:
- "1" on single button press (occurance of "scene_26: 0")
- "2" on double button press (occurance of "scene_26: 0")

What would be the proper way to code it in?


rudolfkoenig

ReadingsVal returns the value of the current Reading (i.e. the "stored event", what you see in list).

Try the following:attr Fibaro_Dimmer_1 userReadings clicks:scene_26.* { 1 }, clicks:scene_24.* { 2 }

TomekWaw

rudolfkoenig, thank you very much!
Works like a charm!