Skip to content

Wrong battery temperature calculation, no conversation #2744

@9840380

Description

@9840380

The battary temperature is not being converted and constantly shows almost the same value, 31 degrees.
In other monitoring programs, the value is correct.
Please check it.

Image

Details:
macOS Monterey
Version 12.7.6
MacBook Pro (Retina, 15-inch, Mid 2015)
Processor 2.2 GHz Quad-Core Intel Core 17
Memory 16 GB 1600 MHz DDR3
Startup Disk Macintosh
Graphics Intel Iris Pro 1536 MB
Stats
Version 2.11.52

This code converts temperature from decikelvin to Celsius with one decimal place. It takes raw integer values representing temperature in tenths of Kelvin (K × 10), converts them to Celsius by dividing by 10 and subtracting 273.15, then rounds to one decimal place. This format provides higher precision for internal measurements while displaying user-friendly Celsius values in MacBook battery diagnostics.

the correct calculation would be:

let tempRaw = dict["Temperature"] as? Int ?? -1
var temperature: Double = -1.0

if tempRaw > 0 {
    temperature = Double(tempRaw) / 10.0 - 273.15
    temperature = (temperature * 10).rounded() / 10
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions