Материал из Module developer
Перейти к: навигация, поиск

SubDevice.addEvent()

to add Event

Syntax

Module.getSubDevice(SubDeviceName).add(Event)

input sample description
Event type: object
the Event object
Event field: Name "MyEvent" type: string
the event name
Event field: EventType "Simple" type: string
the event typeː "Simple" or "Advanced"
Event field: Type "send_number" type: string
the type of the event command - "send_number"
Event field: Param 1 type: number
the value which is compared
Event field: ChannelName "Dimmer:channel1" type: string
the name of the channel from which data is received
Event field: Compare "eq" type: string
the logic operation. "eq" - equal, "gt" - greater than, "lt" - less than, "ge" - greater or equal, "le" - less or equal
output
Оbject type: Object
the Event object


Example:

Module = B.getModule(ModuleID);
sub = Module.getSubDevice("MySub");
channelName1 = "GRPS:myChannel" // full channel name for device "GPRS" and his channel "myChannel"
sub.addEvent({ //event triggers if SMSnumber "=" to channelName1's value
            Name: "Just sent" + SMSnumber,
            EventType: "Simple",
            Param: SMSnumber,
            ChannelName: channelName1,
            Compare: "eq"
         });