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

Xiaomi Desklamp Rotary Encoder Bugs #1934

Closed
fluffymadness opened this issue Oct 7, 2019 · 4 comments · Fixed by #1938
Closed

Xiaomi Desklamp Rotary Encoder Bugs #1934

fluffymadness opened this issue Oct 7, 2019 · 4 comments · Fixed by #1938

Comments

@fluffymadness
Copy link

There are some weird issues with my xiaomi desklamp
I upgraded to the latest nightly that is linked via github
and the rotary encoder behavior is completely broken
when i try to dim down in dims down a bit and is then full brightness again
same with color change
when i turn the wheel to the right it changes between yellow and white gradually
worked fine on older builds
newest tasmota with the xiaomi desklamp module has the same issue for me

(espurna-1.13.6-dev.nightly20191001+gitbd385f9f-xiaomi-smart-desk-lamp) broken
#1621 (comment) -> works fine

@mcspr
Copy link
Collaborator

mcspr commented Oct 7, 2019

Thanks for the report! I do see the issue here:

lightBrightness(_light_brightness + steps * LIGHT_STEP);

When step is negative and brightness already approaches 0, lightBrightness function receives negative value. Due to signed / unsigned conversion, resulting brightness is converted from -1 to some value near 4294967295 and in the end into the 100% that you are seeing
I can't see any issues with the encoder handling, but will re-check in the morning and commit the fix.

@fluffymadness
Copy link
Author

fluffymadness commented Oct 8, 2019

thanks for the quick reply. Another thing I've noticed, is it maybe possible to expose color temperature via mqtt ? The pregenerated homeassistant template from espurna only gives me brightness control.

light:
  - name: ESPURNA_83D22DF2
    state_topic: ESPURNA-83D22DF2/relay/0
    command_topic: ESPURNA-83D22DF2/relay/0/set
    payload_on: 1
    payload_off: 0
    availability_topic: ESPURNA-83D22DF2/status
    payload_available: 1
    payload_not_available: 0
    brightness_state_topic: ESPURNA-83D22DF2/brightness
    brightness_command_topic: ESPURNA-83D22DF2/brightness/set

@mcspr
Copy link
Collaborator

mcspr commented Oct 9, 2019

See if #1938 fixes this. I have a simple encoder setup to mimic xiaomi lamp and it seems to work in both button modes.

For color_temp topic to appear you need to enable both useWhite and useCCT in the settings

@fluffymadness
Copy link
Author

Everything works fine now. Encoder behavior for changing color temperature and brightness and also setting this values via homeassistant. 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 a pull request may close this issue.

2 participants