Per-pack BMS queries (id arg): batSoc source + host_probe7
This commit is contained in:
1 parent
62e0fd649b
commit
3d59a75f14
5 files changed
+223
-13
No files matched your search
@@ -37,3 +37,25 @@ class TestExtractSoc(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class TestBmsSoc(unittest.TestCase):
|
||||
def test_batsoc_key(self):
|
||||
from franklinwh_agate_client.battery import SOC_KEYS
|
||||
self.assertIn("batSoc", SOC_KEYS)
|
||||
|
||||
def test_batsoc_extracted(self):
|
||||
reply = {"cmdType": 1706,
|
||||
"dataArea": {"opt": 0, "result": 0, "id": 1, "batSoc": 87,
|
||||
"batSoh": 100}}
|
||||
out = extract_soc(reply)
|
||||
self.assertEqual(out["value"], 87)
|
||||
self.assertEqual(out["source"], "batSoc")
|
||||
|
||||
def test_bms_query_carries_pack_id(self):
|
||||
from franklinwh_agate_client.protocol import (
|
||||
CommunicationCmd, direct_connect_request)
|
||||
env = direct_connect_request(CommunicationCmd.BMS, "SN",
|
||||
data={"id": 2})
|
||||
self.assertEqual(env.to_dict()["dataArea"], {"opt": 0, "id": 2})
|
||||
self.assertEqual(env.cmd_type, 1705)
|
||||
Reference in new issue
Block a user