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

SubDevice.addCondition()

to add Condition

Syntax

Module.getSubDevice(SubDeviceName).add(Condition)

input sample description
Condition type: object
the Condition object
Condition field: Name "MyCondition" type: string
the condition name
Condition field: ConditionType "Simple" type: string
the condition typeː "Simple" or "Advanced"
Condition field: Type "send_number" type: string
the type of the condition command - "send_number"
Condition field: Param 1 type: number
the value which is compared
Condition field: ChannelName "Dimmer:channel1" type: string
the name of the channel from which data is received
Condition 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
объект Condition


Example:

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