@@ -59,6 +59,12 @@ async def test_state(monkeypatch: Any) -> None:
5959 assert state .target_temperature .desc == ""
6060 assert state .target_temperature .unit == "°C"
6161
62+ # Cooling target temperature assertions
63+ assert state .target_temperature_high is not None
64+ assert state .target_temperature_high .value == 21.0
65+ assert state .target_temperature_high .desc == ""
66+ assert state .target_temperature_high .unit == "°C"
67+
6268 # HVAC mode changeover assertions
6369 assert state .hvac_mode_changeover is not None
6470 assert state .hvac_mode_changeover .value == 2
@@ -81,5 +87,68 @@ async def test_state(monkeypatch: Any) -> None:
8187
8288 # Verify API call
8389 request_mock .assert_called_once_with (
84- params = {"Parameter" : "700,710,900,8000,8740,770" }
90+ params = {"Parameter" : "700,710,900,902, 8000,8740,770" }
8591 )
92+
93+
94+ @pytest .mark .asyncio
95+ async def test_state_with_cooling_include (monkeypatch : Any ) -> None :
96+ """Test fetching only the cooling target temperature."""
97+ async with aiohttp .ClientSession () as session :
98+ config = BSBLANConfig (host = "example.com" )
99+ bsblan = BSBLAN (config , session = session )
100+
101+ monkeypatch .setattr (bsblan , "_firmware_version" , "1.0.38-20200730234859" )
102+ monkeypatch .setattr (bsblan , "_api_version" , "v3" )
103+ monkeypatch .setattr (bsblan , "_api_data" , API_V3 )
104+
105+ api_validator = APIValidator (API_V3 )
106+ api_validator .validated_sections .add ("heating" )
107+ bsblan ._api_validator = api_validator
108+
109+ state_data = json .loads (load_fixture ("state.json" ))
110+ request_mock : AsyncMock = AsyncMock (return_value = {"902" : state_data ["902" ]})
111+ monkeypatch .setattr (bsblan , "_request" , request_mock )
112+
113+ state : State = await bsblan .state (include = ["target_temperature_high" ])
114+
115+ assert state .target_temperature_high is not None
116+ assert state .target_temperature_high .value == 21.0
117+ assert state .target_temperature is None
118+ request_mock .assert_awaited_once_with (params = {"Parameter" : "902" })
119+
120+
121+ @pytest .mark .asyncio
122+ async def test_state_without_cooling_strips_target_temperature_high (
123+ monkeypatch : Any ,
124+ ) -> None :
125+ """Test unsupported cooling setpoint is stripped during validation."""
126+ async with aiohttp .ClientSession () as session :
127+ config = BSBLANConfig (host = "example.com" )
128+ bsblan = BSBLAN (config , session = session )
129+
130+ monkeypatch .setattr (bsblan , "_firmware_version" , "1.0.38-20200730234859" )
131+ monkeypatch .setattr (bsblan , "_api_version" , "v3" )
132+ bsblan ._api_data = {
133+ section : params .copy () for section , params in API_V3 .items ()
134+ }
135+ bsblan ._api_validator = APIValidator (bsblan ._api_data )
136+
137+ state_data = json .loads (load_fixture ("state.json" ))
138+ validation_response = {"700" : state_data ["700" ]}
139+ fetch_response = {"700" : state_data ["700" ]}
140+ request_mock : AsyncMock = AsyncMock (
141+ side_effect = [validation_response , fetch_response ]
142+ )
143+ monkeypatch .setattr (bsblan , "_request" , request_mock )
144+
145+ state : State = await bsblan .state (
146+ include = ["hvac_mode" , "target_temperature_high" ]
147+ )
148+
149+ assert state .hvac_mode is not None
150+ assert state .target_temperature_high is None
151+ assert bsblan .get_parameter_id ("target_temperature_high" ) is None
152+ assert [
153+ call .kwargs ["params" ]["Parameter" ] for call in request_mock .await_args_list
154+ ] == ["700,902" , "700" ]
0 commit comments