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 - Beta testing
#2
Hi,

Very promising library, hides complexities of integration while allowing to focus on actual value conversion routines. I found one issue and one suggestion:

1) ISSUE: lack of scope isolation between scripts. If code will be reused by copy&paste, any issue where user failed to use "local" definition (variable or function) will cause to overwrite values between scripts, which can cause hard to debug issues. 
However, if fixed, i would like you to retain global scope within script, that is any defined global variable keeps its value between script executions. If not fixed, this should be explicitly mentioned in the documentation, and also suggestion that follows my post should be implemented Wink . 
One of the examples where it's beneficial having global variable retain its value is having Throttle function implementation like this:

Code:
local data = json.pdecode(payload)
if type(data) == 'table' then
  val = data.illuminance
 
  -- global variable here that should retain its value between executions
  last_update = last_update == nil and 0 or last_update
  ---
  local now = os.time()
  if((now - last_update) < 60) then
    return nil
  else
    last_update = now
    return val
  end
end


2) SUGGESTION: like in example above, i would like to have Throttle as a function that can be reused multiple times without having to copy-paste it. Right now with global scope creep this can be done indirectly, but it's a bad practice and also will depend on event execution order (event that defines function must be guaranteed to be launched first). It would be great to have separate script editor where i can define all global functions/variables.

UPD: after thinking for a while, it might be a bit more tricky to implement this function, as Throttle usually implemented via capturing state variable in closure, creating new function instance for each usage. Need to think more about how to best implement it in this plugin. Anyway, having set of global functions is still a good addition.


3) SUGGESTION: add enable/disable flag to each object to allow for quick temporary enable and disable of mapping

question: how data can be backed up / restored? if i recover LM from backup, how i can make sure that application configuration is restored as well?
Reply


Messages In This Thread
MQTT Client app - Beta testing - 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

Forum Jump: