File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 4545 ShellyBLESetConfig ,
4646 ShellyScript ,
4747 ShellyScriptCode ,
48+ ShellyWiFiSetConfig ,
4849 ShellyWsConfig ,
4950 ShellyWsSetConfig ,
5051)
@@ -698,6 +699,27 @@ async def ble_getconfig(self) -> ShellyBLEConfig:
698699 """Get the BLE config with BLE.GetConfig."""
699700 return cast (ShellyBLEConfig , await self .call_rpc ("BLE.GetConfig" ))
700701
702+ async def wifi_setconfig (
703+ self , * , ap_enable : bool | None = None
704+ ) -> ShellyWiFiSetConfig :
705+ """Configure WiFi settings with WiFi.SetConfig.
706+
707+ Args:
708+ ap_enable: Whether to enable the WiFi AP
709+
710+ Returns:
711+ Response dict, may contain "restart_required": bool
712+
713+ """
714+ config : dict [str , Any ] = {}
715+ if ap_enable is not None :
716+ config ["ap" ] = {"enable" : ap_enable }
717+
718+ return cast (
719+ ShellyWiFiSetConfig ,
720+ await self .call_rpc ("WiFi.SetConfig" , {"config" : config }),
721+ )
722+
701723 async def ws_setconfig (
702724 self , enable : bool , server : str , ssl_ca : str = "*"
703725 ) -> ShellyWsSetConfig :
Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ class ShellyBLESetConfig(TypedDict, total=False):
3939 restart_required : bool
4040
4141
42+ class ShellyWiFiSetConfig (TypedDict , total = False ):
43+ """Shelly WiFi Set Config."""
44+
45+ restart_required : bool
46+
47+
4248class ShellyWsConfig (TypedDict , total = False ):
4349 """Shelly Outbound Websocket Config."""
4450
Original file line number Diff line number Diff line change @@ -537,6 +537,18 @@ async def test_ble_setconfig(rpc_device: RpcDevice) -> None:
537537 }
538538
539539
540+ @pytest .mark .asyncio
541+ async def test_wifi_setconfig (rpc_device : RpcDevice ) -> None :
542+ """Test RpcDevice wifi_setconfig method."""
543+ await rpc_device .wifi_setconfig (ap_enable = False )
544+
545+ assert rpc_device .call_rpc_multiple .call_count == 1
546+ assert rpc_device .call_rpc_multiple .call_args [0 ][0 ][0 ][0 ] == "WiFi.SetConfig"
547+ assert rpc_device .call_rpc_multiple .call_args [0 ][0 ][0 ][1 ] == {
548+ "config" : {"ap" : {"enable" : False }}
549+ }
550+
551+
540552@pytest .mark .asyncio
541553async def test_script_stop (rpc_device : RpcDevice ) -> None :
542554 """Test RpcDevice script_stop method."""
You can’t perform that action at this time.
0 commit comments