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

lux sensor value #14

Closed
astrojetson8 opened this issue Jun 25, 2017 · 12 comments
Closed

lux sensor value #14

astrojetson8 opened this issue Jun 25, 2017 · 12 comments

Comments

@astrojetson8
Copy link

fyi: looks like the default value for lux from gateway is around 360lux even when it's pitch dark.
https://msdn.microsoft.com/en-us/library/windows/desktop/dd319008(v=vs.85).aspx

@sendorm
Copy link

sendorm commented Jun 26, 2017

Someone has pointed out the fact from a xiaomi document that the lux sensor gives values between 300-1300. I went ahead and subtracted 300 from the reported value. Now it shows between 0-1000. Which for me is a better representation.

@sendorm
Copy link

sendorm commented Jun 26, 2017

Here is the link

lazcad/homeassistant#46

@astrojetson8
Copy link
Author

@sendorm oh cool, thanks, and it make sense. are you manually subtracting 300 ?
@YinHangCode
option 1. update this in code?
option 2. add default start lux value via config
option 3. i don't know

@sendorm
Copy link

sendorm commented Jun 26, 2017

Yeah, I am directly subtracting 300 in the code. So the reported value is between 0-1000. But still they are not good values. I tried to find a multiplier using the mi flora sensor (which seems to have a much better represantation). The relation might even be quadratic, I might check into that.

But in the end it is not necessary, just get the values for your normal usage and create automations accordingly.

@astrojetson8
Copy link
Author

@YinHangCode thanks for adding this to your latest release.

@YinHangCode
Copy link
Owner

YinHangCode commented Jul 26, 2017

1

123

@astrojetson8 @sendorm It looks like -300 is not a good value.

@sendorm
Copy link

sendorm commented Jul 26, 2017

yeah some users on the home assistant site also reported that 300 offset is not working for them too. 279 was the least reported as I recall.
Final solution was to add:

            # Workaround negative values for a few gateways which has a range of 279-1279 for unknown reason.
             if value < 0:
                value = 0

@YinHangCode
Copy link
Owner

@sendorm maybe -279 is the most suitable value.

@sendorm
Copy link

sendorm commented Jul 27, 2017

Maybe but the document here states that the values are between 300-1300.
https://github.com/louisZL/lumi-gateway-local-api/blob/master/网关.md

Some one else can say that his values goes down to 275 for instance, so a zero check is a must.
But of course it is your decision. You can make it 279 and put a negative check. That way no one will get an erroneous negative lux value.

@YinHangCode
Copy link
Owner

YinHangCode commented Jul 27, 2017

@sendorm yes, the document description is between 300-1300, but In fact, this is not the case.
following code should be better:
var illumination = data['illumination'] / 1.0 - 279;
and
illCharacteristic.updateValue(illumination > 0 ? illumination : 0);

@sendorm
Copy link

sendorm commented Jul 27, 2017

Yes, good solution. Thank you.

@astrojetson8
Copy link
Author

@YinHangCode sounds good.

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

3 participants