Added NIC Speed info to system controller

This commit is contained in:
avollkopf 2022-03-08 14:25:00 +01:00
parent 6ac93e5212
commit c3c4101b6b
3 changed files with 31 additions and 5 deletions

View file

@ -131,7 +131,7 @@ class Fermenter:
brewname: str = None brewname: str = None
description : str = None description : str = None
props: Props = Props() props: Props = Props()
target_temp: int = 0 target_temp: float = 0
type: str = None type: str = None
steps: List[Step]= field(default_factory=list) steps: List[Step]= field(default_factory=list)
instance: str = None instance: str = None

View file

@ -178,6 +178,8 @@ class SystemController:
mempercent = 0 mempercent = 0
eth0IP = "N/A" eth0IP = "N/A"
wlan0IP = "N/A" wlan0IP = "N/A"
eth0speed = "N/A"
wlan0speed = "N/A"
TEMP_UNIT=self.cbpi.config.get("TEMP_UNIT", "C") TEMP_UNIT=self.cbpi.config.get("TEMP_UNIT", "C")
FAHRENHEIT = False if TEMP_UNIT == "C" else True FAHRENHEIT = False if TEMP_UNIT == "C" else True
@ -225,6 +227,17 @@ class SystemController:
if str(addr.family) == "AddressFamily.AF_INET": if str(addr.family) == "AddressFamily.AF_INET":
if addr.address: if addr.address:
wlan0IP = addr.address wlan0IP = addr.address
info = psutil.net_if_stats()
try:
for nic in info:
if nic == 'eth0':
if info[nic].speed:
eth0speed = info[nic].speed
if nic == 'wlan0':
if info[nic].speed:
wlan0speed = info[nic].speed
except Exception as e:
logging.info(e)
except: except:
pass pass
@ -242,6 +255,17 @@ class SystemController:
if str(addr.family) == "AddressFamily.AF_INET": if str(addr.family) == "AddressFamily.AF_INET":
if addr.address: if addr.address:
wlan0IP = addr.address wlan0IP = addr.address
info = psutil.net_if_stats()
try:
for nic in info:
if nic == 'Ethernet':
if info[nic].speed:
eth0speed = info[nic].speed
if nic == 'WLAN':
if info[nic].speed:
wlan0speed = info[nic].speed
except Exception as e:
logging.info(e)
except: except:
pass pass
@ -258,7 +282,9 @@ class SystemController:
'temp': temp, 'temp': temp,
'temp_unit': TEMP_UNIT, 'temp_unit': TEMP_UNIT,
'eth0': eth0IP, 'eth0': eth0IP,
'wlan0': wlan0IP} 'wlan0': wlan0IP,
'eth0speed': eth0speed,
'wlan0speed': wlan0speed}
return systeminfo return systeminfo

View file

@ -92,7 +92,7 @@ class FermenterTargetTempStep(CBPiFermentationStep):
self.shutdown = False self.shutdown = False
self.AutoMode = True if self.props.get("AutoMode","No") == "Yes" else False self.AutoMode = True if self.props.get("AutoMode","No") == "Yes" else False
if self.fermenter is not None: if self.fermenter is not None:
self.fermenter.target_temp = int(self.props.get("Temp", 0)) self.fermenter.target_temp = float(self.props.get("Temp", 0))
if self.AutoMode == True: if self.AutoMode == True:
await self.setAutoMode(True) await self.setAutoMode(True)
self.summary = "Waiting for Target Temp" self.summary = "Waiting for Target Temp"
@ -204,7 +204,7 @@ class FermenterStep(CBPiFermentationStep):
self.AutoMode = True if self.props.get("AutoMode", "No") == "Yes" else False self.AutoMode = True if self.props.get("AutoMode", "No") == "Yes" else False
if self.fermenter is not None: if self.fermenter is not None:
self.fermenter.target_temp = int(self.props.get("Temp", 0)) self.fermenter.target_temp = float(self.props.get("Temp", 0))
if self.AutoMode == True: if self.AutoMode == True:
await self.setAutoMode(True) await self.setAutoMode(True)
await self.push_update() await self.push_update()