Skip to content

Add JS 'Utils' object to provide log10() missing on older Qt versions - #6152

Merged
manup merged 2 commits into
dresden-elektronik:masterfrom
manup:master
Jun 30, 2022
Merged

manup merged 2 commits into
dresden-elektronik:masterfrom
manup:master

Conversation

@manup

@manup manup commented Jun 28, 2022

Copy link
Copy Markdown
Member

The Math.log10() function is missing on some setups: see: https://forum.phoscon.de/t/rtcgq11lm-light-level-broken-since-2-17/2104/7

In the Utils object we can add functions to do some basic tasks or provide some math mojo.

Fixes state/lux not updated on Xiaomi RTCGQ11LM motion sensor.

The Math.log10() function is missing on some setups: see: https://forum.phoscon.de/t/rtcgq11lm-light-level-broken-since-2-17/2104/7

In the Utils object we can add functions to do some basic tasks or provide some math mojo.
@manup
manup merged commit b147144 into dresden-elektronik:master Jun 30, 2022
@Tscheurgen

Copy link
Copy Markdown

Hello!
I'm sorry, I'm not sure where to correct discuss this topic further on.
In my situation it seems the value is still not Update in REST API. I've checked out latest master branch, as it was commited today and compiled it right now.
I've checked the files for you changes, everything seems to be there.
Any other things I should investigate?
Thank you!

@manup

manup commented Jun 30, 2022

Copy link
Copy Markdown
Member Author

Hi, compiling the plugin is one part of this puzzle. In the changed files list of this PR are also updated .json and .js files which need to be copied from the source /devices/... directory to respective location in /usr/share/deCONZ/devices/...

However, the next version should arrive during the day, might be easier to just install it :)

@Tscheurgen

Copy link
Copy Markdown

I'm sorry, Yes, I've missed those two files.
I gave it a try and yeah! it's working :-)
Thank you!

@olemr

olemr commented Jul 17, 2022

Copy link
Copy Markdown
Contributor

Tried 2.17.1 now, but same fault as in 2.17.0 (OK in 2.16.1)
It stops sending updates on REST:
Time is now 00:23
Verified by shining a flashlight on the sensor. On 2.17.1, dead, on 2.16.1 new value after 5-10s.
(as posted on Discord)

Phillips HUE Outdoor sensor.
Was working until an apt-get update/upgrade (deconz steady on 2.17.01 via dpkg - i)

@SwoopX

SwoopX commented Jul 18, 2022

Copy link
Copy Markdown
Collaborator

This is not the same issue, but could have a similar root case. Can you please Do the same as described here https://forum.phoscon.de/t/rtcgq11lm-light-level-broken-since-2-17/2104/3?u=swoop ? If you also see an error message while the script is evaluating the lightlevel, please file a seperate bug report. Thanks!

@olemr

olemr commented Sep 10, 2022 •

Copy link
Copy Markdown
Contributor

Got the log ...

Item.val = v
R.item('state/dark').val = v <= tholddark
R.item('state/daylight').val = v > tholddark + tholdoffset
R.item('state/lux').val = Math.round(Math.pow(10, (Math.max(0, Math.min(v, 60001)) - 1) / 10000))
, err: SyntaxError: Syntax error

More here https://forum.phoscon.de/t/philips-hue-outdoor-light-sensor-broken-since-2-17-0-still-a-problem-on-2-18-1-ddf-syntax-error/2429/4

@Smanar

Smanar commented Sep 10, 2022 •

Copy link
Copy Markdown
Collaborator

Lol, you have bypassed the "evil gatekeeper bot " but your issue have nothing to see with this PR

Else I don't see something special in the JS code, the file is devices\philips\0400_lightlevel.js, can you try with adding ";" at the end of lines ?

/* global Attr, Item, R */

const v = Attr.val;
const tholddark = R.item('config/tholddark').val;
const tholdoffset = R.item('config/tholdoffset').val;

Item.val = v
R.item('state/dark').val = v <= tholddark;
R.item('state/daylight').val = v > tholddark + tholdoffset;
R.item('state/lux').val = Math.round(Math.pow(10, (Math.max(0, Math.min(v, 60001)) - 1) / 10000));

Edit:

Restarted here #6315

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

Successfully merging this pull request may close these issues.

5 participants