Different type in getDeviceTriggerCard

I create app with DeviceTriggerCard, but there is a bug with arg type. when I get args.button.aid in standard flow type is Number, but in advanced flow type is String.

this.homey.flow.getDeviceTriggerCard('multy_button_clicks')
    .registerArgumentAutocompleteListener('button', async (query, args) => {
        const device = args.device as SprutHubDevice;
        const data = device.getData()
        const services = await (device.driver as SprutHubDriver).getServices(data.aid);
        const filter = services?.filter(service => service.type === 'StatelessProgrammableSwitch')
        for (const value of filter || []) {
            console.log('*** aid', value.aId, typeof value.aId);
            console.log('*** sid', value.sId, typeof value.sId);

        }
        return filter?.map(service => ({
            name: service.name,
            aid: Number(service.aId),
            sid: Number(service.sId)
        })) || [];;

    })
    .registerArgumentAutocompleteListener('click_type', async (query, args) => {
        if (!(args.button)) {
            return [];
        }
        const device = args.device as SprutHubDevice;
        const data = device.getData()
        // console.log('*** data', data);
        console.log('*** aid', args.button.aid, typeof args.button.aid); // Number in standart flow, but string in advanced
        console.log('*** sid', args.button.sid, typeof args.button.sid);
        const service = await (device.driver as SprutHubDriver).getService(args.button.aid, args.button.sid, true);

        return service.characteristics?.flatMap(characteristic => {
            if (getCharacteristicControl(characteristic).type === 'ProgrammableSwitchEvent') {
                const val = getCharacteristicControl(characteristic).validValues
                    ?.filter(value => value.checked === true)
                    ?.map(filteredValue => ({
                        name: filteredValue.name,
                        value: filteredValue,
                        aId: characteristic.aId,
                        sId: characteristic.sId,
                        cId: characteristic.cId
                    })) || [];
                console.log(val);
                return val
            }
            return [];
        }) || [];
    })
    .registerRunListener(async (args, state) => {
        if (state.aId === args.click_type.aId && state.sId === args.click_type.sId && state.cId === args.click_type.cId) {
            return Object.values(state.control.value)[0] === Object.values(args.click_type.value.value)[0];
        }
        return false;
    });

You can create a issue here: https://github.com/athombv/homey-apps-sdk-issues/issues

1 Like