Some systems expose cpu temperatures differently in
psutil. Specifically, running armbian on the Odroid xu4 sbc gives the
following temerature output:
>>> pp.pprint(psutil.sensors_temperatures())
{ 'cpu0-thermal':
[ shwtemp(label='', current=54.0, high=115.0, critical=115.0)],
'cpu1-thermal':
[ shwtemp(label='', current=56.0, high=115.0, critical=115.0)],
'cpu2-thermal':
[ shwtemp(label='', current=58.0, high=115.0, critical=115.0)],
'cpu3-thermal':
[ shwtemp(label='', current=56.0, high=115.0, critical=115.0)],
}
Since the cpu number is embedded inside the name, the current code
can't find it.
To fix this, check both the name and the constructed label for matches
against CPU_SENSOR_PREFIXES, and add the appropriate label
cpu0-thermal in the prefix list.
While this is slightly less efficient that just generating the label
and checking it, it results in easier to understand code.
- Remove unneeded excinfo to _LOGGER.exception
- Use f-strings
- Switch last_boot to utc
- Cache psutil/os calls used by multiple attributes in the same update cycle
* Remove unit from garmin connect
* Remove unit from hvv departures
* Remove device class timestamp from device condition and trigger
* Remove unit from systemmonitor
* Use device class constant for timestamp in ring
* Added check for mandatory "arg" of sensors
* Make pylint happy
* Moved to vol validator function for "arg" checks
* Make pylint happy once again
* Adjustments from code review
* Improvements for systemmonitor
* Use MDI CPU icon (bit architecture determined at runtime)
* Consistent usages of "percent" (ensured backwards compatibility by explicity setting the entity_id)
* Default value "/" (root) for disk_* sensors to prevent runtime issues if not specified in configuration
* Added CPU temperature sensor to systemmonitor
* Code streamlining of CPU temperature retrieval
* Corrected sensor state handling and added "available" logic
* Corrected ENTITY_ID to include argument
* Optimized "available" handling & CPU temperature detection
* Corrected tuple for CPU temperature determination
* - Do not create CPU temperature entity if no sensor data can be read
- Re-use temperature sensor labels from "glances" integration
* Array fix
* Corrected sensor array access
* Handle empty temperature sensor labels (same logic as used by "glances")
* PR comments: Setting unique_ID and f-strings
* Removed unused constants
* Revert entity rename (wait until next release)
* Change datetime.now() to dt_util.now() in cases where the functionality should stay the same
These changes should not affect the functionality, rather cleanup our codebase.
In general we would like integrations to not to use datetime.now() unless there's a very good
reason for it, rather use our own dt_util.now() which makes the code aware of our current time
zone.
* Use datetime.utcnow() for season sensor to get offset-naive utc time
* Revert "Use datetime.utcnow() for season sensor to get offset-naive utc time"
This reverts commit 5f36463d9c7d52f8e11ffcec7e57dfbc7b21bdd1.
* BOM sensor last_updated should be UTC as well
* Run black
* Remove unused last_partition_update variable
* Consolidate
* Fix tests
* Update imports
* Fix import
* Use importlib because integration and package share name
* Fix more tests
* Update .coveragerc and CODEOWNERS