Skip to content

Lx values calculated incorrectly in Z2M #11866

@MikaFromTheRoof

Description

@MikaFromTheRoof

I recently wondered why all the devices in Z2M always show at least 1 lx illuminance and never 0, even if they are in pitch black surroundings.

Because of that I did some research and found out, that the Zigbee standard defines the following formular for calculating the lux value from the raw illuminance value, that the Zigbee devices report:

lx = 10^(value/10000)-1
This has also been mentioned in this old issue: Koenkk/zigbee2mqtt#2837 (comment)

Back then the formular got corrected in the fromZigbee converter.

Now I found, that the formular used in the modernExtend.ts is wrong again:

result = 10 ** ((result - 1) / 10000);

The -1 is located in the wrong position, which would mathematically result in the lx value never being 0.

Is it possible to fix that globally in Z2M?

Thanks for great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions