FHEM Forum

FHEM => English Corner => Thema gestartet von: VVlasy am 22 März 2015, 01:21:22

Titel: notify if trigger count number is odd/even
Beitrag von: VVlasy am 22 März 2015, 01:21:22
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
Titel: Antw:notify if trigger count number is odd/even
Beitrag von: rudolfkoenig am 22 März 2015, 09:41:08
$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)
Titel: Antw:notify if trigger count number is odd/even
Beitrag von: VVlasy am 22 März 2015, 10:23:41
Oh snap, it worked like a charm.

I googled the code for even numbers.

Thanks alot kind sir!
Titel: Antw:notify if trigger count number is odd/even
Beitrag von: Icinger am 22 März 2015, 10:31:37
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