Created At
Apr 05, 2023
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
1080
Download
57
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_TYPES = {
centralSceneEvent = "centralSceneEvent",
global = "global",
customEvent = "customevent",
geofenceEvent = "GeofenceEvent",
deviceProperty = "property",
deviceActionRanEvent = "deviceActionRanEvent",
deviceRemovedEvent = "DeviceRemovedEvent",
quickAppVariable = "quickvar",
zwaveDeviceParametersChangedEvent = "ZwaveDeviceParametersChangedEvent"
}
table.insert(EventsToRegister, {
event = {
type ='property',
propertyName = 'value',
deviceID = 21,
value = true
},
method = 'onSensorBreach'
})