mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Added battery temperature to telemetry
This commit is contained in:
parent
0425beeda5
commit
454eedd8d1
@ -466,7 +466,7 @@ class Battery(Sensor):
|
|||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
self.battery.get_state()
|
self.battery.get_state()
|
||||||
b = self.battery.status
|
b = self.battery.status
|
||||||
self.data = {"charge_percent": b["percentage"], "charging": b["isCharging"]}
|
self.data = {"charge_percent": b["percentage"], "charging": b["isCharging"], "temperature": None}
|
||||||
|
|
||||||
elif RNS.vendor.platformutils.is_linux():
|
elif RNS.vendor.platformutils.is_linux():
|
||||||
if self.battery_node_name:
|
if self.battery_node_name:
|
||||||
@ -485,7 +485,7 @@ class Battery(Sensor):
|
|||||||
|
|
||||||
is_charging = output['POWER_SUPPLY_STATUS'] == 'Charging'
|
is_charging = output['POWER_SUPPLY_STATUS'] == 'Charging'
|
||||||
charge_percent = float(output['POWER_SUPPLY_CAPACITY'])
|
charge_percent = float(output['POWER_SUPPLY_CAPACITY'])
|
||||||
self.data = {"charge_percent": round(charge_percent, 1), "charging": is_charging}
|
self.data = {"charge_percent": round(charge_percent, 1), "charging": is_charging, "temperature": None}
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.data = None
|
self.data = None
|
||||||
@ -495,14 +495,20 @@ class Battery(Sensor):
|
|||||||
if d == None:
|
if d == None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return [round(d["charge_percent"],1), d["charging"]]
|
return [round(d["charge_percent"],1), d["charging"], d["temperature"]]
|
||||||
|
|
||||||
def unpack(self, packed):
|
def unpack(self, packed):
|
||||||
try:
|
try:
|
||||||
if packed == None:
|
if packed == None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return {"charge_percent": round(packed[0], 1), "charging": packed[1]}
|
unpacked = {"charge_percent": round(packed[0], 1), "charging": packed[1]}
|
||||||
|
if len(packed) > 2:
|
||||||
|
unpacked["temperature"] = packed[2]
|
||||||
|
else:
|
||||||
|
unpacked["temperature"] = None
|
||||||
|
|
||||||
|
return unpacked
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -512,6 +518,7 @@ class Battery(Sensor):
|
|||||||
|
|
||||||
d = self.data
|
d = self.data
|
||||||
p = d["charge_percent"]
|
p = d["charge_percent"]
|
||||||
|
t = d["temperature"]
|
||||||
if d["charging"]:
|
if d["charging"]:
|
||||||
charge_string = "charging"
|
charge_string = "charging"
|
||||||
else:
|
else:
|
||||||
@ -520,7 +527,7 @@ class Battery(Sensor):
|
|||||||
rendered = {
|
rendered = {
|
||||||
"icon": "battery-outline",
|
"icon": "battery-outline",
|
||||||
"name": "Battery",
|
"name": "Battery",
|
||||||
"values": {"percent": p, "_meta": charge_string},
|
"values": {"percent": p, "temperature": t, "_meta": charge_string},
|
||||||
}
|
}
|
||||||
|
|
||||||
if d["charging"]:
|
if d["charging"]:
|
||||||
|
@ -405,7 +405,15 @@ class RVDetails(MDRecycleView):
|
|||||||
elif name == "Battery":
|
elif name == "Battery":
|
||||||
p = s["values"]["percent"]
|
p = s["values"]["percent"]
|
||||||
cs = s["values"]["_meta"]
|
cs = s["values"]["_meta"]
|
||||||
if cs != None: cs_str = f" ({cs})"
|
t = None
|
||||||
|
if "temperature" in s["values"]:
|
||||||
|
t = s["values"]["temperature"]
|
||||||
|
if cs != None:
|
||||||
|
if t != None:
|
||||||
|
cs_str = f" ({cs}, {t}° C)"
|
||||||
|
else:
|
||||||
|
cs_str = f" ({cs})"
|
||||||
|
|
||||||
if p != None: formatted_values = f"{name} [b]{p}%[/b]"+cs_str
|
if p != None: formatted_values = f"{name} [b]{p}%[/b]"+cs_str
|
||||||
|
|
||||||
elif name == "Ambient Pressure":
|
elif name == "Ambient Pressure":
|
||||||
@ -581,7 +589,7 @@ class RVDetails(MDRecycleView):
|
|||||||
load = c["current_load"]
|
load = c["current_load"]
|
||||||
avgs = c["load_avgs"]
|
avgs = c["load_avgs"]
|
||||||
clock = c["clock"]
|
clock = c["clock"]
|
||||||
pct = round(load*100, 1)
|
pct = round(load*100.0, 1)
|
||||||
|
|
||||||
avgs_str = f", averages are [b]{round(avgs[0],2)}[/b], [b]{round(avgs[1],2)}[/b], [b]{round(avgs[2],2)}[/b]" if avgs != None and len(avgs) == 3 else ""
|
avgs_str = f", averages are [b]{round(avgs[0],2)}[/b], [b]{round(avgs[1],2)}[/b], [b]{round(avgs[2],2)}[/b]" if avgs != None and len(avgs) == 3 else ""
|
||||||
clock_str = " at [b]"+RNS.prettyfrequency(clock)+"[/b]" if clock != None else ""
|
clock_str = " at [b]"+RNS.prettyfrequency(clock)+"[/b]" if clock != None else ""
|
||||||
|
Loading…
Reference in New Issue
Block a user