Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions classes/StargateMilkyWay/stargate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, app):
self.electronics = app.electronics
self.base_path = app.base_path
self.net_tools = app.net_tools
self.temperature = app.temperature
self.sw_updater = self.app.sw_updater
self.schedule = app.schedule
self.galaxy = app.galaxy
Expand Down
28 changes: 28 additions & 0 deletions classes/temperature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import subprocess

class Temperature:

def __init__(self, log):
self.log = log

@staticmethod
def get_temperature():
"""
A little helper that returns the output of the temperature command
By default the command is available on Raspberry Pi OS (Lite)
Command: `vcgencmd measure_temp | cut -d "=" -f2`

:return: returns the output as seen if run in a shell.
"""
try:
result = subprocess.run(
'vcgencmd measure_temp | cut -d "=" -f2',
shell=True,
capture_output=True,
text=True,
check=True
)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
return f"Error getting temperature: {e}"
1 change: 1 addition & 0 deletions classes/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def do_GET(self): # pylint: disable=invalid-name
"dialer_mode": self.stargate.dialer.type,
"hardware_mode": self.stargate.electronics.name,
"audio_volume": self.stargate.audio.volume,
"temperature": self.stargate.temperature.get_temperature(),
"galaxy": self.stargate.galaxy
}

Expand Down
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from stargate import Stargate
from electronics import Electronics
from network_tools import NetworkTools
from temperature import Temperature

class GateApplication:

Expand Down Expand Up @@ -104,6 +105,11 @@ def rollbar_except_hook(exc_type, exc_value, traceback):

### We'll use NetworkTools and Schedule throughout the app, initialize them here.
self.net_tools = NetworkTools(self.log)

### Temperature
self.temperature = Temperature(self.log)

### Schedule
self.schedule = schedule # Alias the class here so it can be used in other areas with a clear interface

### Check for new software updates ###
Expand Down
2 changes: 2 additions & 0 deletions web/info.htm
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
$('#dialerMode').html(data.dialer_mode)
$('#hardwareMode').html(data.hardware_mode)
$('#volumeAsPercent').html(data.audio_volume)
$('#temperature').text(data.temperature)

$('#stats_dialing_failures').html(data.stats_dialing_failures)
$('#stats_established_fan_count').html(data.stats_established_fan_count)
Expand Down Expand Up @@ -558,6 +559,7 @@ <h3>System Information</h3>
<div class="system-info-row"><span class="system-info-col-names">Dialer Mode:&nbsp;&nbsp;&nbsp;</span><span class="system-info-col-values" id="dialerMode"></span></div>
<div class="system-info-row"><span class="system-info-col-names">Hardware in Use:&nbsp;&nbsp;&nbsp;</span><span class="system-info-col-values" id="hardwareMode"></span></div>
<div class="system-info-row"><span class="system-info-col-names">Audio Volume (%):&nbsp;&nbsp;&nbsp;</span><span class="system-info-col-values" id="volumeAsPercent"></span></div>
<div class="system-info-row"><span class="system-info-col-names">Temperature:&nbsp;&nbsp;&nbsp;</span><span class="system-info-col-values" id="temperature"></span></div>
</div>
<br>
<h3>Lifetime Statistics</h3>
Expand Down
1 change: 1 addition & 0 deletions web/js/system_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function updateInfo(){
$('#dialerMode').html(data.dialer_mode)
$('#hardwareMode').html(data.hardware_mode)
$('#volumeAsPercent').html(data.audio_volume)
$('#temperature').html(data.temperature)

$('#stats_dialing_failures').html(data.stats_dialing_failures)
$('#stats_established_fan_count').html(data.stats_established_fan_count)
Expand Down