Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convertSet throwing an unspecified error when trying to set specific values #8525

Open
asgothian opened this issue Dec 27, 2024 · 5 comments

Comments

@asgothian
Copy link
Contributor

asgothian commented Dec 27, 2024

Hello,

I have an issue within the iobroker.zigbee Adapter where the converter for the device CL-L02D does not accept values for brightness, color and colortemp. It also does not seem to react correctly to brightness_move, colortemp_move, hue_move and saturation move events. I have been trying to track down the cause of the issue, but hit a wall when the code

with the following code going into the catch with no error message:

code:

                try {
                    if (has_elevated_debug) this.log.warn(`ELEVATED main.publishFromState: convert for ${key} with value ${safeJsonStringify(preparedValue)} and options ${safeJsonStringify(preparedOptions)} (device ${deviceId}, Endpoint ${epName})`);
                    const result = await converter.convertSet(target, key, preparedValue, meta);
                    if (has_elevated_debug) this.log.warn(`ELEVATED: convert result ${safeJsonStringify(result)} for device ${deviceId}`);
                    if (result !== undefined) {
                        if (stateModel && !isGroup) {
                            this.acknowledgeState(deviceId, model, stateDesc, value);
                        }
                        this.processSyncStatesList(deviceId, model, syncStateList);
                    }
                    else
                        if (has_elevated_debug) this.log.warn(`Error convert result for ${key} with ${safeJsonStringify(preparedValue)} is undefined on device ${deviceId}.`);

                } catch (error) {
                    if (has_elevated_debug) this.log.warn(`caught error ${safeJsonStringify(error)} is undefined on device ${deviceId}.`);
                    this.filterError(`Error ${error.code} on send command to ${deviceId}.` +
                        ` Error: ${error.stack}`, `Send command to ${deviceId} failed with`, error);
                }

Data going in (example with brightness_rgb):

key:brightness_rgb 
preparedValue: 254
options:  {"brightness_white":100,"transition_time":2,"brightness_rgb":100,"hue_calibration":{"x":0.64,"y":0.33},"transition":2,"brightness":254}
meta:  {"endpoint_name":"rgb", "options: {"brightness_white":100,"transition_time":2,"brightness_rgb":100,"hue_calibration":"{"x":0.64,"y":0.33}","transition":2,"brightness":254}, "device:{...}","mapped":{...}, "message": {"brightness_white":254}, logger: {...}, state:{}}

Note that I have cut out the values for device, mapped and logger from the provided data. I have verified that device and mapped refer to the exact device. Also, the values for the device, mapped and logger are identical to the attempts when setting the state (on/off), which does work for both endpoints (white, rgb)

I have verified that the correct converter is being addressed.

What throws me for a loop most is the fact that an error is raised as the messages inside the catch path are provided, but the variable 'error' seems to contain an empty object.

I would appreciate any hint as to how to get closer to the root cause of the problem.

This was tested with the current (yesterday) zigbee_herdsman_converters version 21.9.2 as well as 20.58.0

A.

@asgothian
Copy link
Contributor Author

The initial problem has been solved - to a degree. It was a case of Garbage In , Garbage Out. I was able to find the error in the end - the key was wrong. Still, the issue that the catch around the call does not provide an error object is making this difficult to impossible to debug. Any suggestion how to fix this ?

A.

@Koenkk
Copy link
Owner

Koenkk commented Dec 30, 2024

Do you have a clue on what line it goes wrong?

@asgothian
Copy link
Contributor Author

In my code, yes:
const result = await converter.convertSet(target, key, preparedValue, meta);

This call throws an error, but the error itself is empty. I also have (rare) cases where this line just does not return at all, any code afterwards is not being executed.

The inability to pinpoint the error is the main issue there.

A.

@Koenkk
Copy link
Owner

Koenkk commented Jan 2, 2025

Interesting, I cannot explain why this happens, what converter is it calling?

@asgothian
Copy link
Contributor Author

It was this device:

    {
        zigbeeModel: ['lumi.light.acn031'],
        model: 'HCXDD12LM',
        vendor: 'Aqara',
        description: 'Ceiling light T1',
        extend: [
            deviceEndpoints({endpoints: {white: 1, rgb: 2}}),
            lumiLight({colorTemp: true, powerOutageMemory: 'light', endpointNames: ['white']}),
            lumiLight({colorTemp: true, deviceTemperature: false, powerOutageCount: false, color: {modes: ['xy', 'hs']}, endpointNames: ['rgb']}),
            lumiZigbeeOTA(),
        ],
    },

the converter(s) generated by this code, and responsible for "brightness". Unfortunately I do not have the device myself so I cannot link the object directly

    lumiLight: (
        args?: Omit<modernExtend.LightArgs, 'colorTemp'> & {
            colorTemp?: true;
            powerOutageMemory?: 'switch' | 'light' | 'enum';
            deviceTemperature?: boolean;
            powerOutageCount?: boolean;
        },
    ) => {
        args = {powerOutageCount: true, deviceTemperature: true, ...args};
        const colorTemp: {range: Range; startup: boolean} = args.colorTemp ? {startup: false, range: [153, 370]} : undefined;
        const result = modernExtend.light({effect: false, powerOnBehavior: false, ...args, colorTemp});
        result.fromZigbee.push(
            fromZigbee.lumi_bulb_interval,
            fz.ignore_occupancy_report,
            fz.ignore_humidity_report,
            fz.ignore_pressure_report,
            fz.ignore_temperature_report,
            fromZigbee.lumi_specific,
        );

        if (args.powerOutageCount) result.exposes.push(e.power_outage_count());
        if (args.deviceTemperature) result.exposes.push(e.device_temperature());

        if (args.powerOutageMemory === 'switch') {
            result.toZigbee.push(toZigbee.lumi_switch_power_outage_memory);
            result.exposes.push(e.power_outage_memory());
        } else if (args.powerOutageMemory === 'light') {
            result.toZigbee.push(toZigbee.lumi_light_power_outage_memory);
            result.exposes.push(e.power_outage_memory().withAccess(ea.STATE_SET));
        } else if (args.powerOutageMemory === 'enum') {
            const extend = lumiModernExtend.lumiPowerOnBehavior({lookup: {on: 0, previous: 1, off: 2}});
            result.toZigbee.push(...extend.toZigbee);
            result.exposes.push(...extend.exposes);
        }

        return result;
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants