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

Add missing off_wait_time to light_onoff_brightness converter #8175

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

marazmarci
Copy link
Contributor

@marazmarci marazmarci commented Oct 23, 2024

I successfully used the onWithTimedOff command for relays and smart plugs in my automations. For some devices, it's enough only to provide an on_time value in the payload, but for some devices (such as the Sonoff ZBMINI, see note here), it's also required to provide an off_wait_time value. In Koenkk/zigbee2mqtt.io#2392, a documentation section was added for all devices supporting on_time about the "on with timed off" feature, in which it is mentioned that the device may require to also provide an off_wait_time value. This documentation section is also shown for lights (example), so as a user, I would expect it to work.

on_time works¹ for lights (I tried some IKEA LEDxxxxGx lights), but I noticed that off_wait_time produces the following error:

No converter available for 'off_wait_time' (0)

¹ "works" in the sense that it doesn't produce an error in Z2M. However, for some models, it actually works, but for some, it doesn't, that's why I started experimenting with off_wait_time.

In this PR, I added the off_wait_time key to the light_onoff_brightness converter. As far as I understand the code, this works when a brightness value is not provided, and light_onoff_brightness delegates to on_off, according to this part of the code:

if (brightness === undefined) {
// Converting the type to a generic one so we can set readAfterWriteTime and state.brightness without errors
const result = (await converters1.on_off.convertSet(entity, 'state', state, meta)) as KeyValueAny;

Some history: on_time was added to the same line of code in ef35333 by @Koenkk after @sjorge reported Koenkk/zigbee2mqtt#12276

@marazmarci
Copy link
Contributor Author

@Koenkk, please add the hacktoberfest-accepted label to the PR. 🙏

@Koenkk Koenkk merged commit daaa6ba into Koenkk:master Oct 23, 2024
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Oct 23, 2024

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants