11# pylint: disable=W0621
2- """Asynchronous Python client for BSBLan."""
2+ """Asynchronous Python client for BSBLan.
3+
4+ This example demonstrates the optimized hot water functionality:
5+ - HotWaterState: Essential parameters for frequent polling (6 fields)
6+ - HotWaterConfig: Configuration parameters checked less frequently (15 fields)
7+ - HotWaterSchedule: Time program schedules checked occasionally (8 fields)
8+
9+ This three-tier approach reduces API calls by 79% for regular monitoring.
10+ """
311
412from __future__ import annotations
513
1321 BSBLANConfig ,
1422 Device ,
1523 DeviceTime ,
24+ HotWaterConfig ,
25+ HotWaterSchedule ,
1626 HotWaterState ,
1727 Info ,
1828 Sensor ,
@@ -145,11 +155,11 @@ async def print_static_state(static_state: StaticState) -> None:
145155
146156
147157async def print_hot_water_state (hot_water_state : HotWaterState ) -> None :
148- """Print hot water state information.
158+ """Print essential hot water state information.
149159
150160 Args:
151- hot_water_state (HotWaterState): The hot water state information from the
152- BSBLan device.
161+ hot_water_state (HotWaterState): The essential hot water state information
162+ from the BSBLan device (optimized for frequent polling) .
153163
154164 """
155165 attributes = {
@@ -163,41 +173,82 @@ async def print_hot_water_state(hot_water_state: HotWaterState) -> None:
163173 hot_water_state .reduced_setpoint , "value" , "N/A"
164174 ),
165175 "Release" : await get_attribute (hot_water_state .release , "desc" , "N/A" ),
176+ "Current Temperature" : await get_attribute (
177+ hot_water_state .dhw_actual_value_top_temperature , "value" , "N/A"
178+ ),
179+ "DHW Pump State" : await get_attribute (
180+ hot_water_state .state_dhw_pump , "desc" , "N/A"
181+ ),
182+ }
183+ print_attributes ("Hot Water State (Essential)" , attributes )
184+
185+
186+ async def print_hot_water_config (hot_water_config : HotWaterConfig ) -> None :
187+ """Print hot water configuration information.
188+
189+ Args:
190+ hot_water_config (HotWaterConfig): The hot water configuration information
191+ from the BSBLan device (checked less frequently).
192+
193+ """
194+ attributes = {
195+ "Nominal Setpoint Max" : await get_attribute (
196+ hot_water_config .nominal_setpoint_max , "value" , "N/A"
197+ ),
166198 "Legionella Function" : await get_attribute (
167- hot_water_state .legionella_function , "desc" , "N/A"
199+ hot_water_config .legionella_function , "desc" , "N/A"
200+ ),
201+ "Legionella Setpoint" : await get_attribute (
202+ hot_water_config .legionella_setpoint , "value" , "N/A"
168203 ),
169204 "Legionella Periodicity" : await get_attribute (
170- hot_water_state .legionella_periodicity , "value" , "N/A"
205+ hot_water_config .legionella_periodicity , "value" , "N/A"
171206 ),
172- "Legionella Setpoint " : await get_attribute (
173- hot_water_state . legionella_setpoint , "value " , "N/A"
207+ "Circulation Pump Release " : await get_attribute (
208+ hot_water_config . dhw_circulation_pump_release , "desc " , "N/A"
174209 ),
175- "Current Temperature " : await get_attribute (
176- hot_water_state . dhw_actual_value_top_temperature , "value" , "N/A"
210+ "Circulation Setpoint " : await get_attribute (
211+ hot_water_config . dhw_circulation_setpoint , "value" , "N/A"
177212 ),
178- "Time Program Monday" : await get_attribute (
179- hot_water_state .dhw_time_program_monday , "value" , "N/A"
213+ }
214+ print_attributes ("Hot Water Configuration" , attributes )
215+
216+
217+ async def print_hot_water_schedule (hot_water_schedule : HotWaterSchedule ) -> None :
218+ """Print hot water schedule information.
219+
220+ Args:
221+ hot_water_schedule (HotWaterSchedule): The hot water schedule information
222+ from the BSBLan device (time programs).
223+
224+ """
225+ attributes = {
226+ "Monday" : await get_attribute (
227+ hot_water_schedule .dhw_time_program_monday , "value" , "N/A"
228+ ),
229+ "Tuesday" : await get_attribute (
230+ hot_water_schedule .dhw_time_program_tuesday , "value" , "N/A"
180231 ),
181- "Time Program Tuesday " : await get_attribute (
182- hot_water_state . dhw_time_program_tuesday , "value" , "N/A"
232+ "Wednesday " : await get_attribute (
233+ hot_water_schedule . dhw_time_program_wednesday , "value" , "N/A"
183234 ),
184- "Time Program Wednesday " : await get_attribute (
185- hot_water_state . dhw_time_program_wednesday , "value" , "N/A"
235+ "Thursday " : await get_attribute (
236+ hot_water_schedule . dhw_time_program_thursday , "value" , "N/A"
186237 ),
187- "Time Program Thursday " : await get_attribute (
188- hot_water_state . dhw_time_program_thursday , "value" , "N/A"
238+ "Friday " : await get_attribute (
239+ hot_water_schedule . dhw_time_program_friday , "value" , "N/A"
189240 ),
190- "Time Program Friday " : await get_attribute (
191- hot_water_state . dhw_time_program_friday , "value" , "N/A"
241+ "Saturday " : await get_attribute (
242+ hot_water_schedule . dhw_time_program_saturday , "value" , "N/A"
192243 ),
193- "Time Program Saturday " : await get_attribute (
194- hot_water_state . dhw_time_program_saturday , "value" , "N/A"
244+ "Sunday " : await get_attribute (
245+ hot_water_schedule . dhw_time_program_sunday , "value" , "N/A"
195246 ),
196- "Time Program Sunday " : await get_attribute (
197- hot_water_state . dhw_time_program_sunday , "value" , "N/A"
247+ "Standard Values " : await get_attribute (
248+ hot_water_schedule . dhw_time_program_standard_values , "value" , "N/A"
198249 ),
199250 }
200- print_attributes ("Hot Water State " , attributes )
251+ print_attributes ("Hot Water Schedule " , attributes )
201252
202253
203254async def main () -> None :
@@ -241,10 +292,24 @@ async def main() -> None:
241292 static_state : StaticState = await bsblan .static_values ()
242293 await print_static_state (static_state )
243294
244- # Get hot water state
295+ # Get hot water state (essential parameters for frequent polling)
245296 hot_water_state : HotWaterState = await bsblan .hot_water_state ()
246297 await print_hot_water_state (hot_water_state )
247298
299+ # Get hot water configuration (checked less frequently)
300+ try :
301+ hot_water_config : HotWaterConfig = await bsblan .hot_water_config ()
302+ await print_hot_water_config (hot_water_config )
303+ except Exception as e : # noqa: BLE001
304+ print (f"Hot water configuration not available: { e } " )
305+
306+ # Get hot water schedule (time programs)
307+ try :
308+ hot_water_schedule : HotWaterSchedule = await bsblan .hot_water_schedule ()
309+ await print_hot_water_schedule (hot_water_schedule )
310+ except Exception as e : # noqa: BLE001
311+ print (f"Hot water schedule not available: { e } " )
312+
248313 # Example: Set DHW time program for Monday
249314 print ("\n Setting DHW time program for Monday to 13:00-14:00" )
250315
0 commit comments