Skip to content

Commit

Permalink
Account for cpu_temp_sensor returning null
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <[email protected]>
  • Loading branch information
yubiuser committed Mar 13, 2023
1 parent ed2de78 commit 94032c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions padd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ GetSystemInformation() {
fi

# CPU temperature and unit
cpu_temp_raw=$(GetFTLData "/info/sensors" | jq .sensors[0].value 2>/dev/null)
# in case .sensors.cpu_temp returns 'null' we substitute with 0
cpu_temp_raw=$(GetFTLData "/info/sensors" | jq '(.sensors.cpu_temp // 0)' 2>/dev/null)
cpu_temp=$(printf "%.1f" "${cpu_temp_raw}")
temp_unit=$(GetFTLData "/info/sensors" | jq --raw-output .sensors[0].unit 2>/dev/null)
temp_unit=$(GetFTLData "/info/sensors" | jq --raw-output .sensors.unit 2>/dev/null)

# Temp + Unit
if [ "${temp_unit}" = "C" ]; then
Expand Down

2 comments on commit 94032c9

@DL6ER
Copy link
Member

@DL6ER DL6ER commented on 94032c9 Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected behavior when 0 is shown is that users should open a FTL issue ticket so we can add the most appropriate sensor for their board.

@yubiuser
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope they will report (at least to PADD).

Screenshot at 2023-03-13 14-06-57

Please sign in to comment.