Hi,
Using spec.query.qlinkmodel.config returns the following results…
for lumi.switch.agl009:
{
data: {
'lumi.switch.agl009': {
deviceTypesList: [ 'Switch', 'Button' ],
endpoints: [
{
deviceType: 'Root',
functions: [
{
functionId: 128,
traits: [
{
parameter: {
readable: true,
type: 'Integer',
subscribable: true,
writable: false
},
traitId: 32896,
traitCode: 'FirmwareRevision'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 32897,
traitCode: 'SerialNumber'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 32898,
traitCode: 'VendorName'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 32899,
traitCode: 'VendorID'
},
{
parameter: {
readable: true,
unit: '',
defaultValue: 'µÖ║Þâ¢ÕóÖÕúüÕ╝ÇÕà│',
type: 'String',
subscribable: true,
writable: false
},
traitId: 32900,
traitCode: 'ProductName'
},
{
parameter: {
readable: true,
type: 'Bool',
subscribable: true,
writable: false
},
traitId: 32901,
traitCode: 'Reachable'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 33141,
traitCode: 'ModelValue'
},
{
parameter: {
readable: true,
type: 'Integer',
subscribable: true,
writable: false
},
traitId: 32902,
traitCode: 'HardwareVersion'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 32903,
traitCode: 'Location'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 33047,
traitCode: 'FirmwareRevisionString'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 32904,
traitCode: 'Mac'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: false
},
traitId: 32905,
traitCode: 'DeviceID'
}
],
functionCode: 'BasicInformation',
commands: []
},
{
functionId: 129,
traits: [
{
parameter: {
readable: true,
type: 'Integer',
subscribable: true,
writable: true
},
traitId: 32912,
traitCode: 'SelectedEndpointDynamic'
},
{
parameter: {
readable: true,
defaultValue: false,
type: 'Bool',
subscribable: true,
writable: false
},
traitId: 32906,
traitCode: 'SupportedEndpointDynamic'
},
{
parameter: {
readable: true,
defaultValue: 1,
type: 'Integer',
subscribable: true,
writable: false
},
traitId: 32907,
traitCode: 'EndpointDynamicCount'
},
{
parameter: {
readable: true,
defaultValue: 4,
type: 'Integer',
subscribable: true,
writable: false
},
traitId: 32908,
traitCode: 'EndpointCount'
},
{
parameter: {
readable: true,
unit: '',
defaultValue: '[0,1,2,3]',
type: 'List[X]',
subscribable: true,
writable: false
},
traitId: 32909,
traitCode: 'EndpointArray'
},
{
parameter: {
readable: true,
defaultValue: '["Root","Public","Switch","Button"]',
type: 'List[X]',
subscribable: true,
writable: false
},
traitId: 32910,
traitCode: 'EndpointDeviceTypes'
},
{
parameter: {
readable: true,
type: 'List[X]',
subscribable: true,
writable: false
},
traitId: 32911,
traitCode: 'EndpointFunctions'
}
],
functionCode: 'Descriptor',
commands: []
},
{
functionId: 130,
traits: [
{
parameter: {
readable: true,
unit: '',
defaultValue: 'µÖ║Þâ¢ÕóÖÕúüÕ╝ÇÕà│',
type: 'String',
subscribable: true,
writable: true
},
traitId: 32913,
traitCode: 'EndpointName'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: true
},
traitId: 32914,
traitCode: 'EndpointRoom'
},
{
parameter: {
readable: true,
defaultValue: false,
type: 'Bool',
subscribable: true,
writable: false
},
traitId: 32915,
traitCode: 'EndpointVisibility'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: true
},
traitId: 33016,
traitCode: 'EndpointRoomName'
}
],
functionCode: 'EndpointLabel',
commands: []
}
],
endpointId: 0
},
{
deviceType: 'Public',
functions: [
{
functionId: 130,
traits: [
{
parameter: {
readable: true,
defaultValue: false,
type: 'Bool',
subscribable: true,
writable: false
},
traitId: 32915,
traitCode: 'EndpointVisibility'
}
],
functionCode: 'EndpointLabel',
commands: []
},
{
functionId: 131,
traits: [
{
parameter: {
readable: true,
type: 'Float',
subscribable: true,
writable: false
},
traitId: 32916,
traitCode: 'IdentifyTime'
},
{
parameter: {
readable: true,
type: 'Enum',
subscribable: true,
writable: true
},
traitId: 32917,
traitCode: 'IdentifyType'
}
],
functionCode: 'Identify',
commands: [
{
commandCode: 'Identify',
fields: [],
commandId: 32918
}
]
},
{
functionId: 140,
traits: [
{
parameter: {
readable: true,
unit: 'W',
min: 0,
max: 5000,
step: 0.1,
type: 'Float',
subscribable: true,
writable: false
},
traitId: 32945,
traitCode: 'CurrentPower'
},
{
parameter: {
readable: true,
unit: 'W┬Àh',
min: 0,
max: 100000000,
step: 0.1,
type: 'Float',
subscribable: true,
writable: false
},
traitId: 32946,
traitCode: 'CumulativeEnergyConsumption'
}
],
functionCode: 'EnergyManagement',
commands: []
}
],
endpointId: 1
},
{
deviceType: 'Switch',
functions: [
{
functionId: 130,
traits: [
{
parameter: {
readable: true,
unit: '',
defaultValue: 'þ╗ºþöÁÕÖ¿Õ╝ÇÕà│',
type: 'String',
subscribable: true,
writable: true
},
traitId: 32913,
traitCode: 'EndpointName'
},
{
parameter: {
readable: true,
unit: '',
defaultValue: 'Switch',
supportedValues: [
{ value: 'Light' },
{ value: 'Switch' },
{ value: 'Outlet' },
{ value: 'Fan' },
{ value: 'Ventilation' },
{ value: 'AirConditioner' },
{ value: 'AirPurifier' },
{ value: 'Humidifier' },
{ value: 'Dehumidifier' },
{ value: 'TV' },
{ value: 'Refrigerator' },
{ value: 'Computer' },
{ value: 'WaterHeater' },
{ value: 'Kettle' },
{ value: 'MicrowaveOven' },
{ value: 'Hub' },
{ value: 'ContactSensor' },
{ value: 'Door' },
{ value: 'Window' },
{ value: 'Cabinet' },
{ value: 'Other' }
],
type: 'String',
subscribable: true,
writable: true
},
traitId: 32929,
traitCode: 'EndpointApplianceType'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: true
},
traitId: 32914,
traitCode: 'EndpointRoom'
},
{
parameter: {
readable: true,
defaultValue: true,
type: 'Bool',
subscribable: true,
writable: false
},
traitId: 32915,
traitCode: 'EndpointVisibility'
},
{
parameter: {
readable: true,
type: 'Bool',
subscribable: true,
writable: true
},
traitId: 33012,
traitCode: 'EndpointStatistics'
},
{
parameter: {
readable: true,
unit: '',
defaultValue: 'light_bulb',
supportedValues: [
{ value: 'light_bulb' },
{ value: 'ceiling_light' },
{ value: 'ceiling_light_a' },
{ value: 'ceiling_light_b' },
{ value: 'chandelier_a' },
{ value: 'chandelier_b' },
{ value: 'chandelier_c' },
{ value: 'spotlight_a' },
{ value: 'spotlight_b' },
{ value: 'strip_light' },
{ value: 'string_light' },
{ value: 'panel_light' },
{ value: 'track_lighting' },
{ value: 'column_light' },
{ value: 'floor_lamp_a' },
{ value: 'downlights_light' },
{ value: 'wall_lamp' },
{ value: 'child_lamp' },
{ value: 'grille_lamp' },
{ value: 'art_lamp' },
{ value: 'button' },
{ value: 'fan' }
],
type: 'String',
subscribable: true,
writable: true
},
traitId: 32919,
traitCode: 'EndpointIcon'
},
{
parameter: {
readable: true,
type: 'String',
subscribable: true,
writable: true
},
traitId: 33016,
traitCode: 'EndpointRoomName'
}
],
functionCode: 'EndpointLabel',
commands: []
},
{
functionId: 132,
traits: [
{
parameter: {
readable: true,
type: 'Bool',
subscribable: true,
writable: true
},
traitId: 32920,
traitCode: 'OnOff'
}
],
functionCode: 'Output',
commands: [
{ commandCode: 'Toggle', fields: [], commandId: 32922 }
]
},
{
functionId: 135,
traits: [
{
parameter: {
readable: false,
unit: '',
supportedValues: [
{ value: '0', key: 'SinglePress' },
{ value: '1', key: 'DoublePress' },
{ value: '2', key: 'LongPress' }
],
type: 'Enum',
subscribable: true,
writable: false
},
traitId: 32928,
traitCode: 'ButtonEvent'
}
],
functionCode: 'Button',
commands: []
}
],
endpointId: 2
},
{
deviceType: 'Button',
functions: [
{
functionId: 130,
traits: [
{
parameter: {
readable: true,
unit: '',
defaultValue: 'µùáþ║┐Õ╝ÇÕà│',
type: 'String',
subscribable: true,
writable: true
},
traitId: 32913,
traitCode: 'EndpointName'
},
{
parameter: {
readable: true,
unit: '',
defaultValue: true,
type: 'Bool',
subscribable: true,
writable: false
},
traitId: 32915,
traitCode: 'EndpointVisibility'
},
{
parameter: {
readable: true,
defaultValue: true,
type: 'Bool',
subscribable: true,
writable: true
},
traitId: 33012,
traitCode: 'EndpointStatistics'
},
{
parameter: {
readable: true,
unit: '',
defaultValue: 'switch',
supportedValues: [ { value: 'mini_switch' }, { value: 'switch' } ],
type: 'String',
subscribable: true,
writable: true
},
traitId: 32919,
traitCode: 'EndpointIcon'
}
],
functionCode: 'EndpointLabel',
commands: []
},
{
functionId: 135,
traits: [
{
parameter: {
readable: false,
unit: '',
supportedValues: [
{ value: '0', key: 'SinglePress' },
{ value: '1', key: 'DoublePress' },
{ value: '2', key: 'LongPress' }
],
type: 'Enum',
subscribable: true,
writable: false
},
traitId: 32928,
traitCode: 'ButtonEvent'
}
],
functionCode: 'Button',
commands: []
}
],
endpointId: 5
}
],
model: 'lumi.switch.agl009'
}
}
}
From the response, you can then retrieve the endpointId, the functionCode, and the traitCode.
If you then send the following to the API using the intent spec.write.trait:
traits: [
{
deviceId: 'lumi.[DEVICE-MAC-ADDRESS]',
endpointId: 2,
functionCode: 'Output',
traitCode: 'OnOff',
value: true
}
]
Does the connected circuit then turn on, or do you get an error message?
With this command, you are directly controlling the physical relay (the actual electrical circuit), completely independent of whether someone physically pressed the wall switch.
The (other) buttons themselves on the device do not control any hardware relays—they act purely as wireless smart buttons. Because they aren’t physically wired to a load, you cannot send a “switch” command to them; it wouldn’t make sense since there is no circuit to close.
Instead, you use the API to listen for their incoming events (like a single, double, or long press). If you want one of these buttons to turn on a smart bulb, for example, you simply catch that event and handle the automation logic on the software side. You essentially have to script the automation flow yourself: listen for the event (e.g., a “single click”), and then send an API command to turn on the target light.