Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Recommended Posts

Posted

A word about missing events: I have a device on the mechanical heating gas counter reacting with the small magnet on 1/1000 m3 counting wheel. Other words: it generates 1000 events by smart implant on a 1 m3 of gas. This month alone, I noticed a discrepancy of approximately 0.65 cubic meters between the meters - digital in HC3 and analog. That mens more than 650 events was lost. No current lost during the month.

 

In the context of 'pattern of meaning' events, it's particularly challenging when event happens that shouldn't happen at all.

 

 

  • 4 months later...
Posted

@jgab Jan, can you please explain why the eventhandler triggers twice, if the device is a switch, and why once (as it should) when the device is a sensor? This is driving me crazy. I am testing my code, and i am fighting this like 3 hours. I could not get why the event triggered twice while testing . I created a simple switch QA and I turned it ON OFF to see if it works.But every single handler triggers twice. On the other hand, if I use a sensor type device for testing, or a real ZWAVE sensor, it triggers normaly as it should only once.

 

Please login or register to see this code.

 

Posted (edited)
52 minutes ago, Neo Andersson said:

@jgab Jan, can you please explain why the eventhandler triggers twice, if the device is a switch, and why once (as it should) when the device is a sensor? This is driving me crazy. I am testing my code, and i am fighting this like 3 hours. I could not get why the event triggered twice while testing . I created a simple switch QA and I turned it ON OFF to see if it works.But every single handler triggers twice. On the other hand, if I use a sensor type device for testing, or a real ZWAVE sensor, it triggers normaly as it should only once.

 

Please login or register to see this code.

 

 

 

Try this:
 

 

Event.id='breachevent'                            
Event{type='device', id = sensor_id, property='value', value=true}
function Event:handler(event)
  print("Event: ",json.encode(event))
  sensorBreachedEvent()
end

 

 

without the property "Filter" it triggers on other "Switch" events too I think is a Okey explenation 😅

 

This is a way I use it:

 if relay_ids ~= nil then
      print("relay_ids: ",json.encode(relay_ids))
      Event.id='Relay_events'
      Event {type='device', id=relay_ids, property='value'}  -----    Event {type='device', id=relay_ids, property='value', value='$value'}
      ---@diagnostic disable-next-line
      function Event:handler(event)
        self:debug("Sensor ID: ",event.id,"value: ",event.value)
       
        relay_value[event.id] = event.value
          if event.value == true then
            relay_value_string[event.id] = "<font color=#99ff33>ON"
 
          elseif event.value == false then
            relay_value_string[event.id] = "<font color=#990000>OFF"
 
          end
        relay_value_updated[event.id] = os.date("%c")
        relay_power[event.id] = hub.getValue(event.id, "power")
        if relay_power[event.id] ~= nil then
          if relay_power_highest[event.id] < relay_power[event.id] then
            relay_power_highest[event.id] = relay_power[event.id]
          end
        else
          if event.value == true then
            relay_power[event.id] = relay_power_highest[event.id]
          elseif event.value == false then
            relay_power[event.id] = 0
          end
        end
       
        relay_counts[event.id] = relay_counts[event.id] + 1
 
        print("Event: ",json.encode(event))
        Fun_relay_ids()
      end---event.id
 
 

 

 

Then it triggers on all events and I filter all the values I do need :)

 

Event.id='breachevent'
Event{type='device', id = sensor_id, property='value', value='$value'}
 
function Event:handler(event)
print("Event: ",json.encode(event))
if event.value == true then
sensorBreachedEvent_true()
elseif event.value == false then
sensorBreachedEvent_false()
end
end


This way you get only the True/false values and and do :D 

 

 

Edited by Brors94
Posted
13 minutes ago, Brors94 said:

 

 

Try this:
 

 

Event.id='breachevent'                            
Event{type='device', id = sensor_id, property='value', value=true}
function Event:handler(event)
  print("Event: ",json.encode(event))
  sensorBreachedEvent()
end

 

 

without the property "Filter" it triggers on other "Switch" events too I think is a Okey explenation 😅

 

This is a way I use it:

 if relay_ids ~= nil then
      print("relay_ids: ",json.encode(relay_ids))
      Event.id='Relay_events'
      Event {type='device', id=relay_ids, property='value'}  -----    Event {type='device', id=relay_ids, property='value', value='$value'}
      ---@diagnostic disable-next-line
      function Event:handler(event)
        self:debug("Sensor ID: ",event.id,"value: ",event.value)
       
        relay_value[event.id] = event.value
          if event.value == true then
            relay_value_string[event.id] = "<font color=#99ff33>ON"
 
          elseif event.value == false then
            relay_value_string[event.id] = "<font color=#990000>OFF"
 
          end
        relay_value_updated[event.id] = os.date("%c")
        relay_power[event.id] = hub.getValue(event.id, "power")
        if relay_power[event.id] ~= nil then
          if relay_power_highest[event.id] < relay_power[event.id] then
            relay_power_highest[event.id] = relay_power[event.id]
          end
        else
          if event.value == true then
            relay_power[event.id] = relay_power_highest[event.id]
          elseif event.value == false then
            relay_power[event.id] = 0
          end
        end
       
        relay_counts[event.id] = relay_counts[event.id] + 1
 
        print("Event: ",json.encode(event))
        Fun_relay_ids()
      end---event.id
 
 

 

 

Then it triggers on all events and I filter all the values I do need :)

 

Event.id='breachevent'
Event{type='device', id = sensor_id, property='value', value='$value'}
 
function Event:handler(event)
print("Event: ",json.encode(event))
if event.value == true then
sensorBreachedEvent_true()
elseif event.value == false then
sensorBreachedEvent_false()
end
end


This way you get only the True/false values and and do :D 

 

 

that was my first thought too, but waht else can trigger in case of a switch if i specify that i am looking for value == true??? Anyway i will try it.

 

16 minutes ago, Brors94 said:

 

 

Try this:
 

 

Event.id='breachevent'                            
Event{type='device', id = sensor_id, property='value', value=true}
function Event:handler(event)
  print("Event: ",json.encode(event))
  sensorBreachedEvent()
end

 

 

without the property "Filter" it triggers on other "Switch" events too I think is a Okey explenation 😅

 

This is a way I use it:

 if relay_ids ~= nil then
      print("relay_ids: ",json.encode(relay_ids))
      Event.id='Relay_events'
      Event {type='device', id=relay_ids, property='value'}  -----    Event {type='device', id=relay_ids, property='value', value='$value'}
      ---@diagnostic disable-next-line
      function Event:handler(event)
        self:debug("Sensor ID: ",event.id,"value: ",event.value)
       
        relay_value[event.id] = event.value
          if event.value == true then
            relay_value_string[event.id] = "<font color=#99ff33>ON"
 
          elseif event.value == false then
            relay_value_string[event.id] = "<font color=#990000>OFF"
 
          end
        relay_value_updated[event.id] = os.date("%c")
        relay_power[event.id] = hub.getValue(event.id, "power")
        if relay_power[event.id] ~= nil then
          if relay_power_highest[event.id] < relay_power[event.id] then
            relay_power_highest[event.id] = relay_power[event.id]
          end
        else
          if event.value == true then
            relay_power[event.id] = relay_power_highest[event.id]
          elseif event.value == false then
            relay_power[event.id] = 0
          end
        end
       
        relay_counts[event.id] = relay_counts[event.id] + 1
 
        print("Event: ",json.encode(event))
        Fun_relay_ids()
      end---event.id
 
 

 

 

Then it triggers on all events and I filter all the values I do need :)

 

Event.id='breachevent'
Event{type='device', id = sensor_id, property='value', value='$value'}
 
function Event:handler(event)
print("Event: ",json.encode(event))
if event.value == true then
sensorBreachedEvent_true()
elseif event.value == false then
sensorBreachedEvent_false()
end
end


This way you get only the True/false values and and do :D 

 

 

ehh, you were right..this solved the puzzle..thanks

  • Topic Author
  • Posted

    Just see if it's exactly the same event you get:
     

    Please login or register to see this code.

    Please login or register to see this code.

     

    Some devices also sets their property 'state' to true.

    I tried it with this code in plua, and I get single event - because I only update the value prop.

    Please login or register to see this code.

     

    • Like 1
    Posted
    8 minutes ago, jgab said:

    Just see if it's exactly the same event you get:
     

    Please login or register to see this code.

    Please login or register to see this code.

     

    Some devices also sets their property 'state' to true.

    I tried it with this code in plua, and I get single event - because I only update the value prop.

    Please login or register to see this code.

     

    yes, that switch quickapp updates the state property too

    • 1 month later...
    Posted

    Is there a way to make the RECIEVE_EVENT [sic] work if I build a QA with EventLib ?

     

    I sent an external HTTP call and saw this in the logs

     

    Please login or register to see this code.

     

    thx 

    Posted
    2 hours ago, gurpal2000 said:

    Is there a way to make the RECIEVE_EVENT [sic] work if I build a QA with EventLib ?

     

    I sent an external HTTP call and saw this in the logs

     

    Please login or register to see this code.

     

    thx 

     

    you dont need eventlib for that :D 

    Just make a button with "RECIEVE_EVENT" or maybe a function RECIEVE_EVENT() that is global is also possible I think 🤔

     

     

     

    Posted (edited)
    21 minutes ago, Brors94 said:

     

    you dont need eventlib for that :D 

    Just make a button with "RECIEVE_EVENT" or maybe a function RECIEVE_EVENT() that is global is also possible I think 🤔

     

     

     

    oh dear. Really that simple.

     

    Confirmed, eg:

     

    Please login or register to see this code.

     

    Edited by gurpal2000
    • Like 1
    • 1 month later...
    Posted (edited)

    @jgab Hello Jan
    Would you please check on climteZone type event handling?
    For some reason it doesnt work when zone ids are in table. It works only for a single zone

    This works

    Please login or register to see this code.

     

    this also works
     

    Please login or register to see this code.

     

    this doesn't
     

    Please login or register to see this code.

     

    Edited by Neo Andersson
    • 3 weeks later...
    Posted

    @jgab Jan, in my next installation i need to use eventLib in 20 quickapps..(maybe more)
    Do you think that using eventLib in that much devices, can cuase some problems?? CPU, memory etc..

  • Topic Author
  • Posted
    13 hours ago, Neo Andersson said:

    @jgab Jan, in my next installation i need to use eventLib in 20 quickapps..(maybe more)
    Do you think that using eventLib in that much devices, can cuase some problems?? CPU, memory etc..

    20 QuickApps on the same HC3? 
    Why not a single HC2 with eventLIb and 20 child devices?

    Posted
    On 1/15/2026 at 6:09 AM, jgab said:

    20 QuickApps on the same HC3? 
    Why not a single HC2 with eventLIb and 20 child devices?

    becuase there ar 20 thermstats in the house..some of the wall mounted zwave one, some of them linked fibaro thermostats (predefined plugin using a temperature sensor and some actors) and some of the simple thermostat type quickapps where only the lua code drives the thermostat, and some readitors..We have a plugin that manages the heatPumps linked to each thermostats (that plgin runs once the eventlib) but the thermostats all need to run their own listeners (becuase the code itself decides wheter to heat or not). So eseentially yes we can merge this into 20 child thermostats and evenlisteners would only run in parent, but i have not thought about this solution for now, as using childs sometimescan be really tricky , but maybe we will try..anyway, i was still curoius about the burden that 20 eventliis would put on a system..its is the same as i would run 20 different refreshSubscriptions (i guess)
    So probably this can not be any big issue, i just wanted to get it confirmed.

    Posted
    2 hours ago, Neo Andersson said:

    becuase there ar 20 thermstats in the house..some of the wall mounted zwave one, some of them linked fibaro thermostats (predefined plugin using a temperature sensor and some actors) and some of the simple thermostat type quickapps where only the lua code drives the thermostat, and some readitors..We have a plugin that manages the heatPumps linked to each thermostats (that plgin runs once the eventlib) but the thermostats all need to run their own listeners (becuase the code itself decides wheter to heat or not). So eseentially yes we can merge this into 20 child thermostats and evenlisteners would only run in parent, but i have not thought about this solution for now, as using childs sometimescan be really tricky , but maybe we will try..anyway, i was still curoius about the burden that 20 eventliis would put on a system..its is the same as i would run 20 different refreshSubscriptions (i guess)
    So probably this can not be any big issue, i just wanted to get it confirmed.

    I do run eventlib on more then 20 quickapp on both my HC3 :D So works fine for me 😄

    • Thanks 1
    • 2 weeks later...
    Posted (edited)

    @jgab I have noticed that accidentally i forgot to attach Event:attachRefreshstate() in one of my plugins. and it still works..It still fires on events..

    How is this possible? In eventlib there is some auto-attachment?

    so this is the right syntax below right?

    Please login or register to see this code.

     

    how can then this below still work? even if its uses only CRON events, i should have assigned attachRefreshstate right?
     

    Please login or register to see this code.

     

    Edited by Neo Andersson
  • Topic Author
  • Posted
    On 1/27/2026 at 7:39 PM, Neo Andersson said:

    @jgab I have noticed that accidentally i forgot to attach Event:attachRefreshstate() in one of my plugins. and it still works..It still fires on events..

    How is this possible? In eventlib there is some auto-attachment?

    so this is the right syntax below right?

    Please login or register to see this code.

     

    how can then this below still work? even if its uses only CRON events, i should have assigned attachRefreshstate right?
     

    Please login or register to see this code.

     

     

    attachRefreshState is to start polling for HC3 "system" events. "user" defined events still works. CROn uses a "user" defined event  (type='cron') so it still works without attachRefreshState.

    • Like 1
    • Thanks 1
    • 4 weeks later...
    Posted

    Hi @jgab,

     

    time has come when I have to deal with events and to avoid loosing too much time on this I have decided to go with your EventLib solution.

     

    I have added one Quick app of generic type. Added EventLib file and pasted complete code of your EventLib.lua code version 0.51. Then in main file I have added following code for testing:

     

    Please login or register to see this code.

     

    Device 280 is Fibaro eye.

    When eye is triggered this debug I get:

    Please login or register to see this code.

     

    As you can see there are two events reported even I have declared property="value".

    Also, I get warning that class does not have function defined?

     

    What I'm doing wrong here?

     

    Note that I need first to initialize quick app, find and select triggering devices and only then add events, so having these in QuickApp:onInit() does not work for me.

  • Topic Author
  • Posted
    9 hours ago, Sankotronic said:

    Hi @jgab,

     

    time has come when I have to deal with events and to avoid loosing too much time on this I have decided to go with your EventLib solution.

     

    I have added one Quick app of generic type. Added EventLib file and pasted complete code of your EventLib.lua code version 0.51. Then in main file I have added following code for testing:

     

    Please login or register to see this code.

     

    Device 280 is Fibaro eye.

    When eye is triggered this debug I get:

    Please login or register to see this code.

     

    As you can see there are two events reported even I have declared property="value".

    Also, I get warning that class does not have function defined?

     

    What I'm doing wrong here?

     

    Note that I need first to initialize quick app, find and select triggering devices and only then add events, so having these in QuickApp:onInit() does not work for me.


    I'm not able to test your code at the moment on the HC3.
    But the log do print the deviceID so that event handler works.
    The other logs is someone calling QA 188 with something like fibaro.call(188,"sourceTrigger",event)
    and QA 188 don't have QuickApp:sourceTrigger defined... It's not my eventLib code that does that call....

    Posted

    Hi @jgab,

     

    thanks for the tip. There is no other device or device 188 that makes any calls like fibaro.call(188,"sourceTrigger",event) in my code.

     

    But if you look at the trace:

    Please login or register to see this code.

     

    listed in console when Fibaro eye is triggered and event is fired in my quick app, then there is a part "actionName":"sourceTrigger", so I was thinking that I'm missing something?

     

    Anyway I have added function:

    Please login or register to see this code.

    in my main code and instead of warning now I get printed above debug message.

    Is it possible that this is something new with refreshStateSubscriber class introduced with last beta?

     

    Also, when fibaro eye is breached I get two events for 'lastBreached' and 'value' even I used following setup:

    Please login or register to see this code.

     

    It is not a big deal since I can always check what is returned by event arguments and then do action, but as I understood such setup should filter all other events and pass through only those with property 'value'?

  • Topic Author
  • Posted
    12 hours ago, Sankotronic said:

    Hi @jgab,

     

    thanks for the tip. There is no other device or device 188 that makes any calls like fibaro.call(188,"sourceTrigger",event) in my code.

     

    But if you look at the trace:

    Please login or register to see this code.

     

    listed in console when Fibaro eye is triggered and event is fired in my quick app, then there is a part "actionName":"sourceTrigger", so I was thinking that I'm missing something?

     

    Anyway I have added function:

    Please login or register to see this code.

    in my main code and instead of warning now I get printed above debug message.

    Is it possible that this is something new with refreshStateSubscriber class introduced with last beta?

     

    Also, when fibaro eye is breached I get two events for 'lastBreached' and 'value' even I used following setup:

    Please login or register to see this code.

     

    It is not a big deal since I can always check what is returned by event arguments and then do action, but as I understood such setup should filter all other events and pass through only those with property 'value'?

     

    The log

    Please login or register to see this code.

    is logged by Fibaro's QA framework whenever you call

    fibaro.call(self.id,<method>,...) 

    i.e. when calling a QuickApp method from within your own QA using fibaro.call. It is usually better to call self:<method>(....)

    Also if you have a UI button with the onReleased function set it will call fibaro.call(self.id,<actionName>,..) on your QA. In your case do you have an UI button with onReleased set to "sourceTrigger" ? ... that someone is calling?

    It is also logged in your QA if another QA (or Scene) is calling your QA with
    fibaro.call(qaID,<method>,...) 

    In all cases, if the method doesn't exist you get the additional message that the Class does not have the method (sourceTrigger in this case).

    I checked with the HC3 and refreshStateSubscriber and latest FW and I don't get the missing class method warning, so nothing seems to have changed there.

     

    14 hours ago, Sankotronic said:

    Anyway I have added function:

    Please login or register to see this code.

    in my main code and instead of warning now I get printed above debug message.

    Is it possible that this is something new with refreshStateSubscriber class introduced with last beta?

    Yes, it solves the warning but not who's trying to call your QuickApp:sourceTrigger function.
    refreshStateSubscriber has been around for a while, and I tested with latest fw and bo call to :sourceTrigger.

     

     Also, when fibaro eye is breached I get two events for 'lastBreached' and 'value' even I used following setup:

    Please login or register to see this code.


    That doesn't make sense - the handler should only trigger on property == 'value'. Haven't seen that before or from anyone else.

    Please login or register to see this code.

    This should only trigger on device event with property 'value'. lastBreached has a property of 'lastBreached'
    Add this log and see if it triggers on property='lastBreached' and property='value'

    Please login or register to see this code.


    ...or are you meaning that you get some other log? Note that 'lastBreached' and 'value' trigger twice for an Eye, when breached and when going safe. However, your handler only catches property='value' and value=true. Anything else would be need to be some other log or handler ...?

    Btw, are you running the new wave engine I'm still on the old one - but I would be surprised if the system events would change drastically and even if so, the handler in your example would not trigger at all.

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...