Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connectivity_status to Pod #17

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion podpointclient/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .charge import Charge
from .charge_mode import ChargeMode
from .charge_override import ChargeOverride
from .connectivity_status import ConnectivityStatus


class StatusName(StrEnum):
Expand Down Expand Up @@ -165,6 +166,7 @@ def __init__(self, data: Dict[str, Any]):
self.offering_energy: bool = False
self.last_message_at: datetime = None
self.charging_state: str = None
self.connectivity_status: ConnectivityStatus = None

self.firmware: Union(Firmware, None) = None

Expand Down Expand Up @@ -288,7 +290,8 @@ def dict(self) -> Dict[str, Any]:
"charge_override": None,
"offering_energy": self.offering_energy,
"last_message_at": lazy_iso_format_datetime(self.last_message_at),
"charging_state": self.charging_state if self.charging_state is not None else "Unknown"
"charging_state": self.charging_state if self.charging_state is not None else "Unknown",
"connectivity_status": self.connectivity_status.dict if self.connectivity_status is not None else None,
}

for status in self.statuses:
Expand Down
2 changes: 1 addition & 1 deletion podpointclient/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version for the podpointclient library"""

__version__ = "1.6.0"
__version__ = "1.6.1"
4 changes: 2 additions & 2 deletions tests/test_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ def test_serialisation():
pod = Pod(data=complete_pod_fixture())
pod.firmware = Firmware(data=complete_firmware_fixture())

expected = {'id': 113113, 'name': 'Foo Pod', 'ppid': 'PSL-254321', 'offering_energy': False, 'payg': False, 'home': True, 'public': False, 'evZone': False, 'location': {'lat': 51.4995, 'lng': 0.1248}, 'address_id': 987, 'description': 'My pod description', 'charging_state': 'Unknown', 'commissioned_at': '2022-01-01T09:00:00+00:00', 'created_at': '2022-02-01T10:00:00+00:00', 'last_contact_at': '2022-01-11T02:15:59+01:00', 'last_message_at': None, 'contactless_enabled': False, 'unit_id': 198765, 'timezone': 'UTC', 'model': {'id': 123, 'name': 'S7-UC-03-ACA', 'vendor': 'Pod Point', 'supports_payg': False, 'supports_ocpp': False, 'supports_contactless': False, 'image_url': None}, 'price': None, 'statuses': [{'id': 2, 'name': 'Charging', 'key_name': 'charging', 'label': 'Charging', 'door': 'A', 'door_id': 1}], 'unit_connectors': [{'connector': {'id': 123, 'door': 'A', 'door_id': 1, 'power': 7, 'current': 32, 'voltage': 230, 'charge_method': 'Single Phase AC', 'has_cable': False, 'socket': {'type': 'IEC 62196-2 Type 2', 'description': 'Type 2 socket', 'ocpp_name': 'sType2', 'ocpp_code': 3}}}], 'charge_schedules': [
expected = {'id': 113113, 'name': 'Foo Pod', 'ppid': 'PSL-254321', 'offering_energy': False, 'payg': False, 'home': True, 'public': False, 'evZone': False, 'location': {'lat': 51.4995, 'lng': 0.1248}, 'address_id': 987, 'description': 'My pod description', 'charging_state': 'Unknown', 'connectivity_status': None, 'commissioned_at': '2022-01-01T09:00:00+00:00', 'created_at': '2022-02-01T10:00:00+00:00', 'last_contact_at': '2022-01-11T02:15:59+01:00', 'last_message_at': None, 'contactless_enabled': False, 'unit_id': 198765, 'timezone': 'UTC', 'model': {'id': 123, 'name': 'S7-UC-03-ACA', 'vendor': 'Pod Point', 'supports_payg': False, 'supports_ocpp': False, 'supports_contactless': False, 'image_url': None}, 'price': None, 'statuses': [{'id': 2, 'name': 'Charging', 'key_name': 'charging', 'label': 'Charging', 'door': 'A', 'door_id': 1}], 'unit_connectors': [{'connector': {'id': 123, 'door': 'A', 'door_id': 1, 'power': 7, 'current': 32, 'voltage': 230, 'charge_method': 'Single Phase AC', 'has_cable': False, 'socket': {'type': 'IEC 62196-2 Type 2', 'description': 'Type 2 socket', 'ocpp_name': 'sType2', 'ocpp_code': 3}}}], 'charge_schedules': [
{'uid': 'a18eb318-f84b-48a8-9f84-e5cb44e32b16', 'start_day': 1, 'start_time': '00:00:00', 'end_day': 1, 'end_time': '00:00:01', 'status': {'is_active': True}}, {'uid': 'ec1a9a6c-bb4e-4435-a676-06eea8fd8f1a', 'start_day': 2, 'start_time': '00:00:00', 'end_day': 2, 'end_time': '00:00:01', 'status': {'is_active': True}}, {'uid': 'c5447a64-0aeb-4e1e-9af1-c5e13b7acf0c', 'start_day': 3, 'start_time': '00:00:00', 'end_day': 3, 'end_time': '00:00:01', 'status': {'is_active': True}}, {'uid': '8de14592-47f8-4102-a2a8-ef0638a97eb8', 'start_day': 4, 'start_time': '00:00:00', 'end_day': 4, 'end_time': '00:00:01', 'status': {'is_active': True}}, {'uid': '8e7ff42e-d1a4-4fa1-985f-7a5768d16852', 'start_day': 5, 'start_time': '00:00:00', 'end_day': 5, 'end_time': '00:00:01', 'status': {'is_active': False}}, {'uid': 'dfa4d6e5-fb69-43d1-85b1-41c818f6940e', 'start_day': 6, 'start_time': '00:00:00', 'end_day': 6, 'end_time': '00:00:01', 'status': {'is_active': False}}, {'uid': 'fd378f0b-c91a-4377-ab02-7d668a505b5b', 'start_day': 7, 'start_time': '00:00:00', 'end_day': 7, 'end_time': '00:00:01', 'status': {'is_active': False}}], "current_kwh": 0.0, "total_kwh": 0.0, "total_charge_seconds": 0, "total_cost": 0, "firmware": {'serial_number': '123456789', 'update_status': {'is_update_available': False}, 'version_info': {'manifest_id': 'A30P-3.1.22-00001'}}, 'charge_override': None }

assert pod.dict == expected
assert pod.to_json() == '{"id": 113113, "name": "Foo Pod", "ppid": "PSL-254321", "payg": false, "home": true, "public": false, "evZone": false, "location": {"lat": 51.4995, "lng": 0.1248}, "address_id": 987, "description": "My pod description", "commissioned_at": "2022-01-01T09:00:00+00:00", "created_at": "2022-02-01T10:00:00+00:00", "last_contact_at": "2022-01-11T02:15:59+01:00", "contactless_enabled": false, "unit_id": 198765, "timezone": "UTC", "model": {"id": 123, "name": "S7-UC-03-ACA", "vendor": "Pod Point", "supports_payg": false, "supports_ocpp": false, "supports_contactless": false, "image_url": null}, "price": null, "statuses": [{"id": 2, "name": "Charging", "key_name": "charging", "label": "Charging", "door": "A", "door_id": 1}], "unit_connectors": [{"connector": {"id": 123, "door": "A", "door_id": 1, "power": 7, "current": 32, "voltage": 230, "charge_method": "Single Phase AC", "has_cable": false, "socket": {"type": "IEC 62196-2 Type 2", "description": "Type 2 socket", "ocpp_name": "sType2", "ocpp_code": 3}}}], "charge_schedules": [{"uid": "a18eb318-f84b-48a8-9f84-e5cb44e32b16", "start_day": 1, "start_time": "00:00:00", "end_day": 1, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "ec1a9a6c-bb4e-4435-a676-06eea8fd8f1a", "start_day": 2, "start_time": "00:00:00", "end_day": 2, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "c5447a64-0aeb-4e1e-9af1-c5e13b7acf0c", "start_day": 3, "start_time": "00:00:00", "end_day": 3, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "8de14592-47f8-4102-a2a8-ef0638a97eb8", "start_day": 4, "start_time": "00:00:00", "end_day": 4, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "8e7ff42e-d1a4-4fa1-985f-7a5768d16852", "start_day": 5, "start_time": "00:00:00", "end_day": 5, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "dfa4d6e5-fb69-43d1-85b1-41c818f6940e", "start_day": 6, "start_time": "00:00:00", "end_day": 6, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "fd378f0b-c91a-4377-ab02-7d668a505b5b", "start_day": 7, "start_time": "00:00:00", "end_day": 7, "end_time": "00:00:01", "status": {"is_active": false}}], "total_kwh": 0.0, "total_charge_seconds": 0, "current_kwh": 0.0, "total_cost": 0, "firmware": {"serial_number": "123456789", "version_info": {"manifest_id": "A30P-3.1.22-00001"}, "update_status": {"is_update_available": false}}, "charge_override": null, "offering_energy": false, "last_message_at": null, "charging_state": "Unknown"}'
assert pod.to_json() == '{"id": 113113, "name": "Foo Pod", "ppid": "PSL-254321", "payg": false, "home": true, "public": false, "evZone": false, "location": {"lat": 51.4995, "lng": 0.1248}, "address_id": 987, "description": "My pod description", "commissioned_at": "2022-01-01T09:00:00+00:00", "created_at": "2022-02-01T10:00:00+00:00", "last_contact_at": "2022-01-11T02:15:59+01:00", "contactless_enabled": false, "unit_id": 198765, "timezone": "UTC", "model": {"id": 123, "name": "S7-UC-03-ACA", "vendor": "Pod Point", "supports_payg": false, "supports_ocpp": false, "supports_contactless": false, "image_url": null}, "price": null, "statuses": [{"id": 2, "name": "Charging", "key_name": "charging", "label": "Charging", "door": "A", "door_id": 1}], "unit_connectors": [{"connector": {"id": 123, "door": "A", "door_id": 1, "power": 7, "current": 32, "voltage": 230, "charge_method": "Single Phase AC", "has_cable": false, "socket": {"type": "IEC 62196-2 Type 2", "description": "Type 2 socket", "ocpp_name": "sType2", "ocpp_code": 3}}}], "charge_schedules": [{"uid": "a18eb318-f84b-48a8-9f84-e5cb44e32b16", "start_day": 1, "start_time": "00:00:00", "end_day": 1, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "ec1a9a6c-bb4e-4435-a676-06eea8fd8f1a", "start_day": 2, "start_time": "00:00:00", "end_day": 2, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "c5447a64-0aeb-4e1e-9af1-c5e13b7acf0c", "start_day": 3, "start_time": "00:00:00", "end_day": 3, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "8de14592-47f8-4102-a2a8-ef0638a97eb8", "start_day": 4, "start_time": "00:00:00", "end_day": 4, "end_time": "00:00:01", "status": {"is_active": true}}, {"uid": "8e7ff42e-d1a4-4fa1-985f-7a5768d16852", "start_day": 5, "start_time": "00:00:00", "end_day": 5, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "dfa4d6e5-fb69-43d1-85b1-41c818f6940e", "start_day": 6, "start_time": "00:00:00", "end_day": 6, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "fd378f0b-c91a-4377-ab02-7d668a505b5b", "start_day": 7, "start_time": "00:00:00", "end_day": 7, "end_time": "00:00:01", "status": {"is_active": false}}], "total_kwh": 0.0, "total_charge_seconds": 0, "current_kwh": 0.0, "total_cost": 0, "firmware": {"serial_number": "123456789", "version_info": {"manifest_id": "A30P-3.1.22-00001"}, "update_status": {"is_update_available": false}}, "charge_override": null, "offering_energy": false, "last_message_at": null, "charging_state": "Unknown", "connectivity_status": null}'

assert pod.unit_connectors[0].to_json() == '{"id": 123, "door": "A", "door_id": 1, "power": 7, "current": 32, "voltage": 230, "charge_method": "Single Phase AC", "has_cable": false, "socket": {"type": "IEC 62196-2 Type 2", "description": "Type 2 socket", "ocpp_name": "sType2", "ocpp_code": 3}}'
assert pod.unit_connectors[0].socket.to_json() == '{"type": "IEC 62196-2 Type 2", "description": "Type 2 socket", "ocpp_name": "sType2", "ocpp_code": 3}'
Expand Down
3 changes: 2 additions & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def test_complete_user():
'uid': 'f79028be-00e9-4a86-a6c4-d474b7aaab37'}],
'charge_override': None,
'charging_state': 'Unknown',
'connectivity_status': None,
'commissioned_at': '2022-01-25T09:00:00+00:00',
'contactless_enabled': False,
'created_at': '2022-02-13T10:39:05+00:00',
Expand Down Expand Up @@ -241,4 +242,4 @@ def test_complete_user():
'name': 'C5 Aircross Plug-in Hybrid',
'startYear': None,
'uuid': 'citroenC5AircrossPlugInHybrid'}}
assert user.to_json() == '{"id": 123456, "email": "[email protected]", "first_name": "Example", "last_name": "User", "role": "user", "hasHomeCharge": 1, "locale": "en", "preferences": [{"unitOfDistance": "mi"}], "account": {"user_id": 123456, "uid": "1a756c9b-dfac-4c2a-ba13-9cdcc2399366", "balance": 173, "currency": "GBP", "billing_address": {"business_name": "", "address1": "", "address2": "", "town": "", "postcode": "", "country": ""}, "phone": "", "mobile": null}, "vehicle": {"id": 129, "uuid": "citroenC5AircrossPlugInHybrid", "name": "C5 Aircross Plug-in Hybrid", "capacity": 7, "batteryCapacity": 13.2, "startYear": null, "endYear": null, "image": {"@1x": "https://pod-point-admin-images-prod.imgix.net/vehicle-model-images/8eb13aeaf566eaedbe648bab8a5c14c0.png?w=0.5&h=0.5", "@2x": "https://pod-point-admin-images-prod.imgix.net/vehicle-model-images/8eb13aeaf566eaedbe648bab8a5c14c0.png?w=0.75&h=0.75", "@3x": "https://pod-point-admin-images-prod.imgix.net/vehicle-model-images/8eb13aeaf566eaedbe648bab8a5c14c0.png"}, "make": {"id": 22, "name": "Citroen", "logo": {"@1x": "https://pod-point-admin-images-prod.imgix.net/vehicle-make-logos/315261a80a1287b6d1b70f5c0fa8ccde.png?w=0.5&h=0.5", "@2x": "https://pod-point-admin-images-prod.imgix.net/vehicle-make-logos/315261a80a1287b6d1b70f5c0fa8ccde.png?w=0.75&h=0.75", "@3x": "https://pod-point-admin-images-prod.imgix.net/vehicle-make-logos/315261a80a1287b6d1b70f5c0fa8ccde.png"}}}, "unit": {"id": 123456, "ppid": "211092", "name": null, "status": "Available", "architecture": "soloArch3", "pod": {"id": 123456, "name": null, "ppid": "PSL-211092", "payg": false, "home": true, "public": false, "evZone": false, "location": {"lat": 23.543643, "lng": 7.2434543}, "address_id": 12345, "description": "", "commissioned_at": "2022-01-25T09:00:00+00:00", "created_at": "2022-02-13T10:39:05+00:00", "last_contact_at": "2023-01-10T19:17:12+00:00", "contactless_enabled": false, "unit_id": 123456, "timezone": "UTC", "model": {"id": 256, "name": "S7-UC-03-ACA", "vendor": "Pod Point", "supports_payg": false, "supports_ocpp": false, "supports_contactless": false, "image_url": null}, "price": null, "statuses": [{"id": 1, "name": "Available", "key_name": "available", "label": "Available", "door": "A", "door_id": 1}], "unit_connectors": [{"connector": {"id": 303, "door": "A", "door_id": 1, "power": 7, "current": 32, "voltage": 230, "charge_method": "Single Phase AC", "has_cable": false, "socket": {"type": "IEC 62196-2 Type 2", "description": "Type 2 socket", "ocpp_name": "sType2", "ocpp_code": 3}}}], "charge_schedules": [{"uid": "2e47721e-cdb2-49d7-ba47-f956975b7ed5", "start_day": 1, "start_time": "00:00:00", "end_day": 1, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "bf3188eb-745e-4fbd-baa9-8a141eb708ed", "start_day": 2, "start_time": "00:00:00", "end_day": 2, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "80eeba4b-2e69-4e04-a1e9-6e7dfc88528e", "start_day": 3, "start_time": "00:00:00", "end_day": 3, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "3fddde7d-0809-43b3-8d16-64faf8a84e97", "start_day": 4, "start_time": "00:00:00", "end_day": 4, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "79e69a06-2c3a-442b-a65f-5766140d8874", "start_day": 5, "start_time": "00:00:00", "end_day": 5, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "0d2e6fdc-2a3d-4808-84e1-22e1d9d10be8", "start_day": 6, "start_time": "00:00:00", "end_day": 6, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "f79028be-00e9-4a86-a6c4-d474b7aaab37", "start_day": 7, "start_time": "00:00:00", "end_day": 7, "end_time": "00:00:01", "status": {"is_active": false}}], "total_kwh": 0.0, "total_charge_seconds": 0, "current_kwh": 0.0, "total_cost": 0, "firmware": null, "charge_override": null, "offering_energy": false, "last_message_at": null, "charging_state": "Unknown"}}}'
assert user.to_json() == '{"id": 123456, "email": "[email protected]", "first_name": "Example", "last_name": "User", "role": "user", "hasHomeCharge": 1, "locale": "en", "preferences": [{"unitOfDistance": "mi"}], "account": {"user_id": 123456, "uid": "1a756c9b-dfac-4c2a-ba13-9cdcc2399366", "balance": 173, "currency": "GBP", "billing_address": {"business_name": "", "address1": "", "address2": "", "town": "", "postcode": "", "country": ""}, "phone": "", "mobile": null}, "vehicle": {"id": 129, "uuid": "citroenC5AircrossPlugInHybrid", "name": "C5 Aircross Plug-in Hybrid", "capacity": 7, "batteryCapacity": 13.2, "startYear": null, "endYear": null, "image": {"@1x": "https://pod-point-admin-images-prod.imgix.net/vehicle-model-images/8eb13aeaf566eaedbe648bab8a5c14c0.png?w=0.5&h=0.5", "@2x": "https://pod-point-admin-images-prod.imgix.net/vehicle-model-images/8eb13aeaf566eaedbe648bab8a5c14c0.png?w=0.75&h=0.75", "@3x": "https://pod-point-admin-images-prod.imgix.net/vehicle-model-images/8eb13aeaf566eaedbe648bab8a5c14c0.png"}, "make": {"id": 22, "name": "Citroen", "logo": {"@1x": "https://pod-point-admin-images-prod.imgix.net/vehicle-make-logos/315261a80a1287b6d1b70f5c0fa8ccde.png?w=0.5&h=0.5", "@2x": "https://pod-point-admin-images-prod.imgix.net/vehicle-make-logos/315261a80a1287b6d1b70f5c0fa8ccde.png?w=0.75&h=0.75", "@3x": "https://pod-point-admin-images-prod.imgix.net/vehicle-make-logos/315261a80a1287b6d1b70f5c0fa8ccde.png"}}}, "unit": {"id": 123456, "ppid": "211092", "name": null, "status": "Available", "architecture": "soloArch3", "pod": {"id": 123456, "name": null, "ppid": "PSL-211092", "payg": false, "home": true, "public": false, "evZone": false, "location": {"lat": 23.543643, "lng": 7.2434543}, "address_id": 12345, "description": "", "commissioned_at": "2022-01-25T09:00:00+00:00", "created_at": "2022-02-13T10:39:05+00:00", "last_contact_at": "2023-01-10T19:17:12+00:00", "contactless_enabled": false, "unit_id": 123456, "timezone": "UTC", "model": {"id": 256, "name": "S7-UC-03-ACA", "vendor": "Pod Point", "supports_payg": false, "supports_ocpp": false, "supports_contactless": false, "image_url": null}, "price": null, "statuses": [{"id": 1, "name": "Available", "key_name": "available", "label": "Available", "door": "A", "door_id": 1}], "unit_connectors": [{"connector": {"id": 303, "door": "A", "door_id": 1, "power": 7, "current": 32, "voltage": 230, "charge_method": "Single Phase AC", "has_cable": false, "socket": {"type": "IEC 62196-2 Type 2", "description": "Type 2 socket", "ocpp_name": "sType2", "ocpp_code": 3}}}], "charge_schedules": [{"uid": "2e47721e-cdb2-49d7-ba47-f956975b7ed5", "start_day": 1, "start_time": "00:00:00", "end_day": 1, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "bf3188eb-745e-4fbd-baa9-8a141eb708ed", "start_day": 2, "start_time": "00:00:00", "end_day": 2, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "80eeba4b-2e69-4e04-a1e9-6e7dfc88528e", "start_day": 3, "start_time": "00:00:00", "end_day": 3, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "3fddde7d-0809-43b3-8d16-64faf8a84e97", "start_day": 4, "start_time": "00:00:00", "end_day": 4, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "79e69a06-2c3a-442b-a65f-5766140d8874", "start_day": 5, "start_time": "00:00:00", "end_day": 5, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "0d2e6fdc-2a3d-4808-84e1-22e1d9d10be8", "start_day": 6, "start_time": "00:00:00", "end_day": 6, "end_time": "00:00:01", "status": {"is_active": false}}, {"uid": "f79028be-00e9-4a86-a6c4-d474b7aaab37", "start_day": 7, "start_time": "00:00:00", "end_day": 7, "end_time": "00:00:01", "status": {"is_active": false}}], "total_kwh": 0.0, "total_charge_seconds": 0, "current_kwh": 0.0, "total_cost": 0, "firmware": null, "charge_override": null, "offering_energy": false, "last_message_at": null, "charging_state": "Unknown", "connectivity_status": null}}}'
Loading