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

endpoint in definition.toZigbee can be an array of string #24525

Merged
merged 4 commits into from
Nov 2, 2024
Merged

Conversation

Zitrium31
Copy link
Contributor

This change is required for PR #8190 to correct issue #24352.

endpointNames : string[] used in moderExtend.js may includes more that 1 endpoint. Array of endpointNames being recorded in definition.toZigbee, converter filtering in publish.ts must now be able to find the given endpointName within an array of string (and not only a string).

This PR in addition to PR #8190 have been finally sucessfully tested on a diy device made of the following 4 endpoints:

  • Endpoint 8 : genBasic, genIdentify, msTemperatureMeasurement.
  • Endpoint 10 : closuresWindowCovering ( ep1 ) --> It uses key state
  • Endpoint 12 : genOnOff ( relay ) --> It uses also key state
  • Endpoint 14 : genOnOff ( relay2 ) --> It uses also key state and the cluster genOnOff

and the following external definition:

const {deviceEndpoints, temperature, onOff, windowCovering} = require('zigbee-herdsman-converters/lib/modernExtend');

const definition = {
    zigbeeModel: ['GADORC2407'],
    model: 'GADORC2407',
    vendor: 'MyDiyZigbee',
    description: 'Garage Door Lock Remote Control',
    extend: [
        deviceEndpoints({"endpoints":{'ep1':10, 'relay':12, 'relay2':14}}),
        temperature(),
        onOff({"powerOnBehavior":false, "endpointNames":['relay', 'relay2']}),
        windowCovering({"controls":['lift'], "coverInverted":true, "stateSource":'lift', "coverMode":false, "endpointNames":['ep1']})
        ],
};
module.exports = definition;

To allow the selection of the proper converter with multi endpoints divice
This change corrects issue #24352
This change is linked to PR Koenkk/zigbee-herdsman-converters#8190
In zigbee-herdsman-converters\src\lib\types.ts
@Zitrium31
Copy link
Contributor Author

Last ci / tests failed due to Tz.Converter.endpoints renamed and type changed to string[] not yet pulled here. See PR #8190 / commit Simplify Tz.Converter.endpoints type to string[] array only

LaurentChardin referenced this pull request in Koenkk/zigbee-herdsman-converters Nov 2, 2024
…8190)

* Define endpoint in definition.toZigbee containing key 'state'
To allow the selection of the proper converter with multi endpoints divice
at zigbee2mqtt-master\lib\extension\publish.ts at  line "const converter =
converters.find...c.endpoint == endpointName"
This change corrects issue Koenkk/zigbee2mqtt#24352

* Code format with Prettier

* Simplify Tz.Converter.endpoints type to string[] array only
@Koenkk Koenkk changed the base branch from dev to deps/zigbee-herdsman-converters November 2, 2024 20:02
@Koenkk Koenkk merged commit 8d9db22 into Koenkk:deps/zigbee-herdsman-converters Nov 2, 2024
1 of 11 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Nov 2, 2024

Thanks!

@Zitrium31
Copy link
Contributor Author

I found the regression bug comes from devices/gledopto.ts at line 120 :

    result.toZigbee = utils.replaceInArray(
        result.toZigbee,
        [tz.light_onoff_brightness, tz.light_colortemp, tz.light_color, tz.light_color_colortemp],
        [
            tzLocal.gledopto_light_onoff_brightness,
            tzLocal.gledopto_light_colortemp,
            tzLocal.gledopto_light_color,
            tzLocal.gledopto_light_color_colortemp,
        ],
        false,
    );

It seems tz.light_onoff_brightness is not found/replaced anymore by function replaceInArray()
I am trying to find a fix to make this compatible with the {...tz.light_onoff_brightness, endpoints: args?.endpointNames} introduced in modernExtend.ts with but without success up to now.

@Koenkk
Copy link
Owner

Koenkk commented Nov 3, 2024

Fixed!

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

Successfully merging this pull request may close these issues.

2 participants