Skip to content

space_update

You must subclass SpaceUpdateBaseModel for the update json payload of your specific parked car sensor.

DummySpaceUpdate

Bases: SpaceUpdateBaseModel

Minimal concrete space update payload used by tests and examples.

Attributes:

Name Type Description
id LowerStr

Sensor identifier for the parking space being updated.

occ bool

Whether the space is currently occupied.

dt AwareDatetime

Timestamp associated with the device update.

occupied()

Returns self.occ.

sensor_id()

Returns self.id.

update_time()

Returns self.dt.

SpaceUpdateBaseModel

Bases: BaseModel, ABC

Abstract base model for device-specific parking sensor payloads.

Subclasses define how an incoming device message is interpreted as a parking space status update. Implementations must decide whether a payload should be processed, identify the target sensor, report whether the space is occupied, and expose the update timestamp. Method to_model() is used internally to convert a validated payload into the normalized SpaceModel stored by the app.

occupied() abstractmethod

Report whether the payload indicates an occupied space.

Returns:

Name Type Description
bool bool

True when the space is occupied, False when free.

sensor_id() abstractmethod

Return the sensor identifier for the payload.

Returns:

Name Type Description
LowerStr LowerStr

Lowercased sensor identifier understood by the app.

to_model()

Convert the payload into the normalized runtime space model.

Returns:

Name Type Description
SpaceModel SpaceModel

Normalized space update ready for persistence.

update_time() abstractmethod

Return the timezone-aware timestamp associated with the payload.

Returns:

Name Type Description
AwareDatetime AwareDatetime

Timestamp for the update, must to be timezone-aware.