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