notify if trigger count number is odd/even

Begonnen von VVlasy, 22 März 2015, 01:21:22

Vorheriges Thema - Nächstes Thema

VVlasy

Well, basically I need a notify that sets a dummy device when number is odd/even. Odd number means that channel is actuated. Even number means it has been released

Event monitor:
2015-03-22 01:17:01 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 toggle (to broadcast)
2015-03-22 01:17:01 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 trigger_cnt: 127
2015-03-22 01:17:01 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 toggle (to broadcast)
2015-03-22 01:17:01 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 trigger: Short_127
2015-03-22 01:17:02 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D battery: ok
2015-03-22 01:17:02 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 toggle (to broadcast)
2015-03-22 01:17:02 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 trigger_cnt: 128
2015-03-22 01:17:02 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 toggle (to broadcast)
2015-03-22 01:17:02 CUL_HM CUL_HM_HM_SWI_3_FM_2F332D_Sw_01 trigger: Short_128


Notify code I tried but does not work:

define alarm_locked notify CUL_HM_HM_SWI_3_FM_2F332D_Sw_01:trigger.$is_odd set alarm on

rudolfkoenig

$is_odd in a regexp is not doing what it implies, you should use \d*[13579] instead.
You also have to take care of space, the complete regexp should be
CUL_HM_HM_SWI_3_FM_2F332D_Sw_01:trigger_cnt:.\d+[13579]
(untested)

VVlasy

#2
Oh snap, it worked like a charm.

I googled the code for even numbers.

Thanks alot kind sir!

Icinger

#3
Is it realy necessary to use a Dummy? Or is it enough, if you have a UserReading with 0 or 1 in ist?

attr CUL_HM CUL_HM_HM_SWI_3_FM_2F332D userReadings OnOff {ReadingsVal("CUL_HM CUL_HM_HM_SWI_3_FM_2F332D","trigger_cnt",0) % 2 ? "1" : "0"}

Cheers, Ici
Verwende deine Zeit nicht mit Erklärungen. Die Menschen hören (lesen) nur, was sie hören (lesen) wollen. (c) Paulo Coelho