leiweibau / Pi.Alert

Scan the devices connected to your WIFI / LAN and alert you the connection of unknown devices. It also warns if a "always connected" device disconnects. In addition, it is possible to check web services for availability. For this purpose HTTP status codes and the response time of the service are evaluated.
https://leiweibau.net
GNU General Public License v3.0
469 stars 32 forks source link

Missing Temperature in WebGUI on RaspberryPi 2B #101

Closed jkehrel closed 1 year ago

jkehrel commented 1 year ago

Your script does not find a temperature reading on my Rasberry Pi 2B with Pi OS bullseye. With PI OS operating system or Ubuntu 22.04 you can get the temperature with Python this way:

001  # Dieses Programm liest die CPU Temperatur mit GPIOZero aus
002
003  from gpiozero import CPUTemperature
004
005  cpu = CPUTemperature()
006  print(cpu.temperature)

or

001  # Dieses Programm liest die CPU Temperatur mit VCGENCMD aus
002
003  import os
004
005  cpu_temp = os.popen("vcgencmd measure_temp").readline()
006  print(cpu_temp)

comment # above is german, my language.

Should be similar with PHP

<?php
$temp = exec('vcgencmd measure_temp');
$temp = str_replace('temp=','',$temp);
$temp = str_replace('\'C','',$temp);
echo $temp;
?>

Thank you for your nice and free implementation of pi.alert.

leiweibau commented 1 year ago

To query the temperature, no command is executed, but a file containing the temperature is queried. At the moment this is /sys/class/thermal/thermal_zone0/temp and /sys/class/hwmon/hwmon0/temp1_input. Do you have these files? You can test the output with: cat /sys/class/hwmon/hwmon0/temp1_input cat /sys/class/thermal/thermal_zone0/temp

jkehrel commented 1 year ago

After further investigation, a correction: Your code gets the temperature on my Pi 2B. The problem lies in the browser.

On a Windows 10 22H2 PC with Firefox 111 I can not see the temperature: Ashampoo_Snap_Donnerstag, 16  März 2023_8h40m31s Using Google Chrome on the same PC it is visible: Ashampoo_Snap_Donnerstag, 16  März 2023_8h42m4s On an Android smartphone with Chrome it is visible too: Screenshot_20230316_084515_Chrome But on Android/Chrome these buttons are nearly unreadable because of white text on light gray color of background Screenshot_20230316_084526_Chrome Both buttons are okay on Windows with Chrome and Firefox Ashampoo_Snap_Donnerstag, 16  März 2023_8h41m1s

leiweibau commented 1 year ago

During development, I sometimes have similar errors. Have you cleared the browser cache?

jkehrel commented 1 year ago

OK. Cleared my browser cache on Windows. Now Firefox shows temperature. So you can close this issue. But on Android 12 with Google Chrome the two buttons have background color light gray and only the edge of the buttons is in the correct color as in my hard copy of the screen. Even after clearing the browser cache. Because the text is white, it is hardly readable.

leiweibau commented 1 year ago

But on Android 12 with Google Chrome the two buttons have background color light gray and only the edge of the buttons is in the correct color as in my hard copy of the screen.

I'll take a look at it in the next few days and fix it.

leiweibau commented 1 year ago

It is fixed. It will be included in the next update.