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

feat: add status LED switch for WB-MSW-ZIGBEE v.4 and refactor to modern extend #7074

Merged
merged 25 commits into from
Mar 5, 2024

Conversation

mrskycriper
Copy link
Contributor

This PR was inspired by #7016. I'm trying to finish it's idea by properly exposing led control as a binary switch.

So far I was able to make a crude working prototype& However, it has hardcoded endpoint name and TS does not like the convertGet as Promise<{ activity_indicator: unknown; }> does not match Promise<ConvertSetResult>. I'll continue working on it but this muliEndpoint magic is kinda hard to understand and I would really appreciate the help.

@mrskycriper mrskycriper marked this pull request as draft February 14, 2024 23:37
@Koenkk
Copy link
Owner

Koenkk commented Feb 15, 2024

Can you use the binary modern extend instead? This will also solve the issue you are currently having.

Example:

lumiLedIndicator: (args? :Partial<modernExtend.BinaryArgs>) => modernExtend.binary({

@mrskycriper
Copy link
Contributor Author

mrskycriper commented Feb 15, 2024

lumiLedIndicator

Probably just generic binary? I'll try it

UPD
Ah, I see, it's an example

@mrskycriper
Copy link
Contributor Author

mrskycriper commented Feb 15, 2024

@Koenkk How to specify entity_category for modern extends? I can't find any usage of withCategory() inside any of them.

Also, is it possible to specify the target endpoint? This device has two instances of genBinaryOutput. The one on 1st endpoint turns on Modbus and stops sending any data to Zigbee. The other is on the 5th, responsible for the LED indicator. I don't see any explicit endpoint configuration anywhere.

Never mind, it looks like it accepts endpoint name string.

@mrskycriper
Copy link
Contributor Author

mrskycriper commented Feb 15, 2024

Well, I must have done something wrong because now it does not work at all and reacts with errors on any action.

Publish 'get' 'activity_indicator' to 'Bedroom Climate sensor' failed:
'Error: Read 0x04cd15fffe8fb6e9/5 genBinaryOutput([85], {
  "timeout":10000,
  "disableResponse":false,
  "disableRecovery":false,
  "disableDefaultResponse":true,
  "direction":0,
  "srcEndpoint":null,
  "reservedBits":0,
  "manufacturerCode":26214,
  "transactionSequenceNumber":null,
  "writeUndiv":false
}) failed (Status 'UNSUPPORTED_ATTRIBUTE')'
Publish 'set' 'activity_indicator' to 'Bedroom Climate sensor' failed:
'Error: Write 0x04cd15fffe8fb6e9/5 genBinaryOutput({
  "85": {"value":1,"type":16}}, {
    "timeout":10000,
    "disableResponse":false,
    "disableRecovery":false,
    "disableDefaultResponse":true,
    "direction":0,
    "srcEndpoint":null,
    "reservedBits":0,
    "manufacturerCode":26214,
    "transactionSequenceNumber":null,
    "writeUndiv":false
}) failed (Status 'UNSUPPORTED_ATTRIBUTE')'

@Koenkk
Copy link
Owner

Koenkk commented Feb 17, 2024

You need to remove the manufacturerCode (you also don't use it in activity_indicator)

@mrskycriper
Copy link
Contributor Author

It worked, but now I want to finish refactoring it to modern extend. And for that I will need to make some fixes first. So I'm leaving this PR as a draft for now

@mrskycriper mrskycriper changed the title feat: add status LED switch for WB-MSW-ZIGBEE v.4 (help needed) feat: add status LED switch for WB-MSW-ZIGBEE v.4 and refactor to modern extend Feb 17, 2024
@mrskycriper
Copy link
Contributor Author

mrskycriper commented Feb 28, 2024

@Koenkk currently testing it as an external converter and it seems to be working well. However, I regularly get strange error in the logs, but can't seem to find the source of it.

pic error

If I remove the sensor from Zigbee network, the flood of errors stops.

@mrskycriper mrskycriper marked this pull request as ready for review February 28, 2024 15:46
@mrskycriper
Copy link
Contributor Author

It looks like the VOC is failing to bind and somehow all other binds are failing to show up in the GUI until I manually try to bind something else. The attribute reading fail is expected (mine doesn't have the sensor module installed), but this probably should now affect the bind this badly. In a stable version this error is missing.

Снимок экрана 2024-02-28 в 20 09 39

src/lib/modernExtend.ts Outdated Show resolved Hide resolved
src/lib/modernExtend.ts Outdated Show resolved Hide resolved
src/lib/modernExtend.ts Outdated Show resolved Hide resolved
@mrskycriper
Copy link
Contributor Author

@Koenkk besides corrections, any ideas on described errors above?

@mrskycriper mrskycriper marked this pull request as draft February 29, 2024 22:27
@Koenkk
Copy link
Owner

Koenkk commented Mar 1, 2024

However, I regularly get strange error in the logs, but can't seem to find the source of it.

Could you provide the debug log of it?

The attribute reading fail is expected (mine doesn't have the sensor module installed), but this probably should now affect the bind this badly. In a stable version this error is missing.

The other binds are indeed not executed because of this, it stops when one of them fails. We should disabled the read for this attribute.

@mrskycriper
Copy link
Contributor Author

mrskycriper commented Mar 1, 2024

Could you provide the debug log of it?

@Koenkk I’ll see what I can capture

The other binds are indeed not executed because of this, it stops when one of them fails. We should disabled the read for this attribute.

I suspect that this will happen with any combination of attributes if certain modules are not installed. What is the best way to handle this?

@Koenkk
Copy link
Owner

Koenkk commented Mar 1, 2024

I suspect that this will happen with any combination of attributes if certain modules are not installed. What is the best way to handle this?

Maybe we can add an option: allowReadFail ?

@mrskycriper
Copy link
Contributor Author

@Koenkk This is what i caught with debug level + zigbee-herdsman debug log

debug 2024-03-01 23:48:22 Received Zigbee message from 'Bedroom Climate sensor', type 'attributeReport', cluster 'msOccupancySensing', data '{"occupancy":0}' from endpoint 1 with groupID 0
error 2024-03-01 23:48:22 Exception while calling fromZigbee converter: Cannot read properties of undefined (reading 'endpointName')}
debug 2024-03-01 23:48:22 TypeError: Cannot read properties of undefined (reading 'endpointName') at Object.convert (/app/node_modules/zigbee-herdsman-converters/src/lib/modernExtend.ts:833:49) at Receive.onDeviceMessage (/app/lib/extension/receive.ts:153:51) at EventEmitter.wrappedCallback (/app/lib/eventBus.ts:174:23) at EventEmitter.emit (node:events:529:35) at EventBus.emitDeviceMessage (/app/lib/eventBus.ts:108:22) at Controller.<anonymous> (/app/lib/zigbee.ts:117:27)
info 2024-03-01 23:48:22 MQTT publish: topic 'zigbee2mqtt/Bedroom Climate sensor', payload '{"activity_led_indicator":false,"co2":616,"humidity":32.76,"illuminance":3874,"illuminance_lux":2,"last_seen":"2024-03-01T23:48:22+03:00","linkquality":123,"noise":30,"noise_detect_level":50,"noise_detected":false,"noise_timeout":60,"occupancy":false,"occupancy_level":13,"occupancy_sensitivity":50,"occupancy_timeout":60,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","temperature":23.03,"temperature_offset":0,"th_heater":false,"update":{"installed_version":5,"latest_version":5,"state":"idle"},"voc":null}'

@mrskycriper
Copy link
Contributor Author

@Koenkk created #7143 with the fix for this issue, so it can be merged before this PR

@mrskycriper mrskycriper marked this pull request as ready for review March 4, 2024 17:16
src/lib/modernExtend.ts Outdated Show resolved Hide resolved
@Koenkk Koenkk merged commit 5bdb3e2 into Koenkk:master Mar 5, 2024
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Mar 5, 2024

Thanks!

@mrskycriper mrskycriper deleted the wb4-status-switch branch March 7, 2024 17:39
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.

None yet

2 participants