Created At

Apr 05, 2023

Last Update

Apr 05, 2023

Platforms

HC 3 Lite, Z-box Hub, Yubii Home Pro, Yubii Home, Venture WISE, HC 3

Views

840

Download

48

Type Quick App

This QuickApp is a utility that keeps track of refresh state events in the system. It let you register for events from other QuickApps calling your QuickApp methods when the appropriate event occurs similarly to the scene triggers mechanism. 

Let's say you want to call a QuickApp method when some door sensor is triggered. 
In this example we have 3 devices:
21 -> your door sensor
22 -> this QuickApp (EventsListener)
23 -> your new QuickApp in which you want to trigger the methods

To register for such event you need to:

1. Create a method that should be called

function QuickApp:onDoorSensorStateChanged(event)
print("Hello from the door")
end

2. Create EventsToRegister object

EventsToRegister = {
{
event = {
type = 'property',
propertyName = 'value',
deviceID = 21
},
method = 'onDoorSensorStateChanged'
}
}

3. Call addEventListeners method on the EventsListener QA

fibaro.call(22, 'addEventListeners', {
deviceId = 23,
events = EventsToRegister
})

When the door is triggered onDoorSensorStateChanged method will be called by EventsListener QA.

Couple of notes and examples

  • event object is passed to the method so you can inspect for further details
  • EventsToRegister is a table so you can pass multiple events for one QuickApp. Maybe you want to listen for array of sensors, rather than a single one
  • event types examples
    EVENT_TYPES = {
    centralSceneEvent = "centralSceneEvent",
    global = "global",
    customEvent = "customevent",
    geofenceEvent = "GeofenceEvent",
    deviceProperty = "property",
    deviceActionRanEvent = "deviceActionRanEvent",
    deviceRemovedEvent = "DeviceRemovedEvent",
    quickAppVariable = "quickvar",
    zwaveDeviceParametersChangedEvent = "ZwaveDeviceParametersChangedEvent"
    }
  • EventsListener has a filtering mechanism so you can limit the calls to specific properties of the events
    table.insert(EventsToRegister, {
    event = {
    type ='property',
    propertyName = 'value',
    deviceID = 21,
    value = true
    },
    method = 'onSensorBreach'
    })

 

0 Comments,  Want to add comment please login
Load more comments
© 2024. Nice-Polska Sp. z o.o.Privacy policyTerms & ConditionsFeedback