from dataclasses import dataclass from datetime import datetime from dse_shared_libs.traffic_light_color import TrafficLightColor @dataclass class TrafficLightState: tlid: str color: TrafficLightColor last_switch: datetime def to_dict(self): return {'tlid': self.tlid, 'color': self.color.name, 'last_switch': self.last_switch.timestamp()}