This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

MQTT Client app
#7
UPD: i moved all my rules to the new application (54 total) Smile hope it won't break anything :-D

so regarding throttle, the following approach seems to be working, with the knowledge that i should use unique names per each script

"In" event:
Code:
ls_bedroom_throttle = ls_bedroom_throttle or require('user.mqttclient_common').throttle(60)

local data = json.pdecode(payload)
if type(data) == 'table' then
  return ls_bedroom_throttle(data.illuminance)
end

user library:
Code:
return {
  throttle = function(timeout)
    local last_update = 0
    return function(val)
      if(val ~= nil) then
        local now = os.time()
        if((now - last_update) < timeout) then
          return nil
        else
          last_update = now
          return val
        end
      end
    end
  end
}

SUGGESTION: 
1) in error log make it obvious which script contains error, so i can fix it easily. For example this error does not have information where to look:
Quote:error: failed to run script - [string "in-26"]:9: attempt to compare nil with number
2) output errors in global error log so they can be noticed in time
Reply


Messages In This Thread
MQTT Client app - by Daniel - 10.09.2024, 14:12
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 08:58
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 09:50
RE: MQTT Client app - Beta testing - by admin - 23.09.2024, 10:04
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 10:41
RE: MQTT Client app - Beta testing - by myg - 23.09.2024, 12:50
RE: MQTT Client app - Beta testing - by myg - 01.10.2024, 09:37
RE: MQTT Client app - Beta testing - by admin - 01.10.2024, 12:53
RE: MQTT Client app - Beta testing - by myg - 01.10.2024, 13:11
RE: MQTT Client app - Beta testing - by cekca - 02.10.2024, 08:18
RE: MQTT Client app - Beta testing - by admin - 02.10.2024, 08:18
RE: MQTT Client app - Beta testing - by cekca - 02.10.2024, 08:29
RE: MQTT Client app - Beta testing - by admin - 02.10.2024, 08:40
RE: MQTT Client app - Beta testing - by AEK - 02.10.2024, 08:48
RE: MQTT Client app - Beta testing - by admin - 02.10.2024, 09:19
RE: MQTT Client app - Beta testing - by cekca - 02.10.2024, 12:58
RE: MQTT Client app - Beta testing - by admin - 02.10.2024, 13:00
RE: MQTT Client app - Beta testing - by cekca - 02.10.2024, 13:07
RE: MQTT Client app - Beta testing - by admin - 02.10.2024, 13:08
RE: MQTT Client app - Beta testing - by cekca - 02.10.2024, 13:11
RE: MQTT Client app - Beta testing - by admin - 02.10.2024, 13:37
RE: MQTT Client app - Beta testing - by admin - 11.10.2024, 10:52
RE: MQTT Client app - Beta testing - by myg - 14.10.2024, 08:05
RE: MQTT Client app - by admin - 16.10.2024, 07:46
RE: MQTT Client app - by myg - 17.10.2024, 12:13
RE: MQTT Client app - by admin - 17.10.2024, 12:36
RE: MQTT Client app - by Snoolik - 06.11.2024, 15:10

Forum Jump: