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

Converting zigbee illuminance value to lux #1506

Closed
tcwj2008 opened this issue Aug 26, 2020 · 7 comments
Closed

Converting zigbee illuminance value to lux #1506

tcwj2008 opened this issue Aug 26, 2020 · 7 comments

Comments

@tcwj2008
Copy link

tcwj2008 commented Aug 26, 2020

According to Zigbee doc (4.2.2.2.1)

MeasuredValue = 10000 * LOG10( lx )+1

so converting zigbee illuminance value to lux should be

lx = 10^((MeasuredValue-1)/10000)

not
lx = 10^(MeasuredValue/10000)-1

@Koenkk
Copy link
Owner

Koenkk commented Aug 26, 2020

Fixed, thanks!

Koenkk added a commit that referenced this issue Aug 26, 2020
@Koenkk Koenkk closed this as completed Aug 26, 2020
@Koenkk Koenkk reopened this Aug 30, 2020
@Koenkk
Copy link
Owner

Koenkk commented Aug 30, 2020

I'm wondering wether this calculation is correct, in case of MeasuredValue 0, 1 is returned now (Koenkk/zigbee2mqtt#4211)

Shouldn't it be (Math.pow(10, illuminance) - 1) / 10000 ?

@sjorge
Copy link
Sponsor Contributor

sjorge commented Sep 6, 2020

Any consensus on this?

@Koenkk
Copy link
Owner

Koenkk commented Sep 6, 2020

@tcwj2008 could you please check #1506 (comment) , if I don't hear anything I assume (Math.pow(10, illuminance) - 1) / 10000 is OK.

@Koenkk
Copy link
Owner

Koenkk commented Sep 12, 2020

Reverted it back to the old calculation.

@Koenkk Koenkk closed this as completed Sep 12, 2020
@presslab-us
Copy link
Contributor

I believe the new calculation is correct, but there also needs to be a special case for 0. The documentation states: ”0x0000 indicates a value of Illuminance that is too low to be measured." So if MeasuredValue == 0, then lx = 0. Otherwise use the new calculation.

Koenkk added a commit that referenced this issue Oct 2, 2020
@Koenkk
Copy link
Owner

Koenkk commented Oct 2, 2020

@presslab-us good to know, I've added it know with a check on 0 value.

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

No branches or pull requests

4 participants