Results 1 to 3 of 3

Thread: "Debouncing" an Event Handler

  1. #1

    Question "Debouncing" an Event Handler

    I've gotten pretty far on a HA project using a cm15a, w800 for RF, and Girder. I've defined an event handler for the w800 as follows:

    -- Handles all the RF (w800) events

    function processRF(event, device)
    eventlength = string.len(event)
    rfHouseCode = string.sub(event,1,1)
    rfUnitCode = tonumber(string.sub(event,2,2))
    findcolon = string.find(event,":",1,1)
    rfAction = string.sub(event,findcolon+1,eventlength)
    mapRF(rfHouseCode,rfUnitCode,rfAction)
    end

    processRFCallbackID = gir.AddEventHandler(".*", 10001, 10001, processRF)

    The above is called on a w800 event (10001), and parses the house and unit codes. "mapRF" then does the following typical action:

    elseif rfHouseCode == "D" then -- handheld RF remote
    if rfUnitCode == 1 then
    if rfAction == "ON" then -- TURN ON TVROOM NORTH LAMP
    CM15A.Send("A",2,"ON")
    elseif rfAction == "OFF" then
    CM15A.Send("A",2,"OFF")
    end

    The unit (in this case a lamp) is missing a lot of x10 commands (I see 4 or 5 events from the w800 with this remote, very fast). I think there's too many back-to-back commands and the lamp is getting confused.

    I've been working on this for a couple of hours. What's the best way in the event handler to "debounce" the RF remote (i.e. call the mapRF function on the first event and disable events for, say 1/2 a second). It seems like I want a "disable event (or event handler" call, a timer, and a re-enable. What am I missing, and are there lua instructions to do this?

    Thanks in advance!!
    Chris

  2. #2
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    Hi Chris,

    I do not G4 in front of me but I thought we included an 'antirepeat' setting on the w800 config page.

    If not, I will show you another way around this problem...

  3. #3

    Default

    Well, Duh. I was so focused on my lua scripts I never even thought of the device manager. Took me a while to find it, I looked in the plugins (was actually under X10 devices).

    Thanks, this has fixed the problem!

    C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •