Average room temperature: exclude values outside the "normal" ranges from calculations

Hello,
in one room, I have 2 temperature readings coming in: one from a standard sensor, the other from the radiator pilot-wire module which stays at -999°C all the time because it’s unused.
And I occasionally get a wildly incorrect average temperature:

Could we exclude from the calculations values below absolute zero (-273.15 °C) or some other very low value?

Thanks in advance :grin:

Hi @mutmut,

Which integration are these sensors from?

1 Zigbee and 1 Z-Wave JS.

Ok, indeed we can eliminate the outliers!

1 Like

Hello,
I’m back with one more check to do.
In my living room temperature, I have a Zigbee sensor, my Netatmo and my Dyson (via matterbridge).
For now my Dyson has no value (because I’ve disabled the appropriate matterbridge plugin) and I get this, with an obviously incorrect average temperature:


Would it be possible to add a check on the device to know if it is OK or KO

It’s already the case: the « Room Temperature » widget displays an average of the temperatures received in the room during the last hour (source: Gladys/server/lib/device/temperature-sensor/temperature-sensor.getTemperatureInRoom.js at master · GladysAssistant/Gladys · GitHub).

Your KO device will stop

Okay, thanks for the info, I’ll keep an eye on it then :slight_smile:

1 Like

I worked on a PR with Claude Haiku and here is the result :

However, I can’t run the tests via VSCode, I get error messages like this and I don’t understand anything at all (not being a dev, I’m really having trouble) :

DualStef:server stef$ pwd
/Users/stef/CloudStation/github/Gladys/server
DualStef:server stef$ npm test

> test
> cross-env NODE_ENV=test ./node_modules/mocha/bin/mocha --recursive ./test/bootstrap.test.js "./test/**/*.test.js" --exit

node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: spawn ./node_modules/mocha/bin/mocha ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:483:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)
    at onErrorNT (node:internal/child_process:483:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ./node_modules/mocha/bin/mocha',
  path: './node_modules/mocha/bin/mocha',
  spawnargs: [
    '--recursive',
    './test/bootstrap.test.js',
    './test/**/*.test.js',
    '--exit'
  ]
}

Node.js v22.21.1
DualStef:server stef$ pwd
/Users/stef/CloudStation/github/Gladys/server
DualStef:server stef$ npm run eslint

> eslint
> eslint .

(node:82347) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignore-files
(Use `node --trace-warnings ...` to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 10.0.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

@pierre-gilles if you can help me, I wouldn’t say no.

EDIT :
with the help of Copilot, I managed to make some progress a bit :

npx prettier --write lib/device/temperature-sensor/temperature-sensor.getTemperatureInRoom.js

A comma was missing from what I saw… but it doesn’t change anything :

Thanks for trying to help with the AI!

Be careful with Claude Haïku — it’s an old model that’s underperforming and not very smart :sweat_smile:

Comparison with Claude Opus 4.6:

IMG_9274

IMG_9276

To run prettier, you need to run « npm run prettier » in the server folder :wink:

Haïku 4.5 — GitHub and VS Code offer it for free so I’m using it, I don’t have a paid account.
And you have to give it a bit of help but I think the result wasn’t bad.

I had already done that too and it hadn’t worked … and now it works but it modified 81 files, is that normal? :roll_eyes:
What should I do? Stage and commit?

EDIT : well I’m making slow progress, I discarded everything and modified only my file. Now it’s ESLint that I need to rework.

I have a Windsurf referral link if you want: Referrals | Windsurf

It’s cancellable at any time, there’s a trial period, and otherwise at worst it’s just 12€ (15$) for a month of use, and honestly given the quality of the models the 12€ are more than worth it :smiley:

No, only the files you modified should be changed.

Exactly!

Ask the AI to write the tests :wink:

But well, we might be reaching the limit of vibe-coding, in any case you need to review and know what you’re doing… :grimacing: