1414
1515@dataclass
1616class PricingGet :
17- fault_state : int = 0
18- fault_str : str = NO_ERROR
17+ fault_state : int = field ( default = 0 )
18+ fault_str : str = field ( default = NO_ERROR )
1919 prices : Dict = field (default_factory = empty_dict_factory )
2020
2121
22- def get_factory () -> PricingGet :
23- return PricingGet ()
22+ def create_pricing_get_with_topics (topic_prefix : str ) -> PricingGet :
23+ """Factory function to create PricingGet with custom topic prefix"""
24+ pricing_get = PricingGet ()
25+ pricing_get .__dataclass_fields__ ['fault_state' ].metadata = {"topic" : f"{ topic_prefix } /get/fault_state" }
26+ pricing_get .__dataclass_fields__ ['fault_str' ].metadata = {"topic" : f"{ topic_prefix } /get/fault_str" }
27+ pricing_get .__dataclass_fields__ ['prices' ].metadata = {"topic" : f"{ topic_prefix } /get/prices" }
28+ return pricing_get
29+
30+
31+ def flexible_tariff_get_factory () -> PricingGet :
32+ return create_pricing_get_with_topics ("ep/flexible_tariff" )
33+
34+
35+ def grid_fee_get_factory () -> PricingGet :
36+ return create_pricing_get_with_topics ("ep/grid_fee" )
2437
2538
2639@dataclass
2740class FlexibleTariff :
28- get : PricingGet = field (default_factory = get_factory )
41+ get : PricingGet = field (default_factory = flexible_tariff_get_factory )
2942
3043
3144def get_flexible_tariff_factory () -> FlexibleTariff :
@@ -34,7 +47,7 @@ def get_flexible_tariff_factory() -> FlexibleTariff:
3447
3548@dataclass
3649class GridFee :
37- get : PricingGet = field (default_factory = get_factory )
50+ get : PricingGet = field (default_factory = grid_fee_get_factory )
3851
3952
4053def get_grid_fee_factory () -> GridFee :
@@ -43,8 +56,8 @@ def get_grid_fee_factory() -> GridFee:
4356
4457@dataclass
4558class ElectricityPricingGet :
46- next_query_time : Optional [float ] = None
47- _prices : Dict = field (default_factory = empty_dict_factory )
59+ next_query_time : Optional [float ] = field ( default = None , metadata = { "topic" : "ep/next_query_time" })
60+ _prices : Dict = field (default_factory = empty_dict_factory , metadata = { "topic" : "ep/prices" } )
4861
4962 @property
5063 def prices (self ) -> Dict :
@@ -78,7 +91,7 @@ def electricity_pricing_get_factory() -> ElectricityPricingGet:
7891
7992@dataclass
8093class ElectricityPricing :
81- configured : bool = False
94+ configured : bool = field ( default = False , metadata = { "topic" : "ep/configured" })
8295 flexible_tariff : FlexibleTariff = field (default_factory = get_flexible_tariff_factory )
8396 grid_fee : GridFee = field (default_factory = get_grid_fee_factory )
8497 get : ElectricityPricingGet = field (default_factory = electricity_pricing_get_factory )
@@ -88,55 +101,52 @@ def ep_factory() -> ElectricityPricing:
88101 return ElectricityPricing ()
89102
90103
104+ def cards_display_theme_factory () -> CardsDisplayTheme :
105+ return CardsDisplayTheme ()
106+
107+
91108@dataclass
92109class InternalDisplay :
93- active : bool = False
94- on_if_plugged_in : bool = True
95- pin_active : bool = False
96- pin_code : str = "0000"
97- standby : int = 60
98- theme : CardsDisplayTheme = CardsDisplayTheme ()
110+ active : bool = field (default = False , metadata = {"topic" : "int_display/active" })
111+ detected : bool = field (default = False , metadata = {"topic" : "int_display/detected" })
112+ on_if_plugged_in : bool = field (default = True , metadata = {"topic" : "int_display/on_if_plugged_in" })
113+ only_local_charge_points : bool = field (default = False , metadata = {"topic" : "int_display/only_local_charge_points" })
114+ pin_active : bool = field (default = False , metadata = {"topic" : "int_display/pin_active" })
115+ pin_code : str = field (default = "0000" , metadata = {"topic" : "int_display/pin_code" })
116+ rotation : int = field (default = 0 , metadata = {"topic" : "int_display/rotation" })
117+ standby : int = field (default = 60 , metadata = {"topic" : "int_display/standby" })
118+ theme : CardsDisplayTheme = field (default_factory = cards_display_theme_factory ,
119+ metadata = {"topic" : "int_display/theme" })
99120
100121
101122def int_display_factory () -> InternalDisplay :
102123 return InternalDisplay ()
103124
104125
105- @dataclass
106- class Led :
107- active : bool = False
108-
109-
110- def led_factory () -> Led :
111- return Led ()
112-
113-
114126@dataclass
115127class Rfid :
116- active : bool = False
128+ active : bool = field ( default = False , metadata = { "topic" : "rfid/active" })
117129
118130
119131def rfid_factory () -> Rfid :
120132 return Rfid ()
121133
122134
123135@dataclass
124- class Ocpp :
136+ class OcppConfig :
125137 active : bool = False
126- boot_notification_sent : bool = False
127- _url : Optional [str ] = None
138+ url : Optional [str ] = None
128139 version : str = "ocpp1.6"
129140
130- @property
131- def url (self ) -> Optional [str ]:
132- return self ._url
133141
134- @url .setter
135- def url (self , value : Optional [str ]):
136- if value is not None and not value .endswith ("/" ):
137- self ._url = value + "/"
138- else :
139- self ._url = value
142+ def ocpp_config_factory () -> OcppConfig :
143+ return OcppConfig ()
144+
145+
146+ @dataclass
147+ class Ocpp :
148+ config : OcppConfig = field (default_factory = ocpp_config_factory , metadata = {"topic" : "ocpp/config" })
149+ boot_notification_sent : bool = field (default = False , metadata = {"topic" : "ocpp/boot_notification_sent" })
140150
141151
142152def ocpp_factory () -> Ocpp :
@@ -147,9 +157,8 @@ def ocpp_factory() -> Ocpp:
147157class OptionalData :
148158 electricity_pricing : ElectricityPricing = field (default_factory = ep_factory )
149159 int_display : InternalDisplay = field (default_factory = int_display_factory )
150- led : Led = field (default_factory = led_factory )
151160 rfid : Rfid = field (default_factory = rfid_factory )
152- dc_charging : bool = False
161+ dc_charging : bool = field ( default = False , metadata = { "topic" : "dc_charging" })
153162 ocpp : Ocpp = field (default_factory = ocpp_factory )
154163
155164
0 commit comments