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

Sensor magnitude offset option in webUI not showing. #2491

Closed
davebuk opened this issue Dec 26, 2021 · 8 comments
Closed

Sensor magnitude offset option in webUI not showing. #2491

davebuk opened this issue Dec 26, 2021 · 8 comments

Comments

@davebuk
Copy link
Contributor

davebuk commented Dec 26, 2021

I have a device that is using build: 1.15.0-dev.gitd5273513 with a BME280 sensor and I've noticed that I can't see the section in the webUI for adjusting PX, TEMP, HUMIDITY offsets. I know they used to be there in other builds.

I'm going to look to build a firmware tomorrow for another dev board with temp sensor, but before I do, is there something that needs to be adjusted in the code? I've had a quick look through the previous commits and couldn't see anything obvious that may have been fixed since Sep 2021. Thanks.

@davebuk
Copy link
Contributor Author

davebuk commented Dec 26, 2021

Built a firmware now with latest dev on a wemos d1 mini and get the following error at the top of the page:

TypeError: Cannot read properties of undefined (reading 'forEach')
    at updateMagnitudes (http://192.168.1.56/:17:38991)
    at http://192.168.1.56/:17:42063
    at Array.forEach (<anonymous>)
    at processData (http://192.168.1.56/:17:39650)
    at WebSocket.onWebSocketMessage (http://192.168.1.56/:17:43445)

For more info see the Developer Tools console.

I had a BME280 connected (which currently has an issue and intermittently fails so data pins disconnected) and I've just added a DS18b20 Waterproof Temperature Sensor but that isn't showing up as a sensor at the moment.

@mcspr
Copy link
Collaborator

mcspr commented Dec 26, 2021

2nd one seems to be caused by no sensors being available for reading

data.values.forEach((cfg, id) => {

i.e. data.values is undefined where it should've been [], so it's something to fix from both sides (ref. 'Developer Tools / Network' for the /ws endpoint, message causing the error would be {"magnitudes":{}})

1st one is correction aka offset simply missing from the web interface, starting from this commit
d9cb35f (pretty long time ago)
it is still handled via {tmp,press,hum}Correction{index} settings key, and through the build flags. something to add back, since the data is being sent to ui but not being processed

config(F("values"), _magnitudes.size(), {
{F("Correction"), [](JsonArray& out, size_t index) {
const auto& magnitude = _magnitudes[index];
if (_magnitudeCorrectionSupported(magnitude.type)) {
out.add(magnitude.correction);
} else {
out.add(NullSymbol);
}
}},

@davebuk
Copy link
Contributor Author

davebuk commented Dec 27, 2021

Both sensors are now reading so that error has gone.

Like you said, the keys are there for the corrections, just not showing on the webUI.

@davebuk
Copy link
Contributor Author

davebuk commented Apr 18, 2022

Hi Max. Is this a relatively quick fix? I'm going to build some other devices in the next few weeks and wondered if the fix would be implemented? Thanks.

@mcspr
Copy link
Collaborator

mcspr commented Apr 19, 2022

Probably is, but there's also a lot of backlog.
Also a matter of adjusting the .js to read every magnitudes-setting value in the payload instead of just Ratio

espurna/code/html/custom.js

Lines 2527 to 2531 in 02581c6

if ("magnitudes-settings" === key) {
initMagnitudesSettings(value);
return;
}

espurna/code/html/custom.js

Lines 1895 to 1903 in 02581c6

function initMagnitudesSettings(data) {
data.values.forEach((cfg, id) => {
const settings = fromSchema(cfg, data.schema);
if (settings.Ratio) {
initMagnitudesRatio(id, settings.Ratio);
initMagnitudesExpected(id);
}
});
}

(or, at least the correction offsets, which could be just a c/p and changing names of the elements to match the keys used by settings)

@davebuk
Copy link
Contributor Author

davebuk commented May 5, 2022

Thank you. I'll look to update some of my devices over the weekend.

@mcspr
Copy link
Collaborator

mcspr commented May 6, 2022

Just to note, current PIO config also depends on the development version of PlatformIO. You'd need to also do a pio upgrade --dev before trying to build
(mainly, renamed src_build_flags -> build_src_flags. maybe something else in extra scripts, but I have not checked that)

mcspr added a commit that referenced this issue May 6, 2022
As mentioned in the #2491
Hides parent element when these groups are empty
@davebuk
Copy link
Contributor Author

davebuk commented May 7, 2022

Working, thanks.
Build flags changed and updated.
Just have an issue with I2C bus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants