Identified internal_temperature and charge_max_current
This commit is contained in:
parent
6cbf480307
commit
7a61f60ecc
1 changed files with 23 additions and 19 deletions
42
solar_ble.py
42
solar_ble.py
|
@ -173,7 +173,7 @@ def parse_battery_state(data: bytes) -> dict:
|
|||
"battery_charge", # %
|
||||
"battery_voltage", # V
|
||||
"battery_current", # A
|
||||
"_internal_temperature?", # °C
|
||||
"internal_temperature", # °C
|
||||
"battery_temperature", # °C
|
||||
"load_voltage", # V
|
||||
"load_current", # A
|
||||
|
@ -190,7 +190,7 @@ def parse_battery_state(data: bytes) -> dict:
|
|||
res["battery_current"] /= 100
|
||||
res["load_voltage"] /= 10
|
||||
res["load_current"] /= 100
|
||||
res["_internal_temperature?"] = parse_temperature(res["_internal_temperature?"])
|
||||
res["internal_temperature"] = parse_temperature(res["internal_temperature"])
|
||||
res["battery_temperature"] = parse_temperature(res["battery_temperature"])
|
||||
res["panel_voltage"] /= 10
|
||||
res["panel_current"] /= 100
|
||||
|
@ -204,20 +204,22 @@ def parse_historical_entry(data: bytes) -> dict:
|
|||
(
|
||||
"battery_voltage_min", # V
|
||||
"battery_voltage_max", # V
|
||||
"unknown1",
|
||||
"unknown2",
|
||||
"charge_max_power",
|
||||
"discharge_max_power",
|
||||
"charge_amp_hour",
|
||||
"discharge_amp_hour",
|
||||
"production_power",
|
||||
"consumption_power",
|
||||
"charge_max_current", # A
|
||||
"_discharge_max_current?", # A
|
||||
"charge_max_power", # W
|
||||
"discharge_max_power", # W
|
||||
"charge_amp_hour", # Ah
|
||||
"discharge_amp_hour", # Ah
|
||||
"production_power", # Wh
|
||||
"consumption_power", # Wh
|
||||
),
|
||||
struct.unpack_from("!10H", data),
|
||||
)
|
||||
)
|
||||
res["battery_voltage_min"] /= 10
|
||||
res["battery_voltage_max"] /= 10
|
||||
res["charge_max_current"] /= 100
|
||||
res["_discharge_max_current?"] /= 100
|
||||
|
||||
if len(data) > 20:
|
||||
res.update(
|
||||
|
@ -227,10 +229,10 @@ def parse_historical_entry(data: bytes) -> dict:
|
|||
"run_days",
|
||||
"discharge_count",
|
||||
"full_charge_count",
|
||||
"total_charge_amp_hours",
|
||||
"total_discharge_amp_hours",
|
||||
"total_production_power",
|
||||
"total_consumption_power",
|
||||
"total_charge_amp_hours", # Ah
|
||||
"total_discharge_amp_hours", # Ah
|
||||
"total_production_power", # Wh
|
||||
"total_consumption_power", # Wh
|
||||
),
|
||||
struct.unpack_from("!3H4L", data, offset=20),
|
||||
),
|
||||
|
@ -318,7 +320,7 @@ if __name__ == "__main__":
|
|||
while True:
|
||||
try:
|
||||
log("Connecting...")
|
||||
with BTLEUart(MAC, timeout=10) as dev:
|
||||
with BTLEUart(MAC, timeout=30) as dev:
|
||||
log("Connected.")
|
||||
|
||||
# write(dev, construct_request(0, 32))
|
||||
|
@ -349,16 +351,18 @@ if __name__ == "__main__":
|
|||
try:
|
||||
d = parse_battery_state(res)
|
||||
log(d)
|
||||
except struct.error:
|
||||
log("0x0100 Unpack error:", res)
|
||||
except struct.error as e:
|
||||
log(e)
|
||||
log("0x0100 Unpack error:", len(res), res)
|
||||
if per_current_hist(now):
|
||||
res = readMemory(dev, 0x010B, 21)
|
||||
if res:
|
||||
try:
|
||||
d = parse_historical_entry(res)
|
||||
log(d)
|
||||
except struct.error:
|
||||
log("0x010B Unpack error:", res)
|
||||
except struct.error as e:
|
||||
log(e)
|
||||
log("0x010B Unpack error:", len(res), res)
|
||||
# print(".")
|
||||
time.sleep(1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue